Skip to Content
Notification APIDocs

Idempotency

Retry send requests safely without sending a message twice.

Networks fail: a send request can time out after the API has already accepted it. To retry safely, give each message an idempotencyKey, a string of up to 128 characters that is unique for that message in your system (an order id, an event id, a UUID you store).

{
  "channel": "email",
  "recipients": [{ "type": "Email", "value": "jane@example.com" }],
  "templateId": "0197a5f0-2b1c-7e44-8a55-1c2d3e4f5a6b",
  "variables": { "orderId": "1042" },
  "idempotencyKey": "order-1042-shipped"
}

How it works

  • The key is unique per project.
  • If a message with the same key already exists, the API does not create a new one: it answers 202 Accepted with the existing message in its current state (which may already be Completed).
  • The request body is not compared. A different body with an already used key still returns the original message, so never reuse a key for a different message.
  • Keys are checked after request validation: an invalid request answers 400 whatever its key.
  • You can find a message by its key with search on List messages (exact match).
  1. Generate the key once, before the first attempt, and store it with your own record.
  2. On a timeout, a network error or a 5xx response, retry with the same key, with exponential backoff.
  3. Do not send the same new key from several threads at the same time; send it once and retry only after a failure.
  4. Do not retry 4xx responses (except 429, see Rate limits) without changing the request.

Messages sent without a key are never de-duplicated: each request creates a new message.

On this page