API Reference
Complete REST API documentation for While — 43 endpoints.
Authentication
All endpoints require an API key passed via the Authorization header. Admin endpoints use the x-admin-secret header instead.
Base URL: https://while.sh # Standard API (Bearer token) Authorization: Bearer whl_your_api_key # Admin API (shared secret) x-admin-secret: your_admin_secret
Generate API keys via the admin endpoint or in Settings. Keys can be scoped: full, deploy, operate, read-only, sensors-only.
Projects
5 endpoints/api/projectsList all projects with environments and deploy counts
/api/projectsCreate a project with staging + production environments
{ "name": "my-app", "slug": "my-app" }/api/projects/:idGet project detail with environments, deployments, and domains
/api/projects/:idDelete a project and all associated resources
/api/projects/:id/environmentsList environments for a project
Deployments
4 endpoints/api/environments/:id/deployTrigger a new deployment (guardrails enforced)
{ "gitUrl": "https://github.com/you/app", "commitMsg": "fix: bug" }/api/environments/:id/deploymentsList deployments for an environment
/api/deployments/:idGet deployment details (status, logs, timing)
/api/deployments/:id/cancelCancel a running deployment
Databases
5 endpoints/api/environments/:id/databasesList databases for an environment
/api/environments/:id/databasesProvision a managed PostgreSQL database
{ "engine": "postgresql" }/api/databases/:idGet database details
/api/databases/:id/credentialsGet database connection credentials (host, port, user, password)
/api/databases/:idDelete a managed database
Domains
5 endpoints/api/environments/:id/domainsList domains for an environment
/api/environments/:id/domainsAdd a custom domain with auto-SSL
{ "domain": "app.example.com" }/api/domains/:idGet domain details including SSL status
/api/domains/:id/verify-sslTrigger SSL certificate verification
/api/domains/:idRemove a custom domain
Environment Variables
3 endpoints/api/environments/:id/varsList all environment variables (secrets masked)
/api/environments/:id/varsSet an environment variable (upsert)
{ "key": "DATABASE_URL", "value": "postgres://...", "isSecret": true }/api/environments/:id/vars/:keyDelete an environment variable
Scale
3 endpoints/api/environments/:id/scaleGet current replica count and status
/api/environments/:id/scaleScale to a specific number of replicas
{ "replicas": 3 }/api/environments/:id/scale/restartRolling restart of all pods
Errors
3 endpoints/api/environments/:id/errorsList errors (filterable by status: open/resolved)
/api/environments/:id/errorsIngest an error from your application
{ "message": "TypeError: ...", "stack": "...", "file": "app.ts", "line": 42 }/api/errors/:idResolve an error
Performance Metrics
2 endpoints/api/environments/:id/metricsGet current latency (p50/p95/p99), throughput, and error rate
/api/environments/:id/metricsRecord performance data points
{ "p50": 12, "p95": 45, "p99": 120, "throughput": 500, "errorRate": 0.01 }Uptime Checks
5 endpoints/api/environments/:id/uptimeList uptime checks
/api/environments/:id/uptimeCreate an HTTP health check
{ "url": "https://myapp.com/health", "interval": 60 }/api/environments/:id/uptime/summaryGet uptime status and percentages
/api/uptime/:idRun an uptime check immediately
/api/uptime/:idDelete an uptime check
Logs
1 endpoints/api/environments/:id/logsQuery application logs (supports level, limit, since filters)
Webhooks
5 endpoints/api/webhooksList all webhook subscriptions
/api/webhooksCreate a webhook subscription
{ "url": "https://agent.com/hook", "events": ["deployment.failed"], "secret": "optional" }/api/webhooks/:idGet webhook details
/api/webhooks/:idDelete a webhook subscription
/api/webhooks/:id/testSend a test payload to the webhook URL
Admin
2 endpoints/api/admin/api-keysGenerate a new API key (requires x-admin-secret header)
{ "tenantId": "...", "name": "my-key", "scopes": ["full"] }/api/admin/api-keysList API keys (no plaintext, requires x-admin-secret header)
Response Format
All endpoints return JSON. Successful responses return the resource directly. Errors return:
// Success (200/201)
{ "id": "clx...", "name": "my-app", ... }
// Error (400/401/403/404/500)
{ "error": "Project not found" }
// 403 — Guardrail blocked
{ "error": "Production is locked. Disable production lock in guardrail settings to deploy." }
// 403 — Rate limit
{ "error": "Deploy rate limit exceeded: 20/20 deploys in the last hour." }