Why idempotency
Network retries or client restarts can cause duplicate message requests. Use anIdempotency-Key
header to ensure only one message is created.
How it works
- Send a unique key per logical message attempt
- If the same key is received again, the original message is returned with 200
- New unique keys create a new message and return 202
Example
Best practices
- Use a collision-resistant identifier (UUID v4)
- Scope keys to your business action (e.g., order id)
- Expire keys on the client side to avoid unbounded storage