A request times out. Did it land? Without an answer to that, you either retry and risk calling somebody twice, or you do not retry and risk never calling them at all.
Idempotency-Key removes the question.
curl -X POST https://app.talkturo.com/api/v1/campaigns \
-H "Authorization: Bearer $TALKTURO_KEY" \
-H "Idempotency-Key: 6f8b1c3e-7a2d-4f1b-9c44-2b7e5d0a1f93" \
-H "Content-Type: application/json" \
-d '{ "assistant_id": "…", "name": "Herbst-Kampagne", "from_number_ids": ["…"] }'
Send that again with the same key and the same body and you get the first answer again, with:
Idempotent-Replayed: true
No second campaign. No second call. No second contact.
The rules
- Required on every POST that changes something. Without one you get
400idempotency_key_required. - 1–100 characters of letters, digits or
: _ . -. A UUID is ideal. - One key per attempt, not per retry. Generate it when you build the request and reuse it for every retry of that request.
- Same key, different body →
409idempotency_key_reused. This is a guard, not an inconvenience: it means a bug in your code is reusing a key for something else, and we would rather say so than quietly give you the wrong answer. - Kept for 24 hours, per workspace.
"Same body" means the bytes we received. If you re-serialise your JSON and the keys come out in another order, that is a different body and you will be told so, rather than quietly handed the old answer.
Two requests at the same moment
If two arrive together with one key, one does the work and the other waits for its answer. They do not both run. You get one campaign and two identical responses.
What happens on a failure
- A 5xx releases the key. Something broke on our side, nothing was recorded, and you can retry with the same key.
- A 4xx is a real answer and is replayed. If you sent an invalid body, the same key gives you that same
400again — fix the body and use a new key.
PATCH and DELETE need no key
Sending the same PATCH twice leaves the same settings. Deleting the same thing twice leaves it deleted. They are already idempotent, so asking for a key would be ceremony that buys nothing. Send one anyway and it is accepted and ignored.
Three endpoints where it is optional
POST /v1/calls, POST /v1/messages and POST /v1/plans/{id}/ready shipped before this was standard. The first two check the header themselves and still refuse without it. POST /v1/plans/{id}/ready honours a key when you send one but will not demand it — we are not about to start failing requests for customers who never sent one.