Idempotency keys are distinct from
referenceId. See Idempotency keys vs. referenceId below.How It Works
Send anIdempotency-Key request header on a write request. Corsa scopes the key to your platform and the specific request, so one customer’s key can never affect another, and the same key used for a different request is rejected.
- First request with a new key is processed normally, and its result is stored.
- A retry with the same key and the same request replays the stored response — with no duplicate side effects — and includes the
Idempotent-Replayed: trueresponse header. - A retry after a server error (
5xx) is not replayed; Corsa attempts to process the request again.
Idempotency keys are currently supported on resource-creating
POST requests. Sending the header on other verbs is accepted but has no effect.Sending an Idempotency Key
Generate a unique string per intended write operation — a UUID (v4) is recommended — and reuse that same value on every retry of that operation.Key Requirements
Recognizing a Replayed Response
When Corsa replays a stored response, the body and status code are identical to the original, and the response carries an extra header:Idempotent-Replayed: true when you need to distinguish a fresh write from a replayed one — for example, when reconciling logs after a retry storm.
Handling Conflicts
A reused key that does not match the original completed request returns409 Conflict. There are two cases:
Retry After a Timeout
The core use case: your request times out and you do not know whether it succeeded. Retry with the same key.- If the first request completed, you get the original response back with
Idempotent-Replayed: true— no duplicate created. - If the first request is still processing, you get
409 Conflictwith an in-progress message; wait and retry with the same key. - If the first request failed with a
5xx, the retry is processed as a new attempt.
Retention and Expiry
After 24 hours, Corsa may treat the same key as a brand-new request. If you need retry safety beyond that window, generate a fresh key and treat the operation as new.
Idempotency Keys vs. referenceId
These solve different problems and are often used together.
Use an
Idempotency-Key to make a retry safe. Use referenceId to map a Corsa entity back to a record in your system. During imports and backfills, set both: referenceId identifies the entity, and a per-row Idempotency-Key makes each write retry-safe.