Retries and errors
Networks fail. Send an idempotency key with every email, and a retry never sends it twice. To learn how PostHog queues, retries, and delivers each send, see how PostHog delivers messages reliably.
Idempotency keys
Build the key from the record that caused the email, and send the same key on every retry. A random value or a timestamp makes each retry look like a new email.
| Key | |
|---|---|
| Password reset | password-reset-{reset_request_id} |
| Sign-in code | sign-in-code-{code_id} |
| Team invite | invite-{invite_id} |
| Receipt | receipt-{order_id} |
Send it as the Idempotency-Key header, or idempotencyKey in the SDKs. A key is 1 to 255 visible ASCII characters, is kept for 7 days, and is separate for each project.
- Same key, same request: nothing new sends. You get the first send's message ID, with
"replayed": true. - Same key, different request:
422 idempotency_key_reused. Use a new key for a new email. - First request still running:
409 idempotency_key_in_flight. Wait a few seconds and retry. - Refused request: the key stays unused, so you can send it again later.
- Lost response: look up the email by its key to see if PostHog queued it, or send it again with the same key.
What to retry
The SDKs retry the codes marked Yes for you, up to two times, with the same idempotency key. Use code in your own error handling. The detail text can change.
| Status | code | Retry? | What to do |
|---|---|---|---|
409 | idempotency_key_in_flight | Yes | Retry with the same key after a few seconds. |
429 | throttled | Yes | Wait for the time in the Retry-After header. |
503 | delivery_unavailable | Yes | Retry with backoff and the same key. PostHog might have queued the email. Don't resend through another email provider, or the recipient can get two copies. |
network_error (SDKs) | Yes | Same as a 503. | |
400 | A field code, such as required or invalid | No | Fix the field that attr names. |
400 | invalid_idempotency_key | No | Send 1 to 255 visible ASCII characters. |
400 | sandbox_fields_unsupported | No | Your project has no verified domain, so the test sender can't send cc, bcc, attachments, reply headers, or a marketing category. Remove them, or verify a domain. |
400 | template_not_transactional | No | Make it transactional. |
400 | template_not_sendable | No | Add a subject and body, and publish. |
400 | marketing_template | No | Remove its marketing category. |
400 | transactional_email_paused | No | The email's workflow is turned off. Turn it back on. |
401 | authentication_failed or not_authenticated | No | Send a valid project secret API key. |
403 | permission_denied | No | Use a key from this project with the transactional_email:write scope. |
404 | not_found | No | Check the template ID and project. |
422 | idempotency_key_reused | No | Use a new key. |
422 | recipient_suppressed | No | The address hard bounced, or was suppressed through the API with reason bounce. See the suppression list. |
422 | recipient_unreachable | No | The address or its domain can't receive email. Check for a typo. |
422 | sending_paused | No | Too many bounces or complaints on this email. Check the Reputation tab. |
422 | sending_suspended | No | Sending is suspended for your project. Check the Reputation tab. |
422 | sandbox_recipient_not_member | No | Your project has no verified domain, so the test sender only sends to members of your organization. Verify a domain. |
429 | quota_limited | No | Your project is over its email quota. Check billing limits. |
The SDKs also check some fields before they call PostHog, and return an invalid_* code, such as invalid_recipient, when one is wrong. Send emails from code and attachments have their own checks.
Rate limits
A project can send 600 emails a minute and 20,000 an hour, and all its keys share these limits. The limits rise with the project's sending tier, to about 1% of its daily allowance a minute and 10% an hour at the top tiers. Status lookups have their own limits, so they don't use up the limits for sends. See API and SDK limits for every limit on a send.





