Idempotency-Key header on send, and retries within 24 hours
replay the original response instead of enqueuing a duplicate. Safe even
when your producer code doesn’t know whether the previous request succeeded.
Usage
Response on replay
If a message with this key was sent in the last 24 hours, the server returns the ORIGINAL message’s 201 response AND sets a headerIdempotency-Replay: true. Status is 200, not 201.
msg_abc123 exactly once.
Key choice
- Use a deterministic key derived from business data:
order-9001-attempt-1, not a random UUID per call. - Keys are scoped per tenant. Two different API keys on the same tenant SHARE the idempotency cache.
- All SDKs auto-generate a UUIDv4 if you omit the option. That’s fine if
you call
sendexactly once per logical event, but defeats the purpose if the caller retries the whole function.
Outbox pattern
vs dedupe_id
Different scope: Idempotency-Key = producer retry safety (“this is the same request”). dedupe_id = SQS-style message dedup within afifo_group (“the same business event”). See FIFO + dedup.