Skip to main content
A network failure after a send leaves you not knowing whether the message was created. Resending carelessly can deliver two messages to the same customer, which is the worst kind of bug in messaging. The Idempotency-Key header solves this: Routa guarantees that the same key produces at most one message.

Where it applies

The other write endpoints are designed to be safe to repeat (disable and enable, for example), but they do not use the header. If you need to avoid retries in those cases, set maxRetries: 0 in the SDK.

How to use it

Generate a unique key per logical message (a UUID v4, for example) before the first attempt, and send the same key on every retry.
Derive the key from a stable ID in your domain (such as the order ID and the kind of notice). That way, even reprocessing your own job does not duplicate the message.

What happens in each case

In the SDK, when the call returns the result of an earlier attempt, message._replayed is true.

Scope and lifetime

  • The key is valid within the project, for this operation. Keys of different projects never collide.
  • The record is kept for 24 hours. After that, repeating the key runs the operation again. The window is for retries, not for permanent deduplication.
  • The body comparison ignores key order and whitespace in the JSON.
Do not reuse one Idempotency-Key for different messages. One key per logical message, always.

Limits of the guarantee

Idempotency protects the API boundary: an accepted request produces exactly one message in Routa. In the next step, between Routa and WhatsApp, a failure with an unknown outcome (such as a timeout) is handled with a deterministic reference sent to the provider for deduplication, and with a reconciliation query before any new attempt. Even so, exactly once delivery does not exist against a third-party API: the documented guarantee is at least once, and Routa makes duplicates rare, not impossible. See Delivery guarantees.