Idempotency Keys
Network errors, timeouts, and worker restarts can leave your code unsure whether aPOST /email request actually went through. Sending an Idempotency-Key header lets you retry safely: a repeat with the same key and body replays the original response instead of sending a duplicate email.
How it works
- Generate a unique key on your side (e.g. a UUID v4) for each logical send.
- Pass it in the
Idempotency-KeyHTTP header onPOST /email. - If the request is retried with the same key and same body, JetEmail returns the original response and does not send a second email.
- If the same key is reused with a different body, the request is rejected with
409 Conflict.
Header reference
Keys are scoped to your account. Pick something globally unique per send (UUID v4 is a safe default).
Example request
Idempotency-Key and body will return the original 201 Created (or 202 Accepted for scheduled sends) without triggering another delivery.
Conflict responses
A409 Conflict indicates one of two situations:
If you legitimately need to send a different message, generate a new
Idempotency-Key.
Best practices
- Generate the key before the first attempt, not on retry, so retries can reuse it.
- Persist the key alongside the work item that triggered the send (e.g. order ID, job row) so the same retry path always reaches for the same key.
- One key per logical send. Do not reuse the same key for unrelated emails.
- Pair with scheduled sends when the call that schedules an email may itself be retried.