# Retry requests safely with idempotency keys

Supply a unique UUID in `X-Idempotency-Key` to identify a write request and its identical retries.
The header is **optional**: without it, the server processes each request independently, with
no deduplication or replay. Use it for POST operations that create side effects.

Provide optional `X-Idempotency-Key` on POST writes for safe retries:

- Success → the server caches the response for replay.
- In-flight duplicate → 409 (retry later).
- Mismatch → 422.
- Failure → entry removed; verify the resource state before retrying an uncertain outcome.
- The server replays only successful responses.


Idempotency does not guarantee that an error rolls back every side effect. After a timeout or
server error, check the resource's status or list recent resources before deciding whether to
retry. Reuse the key for an identical retry; generate a new key for a new operation.

### With and without the header

With `X-Idempotency-Key`:

- First request claims and (if successful) caches response.
- Concurrent duplicates while in flight receive 409 + `Retry-After: 1`.
- Later identical retries get the cached 2xx response.
- Different payload/path/method using same key → 422 mismatch.


Without the header:

- Filter bypasses idempotency entirely.
- Each call executes independently; duplicates may create repeated side effects.