How idempotency works
Idempotency is opt-in. To enable it, include anIdempotency-Key header on a write request:
Example
Idempotency-Key header are not deduplicated. Each one is processed independently.
Idempotency applies to write operations (
POST and DELETE). Read operations (GET) are already safe to retry, so they ignore the header. When a stored response is replayed, the API includes an Idempotency-Replayed: true response header so you can tell a replay apart from a freshly executed request.Creating an idempotency key
The key is a string that uniquely identifies a single logical operation. It must meet these requirements:| Requirement | Value |
|---|---|
| Length | 16–128 characters |
| Allowed characters | Letters, digits, ., _, - |
| Case | Case-sensitive (ABC and abc are different keys) |
| Scope | Unique per operation, per client |
Idempotency-Key header. If the request fails and you retry, recompute the key from the same order and payload, and the API recognises it as the same operation.
How repeated requests are handled
| Situation | Result |
|---|---|
| New key | The request is processed normally and the response is stored. |
| Same key, same payload, original finished | The stored response (status code and body) is returned without re-executing the operation. The response includes the header Idempotency-Replayed: true. |
| Same key, different payload | 422 Unprocessable Entity. The key is already associated with a different request. |
| Same key, original still in progress | 409 Conflict with a Retry-After header indicating how many seconds to wait before retrying. |
A request that fails validation is not stored against the key. You can correct the payload and retry with the same key.
Conflicts and errors
If you receive a409 Conflict, the original request is still being processed. Wait for the number of seconds given in the Retry-After response header, then retry with the same key:
Example response
422 Unprocessable Entity means the key has already been used for a request with a different payload which is considered wrong. Either reuse the original payload, or generate a new key for the new operation.