Idempotency
A network timeout tells you nothing about whether the server acted. Send an Idempotency-Key on every write and that ambiguity disappears: retry the exact same request and you get the original outcome back, not a second contact, order or message.
Using it
curl -X POST https://api.onivos.com/contacts \
-H "Authorization: Bearer onv_live_xxxxxxxx" \
-H "Idempotency-Key: 8f14e45f-ea7f-4b3d-9a26-1c2b7a0d5f31" \
-H "Content-Type: application/json" \
-d '{ "display_name": "Jane Cooper" }'Retry the same call with the same key and the response is byte-identical, plus one header:
Idempotency-Replayed: true| Rule | Detail |
|---|---|
| Applies to | POST, PUT, PATCH, DELETE from an API key. |
| Ignored for | GET / HEAD, and for session (browser) traffic. |
| Key format | Any string you choose, up to 200 characters. Use a UUID, or your own operation id. |
| Scope | Per organization and per key — the same key value used by two different API keys is two different operations. |
| Retention | 24 hours from the first request. After that the key is forgotten and a replay executes for real. |
What gets replayed
- Success — the stored status and body come back verbatim.
- A deterministic client error (
4xx) is stored too: a request that failed validation will fail identically on retry rather than getting a second chance to half-succeed. - A server error (
5xx) is never stored. Those are exactly the ones you want to actually retry.
Concurrent duplicates
If a second request arrives with the same key while the first is still running:
{
"error": {
"code": "idempotency_conflict",
"message": "A request with this Idempotency-Key is still in progress"
}
}with status 409. Wait a moment and retry — by then the first has finished and you get its result.
Choosing keys
- One key per logical operation, generated by you, before the first attempt — a key minted at retry time protects nothing.
- Derive it from your own data when you can:
order-4471-chargeis better than a random UUID you did not persist, because a process that crashed and restarted can reconstruct it. - Never reuse a key for a different payload. The response of the first request is what comes back; the second body is not inspected and not applied.
Idempotency is not a lock
It guarantees that this exact operation runs once. It does not stop a different request from changing the same resource in between. Where an endpoint needs stricter ordering, it carries its own conflict rules — those return 409 CONFLICT.
Endpoints with built-in deduplication
Some writes are naturally idempotent and need no header at all — for example creating a commerce order with a clientRef, or a cart checkout with a client_ref. Sending the same reference twice returns the same order. Where that applies it is called out on the endpoint's reference page; Idempotency-Key still works alongside it.