Skip to main content
Network timeouts, client crashes, and rate-limit retries can leave you unsure whether a write request actually completed. Retrying blindly risks creating duplicate clients, transactions, alerts, or cases. Idempotency keys let you retry the same write request safely: Corsa processes it once and replays the original response on any retry within the retention window. The feature is fully backward compatible. Requests without an idempotency key behave exactly as they do today.
Idempotency keys are distinct from referenceId. See Idempotency keys vs. referenceId below.

How It Works

Send an Idempotency-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.
  1. First request with a new key is processed normally, and its result is stored.
  2. A retry with the same key and the same request replays the stored response — with no duplicate side effects — and includes the Idempotent-Replayed: true response header.
  3. 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.
A single client-wide header sends the same key on every request. That is only correct when the client issues one write. For most integrations, set the Idempotency-Key per request so each operation gets its own key.

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:
Check for 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 returns 409 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 Conflict with 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.

Error Reference