Idempotency
Network failures happen. To safely retry a POST /emails request without risking a duplicate send, supply an Idempotency-Key header:
POST /emailsAuthorization: Bearer am_YOUR_KEYIdempotency-Key: order-12345-receiptContent-Type: application/jsonThe key can be any string up to 256 chars. Most callers use a UUID or a stable business identifier (order-{id}-receipt).
Behavior
Section titled “Behavior”- First request with the key: processed normally, response cached for 24h.
- Retry with the same key + same body: returns the cached response (same
id, samestatus, same timestamp). No new email is queued. - Retry with the same key + different body: returns
409 Conflictto surface the inconsistency.
When to use it
Section titled “When to use it”- Webhook handlers in your app — retry-on-error is common.
- Cron jobs that may overlap.
- Anywhere a transient network error could cause a retry loop.
When not to bother
Section titled “When not to bother”- One-off sends triggered by user actions where duplicate-prevention is not load-bearing.
- Campaign sends — the campaign dispatcher handles dedupe internally.
Window
Section titled “Window”Keys are remembered for 24 hours from the first request. After that, the same key can be reused without conflict.