Guides
Idempotency
Networks fail. An idempotency key lets you retry a send without ever messaging a customer twice.
The Idempotency-Key header
Every POST /messages requires an Idempotency-Key header of 16 to 128 characters. Use one stable key per logical message, for example the record that triggered it plus the event name.
Idempotency-Key: invoice-1042-sent-v1What Inbobo does
| Situation | Result |
|---|---|
| First request with this key | The message is created and queued. 202. |
| Same key, same channel, recipient and message | The original result is returned. Nothing is sent again. 202. |
| Same key, different channel, recipient or message | 409 IDEMPOTENCY_MISMATCH. Nothing is sent. |
| Same key used by a different consumer | Independent. Keys are scoped to your consumer. |
Retrying safely
- If a request times out or the connection drops, you do not know whether it was accepted. Retry with the same key.
- Never generate a fresh key for a retry. That is the one thing that can cause a duplicate.
- Only
channel_id,toandmessageare compared.purpose,consent_reference,attributionandcorrelationmay differ between retries. - Errors are not remembered. A request rejected with
400or422(includingWINDOW_CLOSED) creates nothing, so you can send a corrected request, for example a template, with the same key.