How to use the Idempotency-Key header
Include an Idempotency-Key header in every POST /v1/messages request. The value is a string of your choosing — typically something that uniquely identifies the specific message you intend to send.
Idempotency-Key, RelayOS returns the original response — the same id, status, and queuedAt — without queuing a second message.
What happens on a duplicate request
When RelayOS receives aPOST /v1/messages request with a key it has seen before, it:
- Looks up the stored response for that key.
- Returns that response immediately with the same HTTP status code.
- Does not create, queue, or send another message.
id is the same and you can track the message status normally.
Best practices for key values
A good idempotency key is unique per intended message, not per API call. Combine identifiers that naturally describe what you are sending:| Scenario | Example key |
|---|---|
| Order confirmation | order-8821-confirmation |
| Appointment reminder | appointment-5503-reminder |
| Shipping update | shipment-TRK001-dispatched |
| Password reset | user-19-pwd-reset-20260514 |
When to use idempotency keys
Use anIdempotency-Key on:
- All retries — any time your HTTP client re-sends a request after a timeout or connection error.
- Automated triggers — background jobs, queued workers, or event-driven functions that may execute more than once due to at-least-once delivery semantics.
- Critical transactional messages — confirmations, receipts, or alerts where a duplicate would cause confusion or a compliance issue.
Even when you are confident a request succeeded, always include an idempotency key. The overhead is negligible and the protection it provides is significant in production environments with unreliable networks.