Every request that creates, changes or deletes something carries an Idempotency-Key header. If the answer is lost, send the same request again with the same key: the API returns the first answer and does nothing twice. A write without a key is refused with idempotency_key_missing. Reads need none.
The rules
- Use a new key for each request. A random UUID is a good key. A key you used for a charge can't be used again for its capture or its refund.
- Send the same key only to repeat the same request, after a lost answer or a
5xx. - Same key, same request: you get the saved answer, marked as a replay in your request logs. No second effect.
- Same key, different request: refused with
idempotency_key_reused, with no effect. - The first request is still running: the repeat is refused with
409and aRetry-After. Wait, then repeat it.
How long a key lasts
A key is kept for 7 days from the moment its outcome is known. A payment, a capture or a refund keeps its key for as long as it exists: a late repeat returns the record as it stands now, and can never take money twice.
What isn't saved
A request refused before anything happened, for a bad field, a missing permission, a rate limit or a key refusal, isn't saved. Fix it and send it again: the key is still free.
Telemetry events
A telemetry event uses its own identifier instead: the same identifier is never counted twice in a day, and is kept until its month closes.