Skip to content

Idempotency

A program that did not receive the response to a POST — the network dropped — cannot know whether the job started. With an Idempotency-Key it can retry safely: the second request receives the response of the first instead of creating a second object.

POST /v1/jobs
Authorization: Bearer vc_…
Idempotency-Key: 6f1c2a9e-order-4411
Content-Type: application/json

Rules

Errors

StatusCodeMeaning
400idempotency_key_invalidThe key is empty, too long, or not printable ASCII.
409idempotency_in_progressThe first request with this key is still running. Retry shortly.
422idempotency_key_reusedThe key was already used for a different request (another body or another address). Repeating is not changing one's mind: use a new key.

A retry loop

1. Choose the key before the first attempt, and keep it for every retry of the same operation. 2. On a network failure, a 500 or a 409 idempotency_in_progress, wait and send the same request again with the same key. 3. On any other response, stop: that is the answer.