How it works
- Include an
idempotency_keyin your send request - Sendmux stores the key with the resulting
message_idfor 24 hours - If the same key is sent again within 24 hours, the original
message_idis returned without re-queuing the email
Usage
Idempotent replay response
When a duplicate key is detected, the response includes"idempotent": true:
Key format
- Allowed characters: alphanumeric, hyphens, underscores (
a-zA-Z0-9_-) - Length: 1–255 characters
- Scope: Keys are scoped to your team — different teams can use the same key without conflict
Best practices
- Use meaningful keys tied to your business logic:
order-confirm-{orderId},welcome-{userId},invoice-{invoiceId}-{month} - Don’t use random values (like UUIDs) as idempotency keys — the whole point is to deduplicate, so the key must be deterministic
- Keys expire after 24 hours — after expiry, the same key can be used again and will queue a new message
Concurrent requests
If two requests with the same idempotency key arrive simultaneously, the first claims the key and begins processing. The second receives a 409idempotency_conflict error. This is transient — retry after a short delay to receive the completed result with "idempotent": true.
If the first request fails (validation error, insufficient credits, etc.), the key is released so subsequent retries can succeed immediately.
Batch sends
Each message in a batch can have its ownidempotency_key. Messages with previously-seen keys are returned as idempotent replays in the results array while new messages are queued normally.
Limitations
- Idempotency is best-effort — if the key store (Redis) is temporarily unavailable, the email will be queued normally without idempotency protection
- Keys are scoped to
(team_id, key)— the same key from different API keys on the same team will still deduplicate