Skip to content

Reference

Operator routes

Manage environments, variables, API keys and private workers. These routes need the operator token, which apps should never hold.

On this page

The CLI wraps each route: durable-compute environments, variables, api-keys and workers. See Environments, API keys and variables and Private workers.

Deployments are not on this page: deploy registers them by writing to the database directly, and there is no HTTP route for it yet.

List environments#

GET/v1/environments

Auth: Operator token or personalToken

dev, staging and prod, then previews by branch, each with its last run and counts. A person sees their projects' environments only.

Parameters

List environments: parameters
FieldDescription
projectstring in queryA project's ref: only its environments. One the caller does not reach is a 404.

Responses

  • 200OK EnvironmentSummary[]
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error

Get an environment#

GET/v1/environments/{slug}

Auth: Operator token or personalToken

Parameters

Get an environment: parameters
FieldDescription
slugstring in path requiredEnvironment slug. A preview's slash is sent percent-encoded: preview%2Fmy-branch.

Responses

  • 200OK Environment
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
Fields of Environment
Environment fields
FieldDescription
idstring (uuid) required
slugstring requiredEnvironment slug: dev, staging, prod or preview/<branch>, after the project's ref and a colon for every project but the first (proj_...:prod).
kindEnvironmentKind required
branchstring | null requiredThe git branch of a preview.
deployment_idstring | null requiredThe current deployment: where runs that name no deployment run.
created_atstring (date-time) required
updated_atstring (date-time) required
archived_atstring | null requiredSet on an archived preview, which refuses new runs and deploys and keeps its history.
project_idstring (uuid) requiredThe project it belongs to.

Make a deployment current in an environment#

POST/v1/environments/{slug}/promote

Auth: Operator token or personalToken

Runs that name no deployment use it from now on. The same deployment may be current in several environments. An unregistered deployment or unknown environment is a 404; an archived preview is a 409.

Parameters

Make a deployment current in an environment: parameters
FieldDescription
slugstring in path requiredEnvironment slug. A preview's slash is sent percent-encoded: preview%2Fmy-branch.

Request body PromoteRequest

Make a deployment current in an environment: request body
FieldDescription
deployment_idstring requiredA registered deployment.

Responses

  • 200OK Environment
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
  • 409The request conflicts with current state, or is fenced by a newer attempt epoch, lease or owner. Error
  • 422The JSON body did not match the request schema string
Fields of Environment
Environment fields
FieldDescription
idstring (uuid) required
slugstring requiredEnvironment slug: dev, staging, prod or preview/<branch>, after the project's ref and a colon for every project but the first (proj_...:prod).
kindEnvironmentKind required
branchstring | null requiredThe git branch of a preview.
deployment_idstring | null requiredThe current deployment: where runs that name no deployment run.
created_atstring (date-time) required
updated_atstring (date-time) required
archived_atstring | null requiredSet on an archived preview, which refuses new runs and deploys and keeps its history.
project_idstring (uuid) requiredThe project it belongs to.

Archive a preview#

POST/v1/environments/{slug}/archive

Auth: Operator token or personalToken

An archived preview refuses new runs and deploys and keeps its history; unarchive restores it. Idempotent. Archiving dev, staging or prod is a 409.

Parameters

Archive a preview: parameters
FieldDescription
slugstring in path requiredEnvironment slug. A preview's slash is sent percent-encoded: preview%2Fmy-branch.

Responses

  • 200OK Environment
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
  • 409The request conflicts with current state, or is fenced by a newer attempt epoch, lease or owner. Error
Fields of Environment
Environment fields
FieldDescription
idstring (uuid) required
slugstring requiredEnvironment slug: dev, staging, prod or preview/<branch>, after the project's ref and a colon for every project but the first (proj_...:prod).
kindEnvironmentKind required
branchstring | null requiredThe git branch of a preview.
deployment_idstring | null requiredThe current deployment: where runs that name no deployment run.
created_atstring (date-time) required
updated_atstring (date-time) required
archived_atstring | null requiredSet on an archived preview, which refuses new runs and deploys and keeps its history.
project_idstring (uuid) requiredThe project it belongs to.

Unarchive a preview#

POST/v1/environments/{slug}/unarchive

Auth: Operator token or personalToken

Restores an archived preview: it accepts runs and deploys again. Idempotent: an environment that is not archived (dev, staging and prod never are) is returned unchanged. While a preview was archived, staging writes no longer counted it, so the variables its new runs would receive (its own and staging's) may now exceed 256 KiB; then this is a 400 and the preview stays archived.

Parameters

Unarchive a preview: parameters
FieldDescription
slugstring in path requiredEnvironment slug. A preview's slash is sent percent-encoded: preview%2Fmy-branch.

Responses

  • 200OK Environment
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
Fields of Environment
Environment fields
FieldDescription
idstring (uuid) required
slugstring requiredEnvironment slug: dev, staging, prod or preview/<branch>, after the project's ref and a colon for every project but the first (proj_...:prod).
kindEnvironmentKind required
branchstring | null requiredThe git branch of a preview.
deployment_idstring | null requiredThe current deployment: where runs that name no deployment run.
created_atstring (date-time) required
updated_atstring (date-time) required
archived_atstring | null requiredSet on an archived preview, which refuses new runs and deploys and keeps its history.
project_idstring (uuid) requiredThe project it belongs to.

List an environment's variable names#

GET/v1/environments/{slug}/variables

Auth: Operator token or personalToken

Names and when each was set, never values. A preview also lists staging's variables it does not override.

Parameters

List an environment's variable names: parameters
FieldDescription
slugstring in path requiredEnvironment slug. A preview's slash is sent percent-encoded: preview%2Fmy-branch.

Responses

  • 200OK VariablesView
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
Fields of VariablesView
VariablesView fields
FieldDescription
environmentstring requiredEnvironment slug: dev, staging, prod or preview/<branch>.
variablesVariableInfo[] requiredBy name.
writableboolean requiredWhether this control plane has a secrets key, so it can store values. It says nothing about values already stored: see each variable's readable.

Set a variable#

PUT/v1/environments/{slug}/variables/{name}

Auth: Operator token or personalToken

Seals the value with XChaCha20-Poly1305 under the control plane's secrets key. New runs see it; runs already accepted keep the value they snapshotted. A malformed body is a 400 whose message never quotes it.

Parameters

Set a variable: parameters
FieldDescription
slugstring in path requiredEnvironment slug. A preview's slash is sent percent-encoded: preview%2Fmy-branch.
namestring in path requiredVariable name: [A-Za-z_][A-Za-z0-9_]*, at most 128 bytes. PATH, HOME, NODE_OPTIONS, PYTHONPATH, PYTHONHOME and names starting DC_, LD_ or DYLD_ are reserved.

Request body SetVariableRequest

Set a variable: request body
FieldDescription
valuestring requiredUp to 16 KiB of UTF-8 without NUL bytes. Sealed at rest; never returned or logged. Refused (400) when it would make the variables new runs of the environment receive (its own, plus staging's for a preview, and for staging those of every active preview) exceed 256 KiB encoded as JSON.

Responses

  • 200OK VariableInfo
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
  • 503This control plane has no secrets key (DC_SECRETS_KEY or --secrets-key-file), so it cannot store a variable. Error
Fields of VariableInfo
VariableInfo fields
FieldDescription
namestring required
updated_atstring (date-time) required
inherited_fromstring | null requiredstaging, when a preview inherits the variable rather than defining it.
readableboolean requiredWhether this control plane's secrets key opens the value. False when it was sealed under another key, or the control plane has none: runs that need it are deferred and fail after the deferral window unless a server with that key starts them. Setting it again seals it under this key.

Delete a variable#

DELETE/v1/environments/{slug}/variables/{name}

Auth: Operator token or personalToken

New runs no longer see it; a preview falls back to staging's value if staging defines one. Needs no secrets key. A name this environment does not define is a 404. In a preview, a deletion that would uncover a staging value too large for the 256 KiB limit is refused with 400.

Parameters

Delete a variable: parameters
FieldDescription
slugstring in path requiredEnvironment slug. A preview's slash is sent percent-encoded: preview%2Fmy-branch.
namestring in path requiredVariable name: [A-Za-z_][A-Za-z0-9_]*, at most 128 bytes. PATH, HOME, NODE_OPTIONS, PYTHONPATH, PYTHONHOME and names starting DC_, LD_ or DYLD_ are reserved.

Responses

  • 200OK VariableDeleted
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
Fields of VariableDeleted
VariableDeleted fields
FieldDescription
deletedboolean required
namestring required

List environment API keys#

GET/v1/api-keys

Auth: Operator token or personalToken

Never tokens or their hashes.

Parameters

List environment API keys: parameters
FieldDescription
environmentstring in queryOnly this environment's keys. An unknown environment is a 404.

Responses

  • 200OK ApiKeyRecord[]
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error

Create an environment API key#

POST/v1/api-keys

Auth: Operator token or personalToken

The response carries the token once; only its SHA-256 hash is kept. The key may list tasks and submit, list, read, cancel and signal runs in its environment only.

Request body CreateApiKeyRequest

Create an environment API key: request body
FieldDescription
environmentstring requiredEnvironment slug: dev, staging, prod or preview/<branch>.
namestring required1..64 characters, to tell keys apart.

Responses

  • 201Created. The token is never shown again. CreatedApiKey
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
  • 422The JSON body did not match the request schema string
Fields of CreatedApiKey
CreatedApiKey fields
FieldDescription
keyApiKeyRecord requiredAn environment API key as listed. Never contains the token or its hash.
tokenstring requiredThe bearer token, returned only here. Only its SHA-256 hash is stored.

Revoke an environment API key#

POST/v1/api-keys/{id}/revoke

Auth: Operator token or personalToken

Requests with it are refused from now on; runs it submitted keep running. Idempotent.

Parameters

Revoke an environment API key: parameters
FieldDescription
idstring (uuid) in path requiredAPI key ID.

Responses

  • 200OK ApiKeyRecord
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
Fields of ApiKeyRecord
ApiKeyRecord fields
FieldDescription
idstring (uuid) required
environmentstring requiredEnvironment slug: dev, staging, prod or preview/<branch>.
namestring required
prefixstring requiredThe token's public start, for example bjk_prod_1a2b3c4d.
created_atstring (date-time) required
last_used_atstring | null requiredUpdated at most every 10 seconds.
revoked_atstring | null required

List remote workers#

GET/v1/workers

Auth: Operator token

Responses

  • 200OK WorkerRecord[]
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error

Register a remote worker#

POST/v1/workers

Auth: Operator token

Request body WorkerRegistration

Register a remote worker: request body
FieldDescription
namestring required1..64 characters of [A-Za-z0-9._-].
poolPoolKind required
executorWorkerExecutor required
slotsinteger required
cpu_millisinteger required
memory_mibinteger required
deployment_idstring | nullScope: 1..256 bytes. Give both deployment_id and runtime, or neither. An in-image worker must be scoped and serve the cloud pool.
runtimeRuntime | nullScope runtime; required with deployment_id.
environmentsstring[]Environment scope, at most 16 existing slugs: the worker claims only runs of these environments, so a prod worker never runs preview code. Default: every environment.

Responses

  • 201Created. The token is returned only here. RegisteredWorker
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 409The request conflicts with current state, or is fenced by a newer attempt epoch, lease or owner. Error
  • 422The JSON body did not match the request schema string
Fields of RegisteredWorker
RegisteredWorker fields
FieldDescription
workerWorkerRecord requiredOperator view of a worker. Never contains the token or its hash.
tokenstring requiredThe worker token, returned exactly once. Only its SHA-256 hash is stored.

Revoke a worker token#

POST/v1/workers/{id}/revoke

Auth: Operator token

The worker's reservations stay held until released.

Parameters

Revoke a worker token: parameters
FieldDescription
idstring (uuid) in path requiredWorker ID.

Request body RevokeRequest

Revoke a worker token: request body
FieldDescription
reasonstring required1..1024 bytes without NUL.

Responses

  • 200OK WorkerRecord
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
  • 422The JSON body did not match the request schema string
Fields of WorkerRecord
WorkerRecord fields
FieldDescription
idstring (uuid) required
namestring required
poolPoolKind required
executorWorkerExecutor required
capacityPoolCapacity required
created_atstring (date-time) required
last_seen_atstring | null required
liveboolean required
revoked_atstring | null required
revoke_reasonstring | null required
inventoryInventoryEntry[] required
reservedPoolCapacity requiredSummed reservations of the attempts holding this worker's capacity.
reserved_attemptsstring (uuid)[] required
deployment_idstring | null requiredScope deployment, when scoped.
runtimeRuntime | null requiredScope runtime, when scoped.
draining_atstring | null required
environmentsstring[] requiredEnvironment scope: the worker claims only runs of these environments. Empty means every environment.
hot_taskstringThe hot task this warm worker is kept for. Absent for every other worker.

Release a revoked worker's reservations#

POST/v1/workers/{id}/release

Auth: Operator token

Only for a revoked worker, and only with confirm_terminated after confirming termination out of band.

Parameters

Release a revoked worker's reservations: parameters
FieldDescription
idstring (uuid) in path requiredWorker ID.

Request body ReleaseRequest

Release a revoked worker's reservations: request body
FieldDescription
confirm_terminatedbooleanAssert that every reserved execution of this revoked worker (or, for an attempt release, this attempt's execution) has terminated. Without it nothing is released.
reasonstring required1..2048 bytes without NUL.
released_bystringWho is releasing, recorded with each release: the console sends the signed-in super admin's email, the CLI `--released-by`, `DC_OPERATOR` or the account's user name. 1..320 bytes without control characters. Optional.

Responses

  • 200OK ReleaseResponse
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
  • 409The request conflicts with current state, or is fenced by a newer attempt epoch, lease or owner. Error
  • 422The JSON body did not match the request schema string
Fields of ReleaseResponse
ReleaseResponse fields
FieldDescription
worker_idstring (uuid) required
released_attemptsstring (uuid)[] required

Drain a worker#

POST/v1/workers/{id}/drain

Auth: Operator token

No request body is read. From now on the worker's claims return nothing; its agent finishes what it holds and exits. One way.

Parameters

Drain a worker: parameters
FieldDescription
idstring (uuid) in path requiredWorker ID.

Responses

  • 200OK WorkerRecord
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
Fields of WorkerRecord
WorkerRecord fields
FieldDescription
idstring (uuid) required
namestring required
poolPoolKind required
executorWorkerExecutor required
capacityPoolCapacity required
created_atstring (date-time) required
last_seen_atstring | null required
liveboolean required
revoked_atstring | null required
revoke_reasonstring | null required
inventoryInventoryEntry[] required
reservedPoolCapacity requiredSummed reservations of the attempts holding this worker's capacity.
reserved_attemptsstring (uuid)[] required
deployment_idstring | null requiredScope deployment, when scoped.
runtimeRuntime | null requiredScope runtime, when scoped.
draining_atstring | null required
environmentsstring[] requiredEnvironment scope: the worker claims only runs of these environments. Empty means every environment.
hot_taskstringThe hot task this warm worker is kept for. Absent for every other worker.

Release a quarantined embedded attempt#

POST/v1/attempts/{id}/release

Auth: Operator token

For an attempt no worker owns that stays quarantined because nothing can prove it stopped (native execution after a crash, or a container on a Docker daemon no control plane reaches any more), and only with confirm_terminated after confirming termination out of band. Until then it keeps its capacity and its queue slot. The release is audited with the worker releases, the lost duration stays unresolved and uncharged, and the run retries under its normal budget. 409 for a worker's attempt (release it with its worker) or an attempt not in quarantine.

Parameters

Release a quarantined embedded attempt: parameters
FieldDescription
idstring (uuid) in path requiredAttempt ID.

Request body ReleaseRequest

Release a quarantined embedded attempt: request body
FieldDescription
confirm_terminatedbooleanAssert that every reserved execution of this revoked worker (or, for an attempt release, this attempt's execution) has terminated. Without it nothing is released.
reasonstring required1..2048 bytes without NUL.
released_bystringWho is releasing, recorded with each release: the console sends the signed-in super admin's email, the CLI `--released-by`, `DC_OPERATOR` or the account's user name. 1..320 bytes without control characters. Optional.

Responses

  • 200OK AttemptRelease
  • 400The request was invalid: a validation error, or a malformed path, query or JSON body. Extractor rejections (malformed JSON, a bad UUID) carry a text/plain body instead. Error
  • 401Missing or wrong bearer token. Error
  • 403The credential is valid but may not read this resource. Error
  • 404The resource does not exist. Error
  • 409The request conflicts with current state, or is fenced by a newer attempt epoch, lease or owner. Error
  • 422The JSON body did not match the request schema string
Fields of AttemptRelease
AttemptRelease fields
FieldDescription
attempt_idstring (uuid) required
run_idstring (uuid) requiredThe attempt's run, retried under its normal budget (a cancelled run stays cancelled).