Idempotency keys
Send Idempotency-Key: <unique string> on a create or deploy request and a
retry of it returns the first response instead of running again. Use one new key
per intended action (a UUID works); reuse it only to retry that same action.
Routes that honour the header:
| Route | Action |
|---|---|
POST /apps | Create an app |
POST /apps/deploy-git | Deploy from a Git repository |
POST /apps/{app}/redeploy | Redeploy |
POST /apps/{app}/deploy-latest | Deploy the latest commit |
POST /databases | Create a database |
POST /databases/{id}/restore | Restore a backup into a new database |
POST /apps/upload is multipart and is not covered.
Behaviour
Keys are scoped to the credential that sent them (one API key, or one signed-in user) and kept for 24 hours. Two keys, even in the same org, never share a stored response, so a key with fewer scopes cannot replay what another key's request returned.
| Situation | Response |
|---|---|
| First request with the key | Runs normally. A 2xx response is stored. |
| Same key, same request, again | The stored response, with Idempotent-Replayed: true. Nothing runs. |
| Same key while the first is still running | 409 idempotency_in_progress, with Retry-After. |
| Same key, different method, path, query or body | 422 idempotency_key_reused. |
| First request failed (non-2xx) | Not stored. The key is released, so the same key can be retried. |
| Key longer than 255 characters or not printable ASCII | 400 invalid_request. |
| Body over 1 MiB | 413 payload_too_large. |
| The coordinator cannot reach the store that holds keys | 503 idempotency_unavailable, with Retry-After. Nothing runs. |
A request that carries a key but no valid credential is not recorded; it gets the usual authentication error.
Two things a stored response does not track. It is replayed for 24 hours even if the
app has been deleted since, so a replayed 201 or 202 is not proof the app still exists.
And the in-progress lock lasts 10 minutes, so a request still running after that can
be started a second time by a retry. A deploy sent with Prefer: respond-async
answers in seconds, so its lock is never near that limit (see below).
Deploys that answer before the build
POST /apps/deploy-git, POST /apps/{app}/redeploy, POST /apps/{app}/deploy-latest
and PUT /apps/{app}/branch build an image before anything runs, which can take
minutes. Send Prefer: respond-async and the request answers 202 once the deploy is
accepted, with status: "deploying", a deployment_id and Preference-Applied: respond-async. The build carries on without the client:
- Its outcome is on the deploy history (
GET /apps/{app}/deployments): the entry with thatdeployment_idbecomessucceededorfailed, with the builder's error. - A first deploy exists from the moment it is accepted, reading
deploying. If its build fails, the app readsdegradedwithstatus_reason: build_failed. - One build per app at a time. A second deploy while one is building answers
409. - A coordinator restart fails a build that was running, with
status_reason: build_interruptedon a first deploy. Deploy again.
Without the header these routes answer when the build is done, with the builder's
error as a 502 if it failed. POST /apps (a Docker image) builds nothing, so it
answers at once either way.
Retrying after a timeout
POST /apps/web/deploy-latest
Idempotency-Key: 6f1c... # times out, outcome unknown
POST /apps/web/deploy-latest
Idempotency-Key: 6f1c... # same key: replays the first deploy, or runs it once