# Errors

Every failure returns the same envelope. `code` is stable and meant for your
agent to branch on. `message` is for a human reading a log and may be reworded
without notice.

```json
{
  "error": {
    "code": "DOMAIN_NOT_VERIFIED",
    "message": "The sender domain \"example.com\" is not verified for this account"
  }
}
```

Some errors carry extra fields next to `code` and `message`. `COMPLIANCE_FAILED`
carries `details` with the SPF, DKIM and DMARC result. `INSUFFICIENT_CREDITS`
carries `balance` and `required_credits`.

Every failure answers five questions: what happened, where it stopped, whether a
retry is safe, which request it was and what to do next. [Reading a Send
Failure](/docs/concepts/error-language) explains each answer. The request ID is the
`x-request-id` response header. Quote it when you contact support.

Branch on `code`, not on the status. One status covers several causes, and the
status alone cannot tell you whether to fix the request, wait, or stop.

## Status meanings

| Status | Meaning |
|---|---|
| `400` | The request or the current resource state is wrong |
| `401` | No usable API key on the request |
| `402` | Credit balance is spent, in credit mode |
| `403` | Authenticated, but this is not allowed right now |
| `404` | No such resource on this account |
| `408` | A wait call timed out before the awaited message arrived |
| `409` | Conflicts with something that already exists or already happened |
| `410` | The endpoint is retired, or ownership must be proved first |
| `413` | Request body exceeds the HTTP ingress ceiling; inbound attachment limits are separate |
| `422` | The pre-send compliance check failed |
| `429` | A request rate or a sending volume limit was hit |
| `500` | Server fault on our side |
| `502` | An upstream provider rejected or failed the operation |
| `503` | A dependency or an operator switch makes the operation unavailable |

## Authentication and keys

| Code | Status | Meaning |
|---|---|---|
| `UNAUTHORIZED` | `401` | Missing key, unknown key, or revoked key |
| `OTP_INVALID` | `401` | The sign in code does not match |
| `OTP_EXPIRED_OR_NOT_FOUND` | `400` | The sign in code expired or was already used |
| `OWNERSHIP_VERIFICATION_REQUIRED` | `403` | The account has not proved it owns its email address. Sign in with the email code or an OAuth provider |
| `EMAIL_VERIFICATION_REQUIRED` | `410` | Sign in cannot continue until the address is verified |
| `INSUFFICIENT_PERMISSION` | `403` | The key lacks `read` or `write` for this method, or tried to mint a key with permissions it does not hold |
| `SCOPED_API_KEY_FORBIDDEN` | `403` | The key is scoped to one inbox and this route is outside it |
| `KEY_NOT_ACTIVE` | `400` | The key is not in an active state |
| `CANNOT_DELETE_ACTIVE_KEY` | `400` | Revoke the key before deleting it |
| `INVALID_EXPIRES_AT` | `400` | `expires_at` is not a usable future timestamp |
| `ACCOUNT_NOT_FOUND` | `400`, `404` | No account for that address |
| `ACCOUNT_EXISTS` | `409` | An account already uses that address |
| `OAUTH_PROVIDER_NOT_FOUND` | `404`, `302` | Unknown OAuth provider in the path |
| `OAUTH_PROVIDER_NOT_CONFIGURED` | `503` | That OAuth provider is not configured on this deployment |
| `PASSWORD_RESET_INVALID` | `400` | The reset link is wrong or already spent |
| `PASSWORD_RESET_RATE_LIMIT` | `429` | Too many reset requests for that address |

## Inboxes and domains

| Code | Status | Meaning |
|---|---|---|
| `INBOX_NOT_FOUND`, `NOT_FOUND` | `404` | No such inbox on this account |
| `INBOX_ALREADY_EXISTS` | `409` | That address already exists |
| `USERNAME_NOT_AVAILABLE` | `409` | The username is taken on that domain |
| `INBOX_USERNAME_RESERVED` | `409` | The username is reserved by the platform |
| `INVALID_USERNAME` | `400` | The username is not a valid local part |
| `INVALID_INBOX_UPDATE` | `400` | Nothing updatable in the body |
| `INBOX_INACTIVE` | `400` | The inbox is disabled, so it cannot send |
| `INBOX_LIMIT_REACHED`, `PLAN_LIMIT_REACHED` | `403` | The plan's inbox or domain count is spent |
| `SHARED_DOMAIN_INBOX_LIMIT` | `403` | The per account cap on shared domain inboxes is spent |
| `INVALID_DOMAIN` | `400` | The domain is not a usable domain name |
| `DOMAIN_EXISTS`, `DOMAIN_TAKEN` | `409` | The domain is already registered, here or on another account |
| `DOMAIN_IN_USE` | `409` | Inboxes still live on the domain |
| `DOMAIN_NOT_VERIFIED` | `400` | The sender domain has no verified record on this account |
| `CANNOT_DELETE_SANDBOX`, `CANNOT_CONNECT_SANDBOX` | `400` | The shared sandbox domain is not yours to delete or connect |
| `CLOUDFLARE_INVALID_TOKEN`, `CLOUDFLARE_ZONE_NOT_FOUND`, `ZONE_DOMAIN_MISMATCH`, `CLOUDFLARE_PROVISION_FAILED` | `400`, `409` | The Cloudflare connect flow could not provision DNS |
| `DOMAIN_REGISTRATION_FAILED` | `500` | Domain registration failed on our side |

## Sending

Read [Send Authorization](/docs/concepts/send-authorization) for the order these
run in. Codes below are the ones a send can return before anything leaves
mailbot.

| Code | Status | Meaning |
|---|---|---|
| `VALIDATION_ERROR` | `400` | The body does not match the send schema. At most 10 addresses per field, subject up to 998 characters, `body_text` required |
| `IDEMPOTENCY_KEY_REQUIRED` | `400` | Missing or malformed `Idempotency-Key` (8 to 255 characters) on a creating call made with an API key or MCP |
| `IDEMPOTENCY_CONFLICT`, `IDEMPOTENCY_IN_PROGRESS`, `IDEMPOTENCY_OUTCOME_UNKNOWN` | `409` | Key reused with a different payload (use a new key); first attempt still running (wait, then repeat the identical request); first attempt failed with a server error and the key is locked, so read the message back and use a new key only if it did not go out. A repeat of a finished request returns the first response again with no second send |
| `INVALID_SEND_AT` | `400` | `send_at` is not an ISO timestamp in the future |
| `OUTBOUND_POLICY_DENIED` | `403` | Nonempty outbound attachments are unavailable; `reason` is `attachment_review_required`. No message, debit, reservation or transport is created |
| `NO_REPLY_TARGET`, `THREAD_NOT_REPLYABLE` | `400` | The thread has no message to reply to |
| `FROM_INBOX_NOT_FOUND` | `404` | The `from` address matches no inbox you own |
| `MISSING_TARGET_URL` | `400` | A forward call arrived without a destination |
| `COMPLIANCE_FAILED` | `422` | SPF, DKIM or DMARC did not pass for the sending domain. `details` says which |
| `SUSPICIOUS_CONTENT` | `403` | Content screening flagged the message before send |
| `ATTACHMENT_SIZE_EXCEEDED`, `SCHEDULED_ATTACHMENTS_UNSUPPORTED` | `400`, `403` | Attachment limit codes. Outbound attachments are refused as a whole, so remove `attachments` instead of shrinking them |
| `INSUFFICIENT_CREDITS` | `402` | Credit mode is on and the balance is spent. `balance` and `required_credits` are included |
| `TRANSMISSION_FAILED` | `502` | The email provider did not confirm the handoff. The message is saved as failed and carries `message_id`. A rejection and a timeout both return this code today, so read the message back before sending again |
| `delivery_unavailable` | `503` | The delivery policy could not reach a verdict. The state of the send is unknown, so read the message back before retrying |
| lowercase delivery policy codes | `403` | The delivery policy refused the send. See the [full table](/docs/concepts/send-authorization#delivery-policy-codes) |

Omit outbound `attachments` or use `[]`. Nonempty arrays receive the early
policy denial above, including scheduled sends and replies. Non-array values
remain `400 VALIDATION_ERROR`; authentication, abuse and the body ceiling may
reject earlier. Link to files you host. Inbound limits and storage are separate.

## Volume and rate

| Code | Status | Meaning |
|---|---|---|
| `RATE_LIMIT_EXCEEDED` | `429` | Request rate for the key. Read the `X-RateLimit-*` headers |
| `RATE_LIMIT_UNAVAILABLE` | `503` | The rate limiter is unreachable. Sensitive routes such as sign in are refused rather than waved through |
| `DAILY_SEND_LIMIT_EXCEEDED` | `429` | The inbox's own daily send count is spent |
| `DAILY_SEND_LIMIT_REACHED` | `429` | The account's daily send count is spent |
| `MONTHLY_EMAIL_LIMIT_REACHED` | `429` | The plan's monthly outbound count is spent |
| `NEW_ACCOUNT_RATE_LIMIT` | `429` | A new account is capped at 10 outbound emails per rolling 24 hours for its first 7 days |
| `SHARED_DOMAIN_NEW_ACCOUNT_RATE_LIMIT` | `429` | A separate rolling 24 hour cap for new accounts sending on the shared domain. The message carries the number in force |
| `SHARED_DOMAIN_UNTRUSTED_RATE_LIMIT` | `429` | A rolling 24 hour cap for untrusted accounts sending on the shared domain. The message carries the number in force |
| `SANDBOX_BURST_LIMIT_EXCEEDED` | `429` | Too many sandbox sends in a short burst |
| `SPRAY_PATTERN_DETECTED` | `429` | The recipient pattern looks like spraying |
| `ACCOUNT_ABUSE_SUSPENDED`, `ACTION_UNAVAILABLE` | `403` | Abuse controls suspended the account. Billing stays reachable |
| `INBOX_DISABLED_BOUNCE_RATE` | `403` | The inbox was disabled because its bounce rate crossed the threshold |
| `INBOX_DISABLED_COMPLAINT_RATE` | `403` | The inbox was disabled because its complaint rate crossed the threshold |
| `OUTBOUND_SHARED_DOMAIN_PAUSED` | `503` | Shared domain sending is paused by the operator |
| `OUTBOUND_UNTRUSTED_ACCOUNTS_PAUSED` | `503` | Untrusted account sending is paused by the operator |

## Messages, threads and scheduling

| Code | Status | Meaning |
|---|---|---|
| `NOT_FOUND` | `404` | No such message or thread on this account |
| `FILE_NOT_FOUND` | `404` | No such attachment on that message |
| `INVALID_PARAMETER` | `400` | A query or path parameter is unusable |
| `MESSAGE_NOT_SCHEDULED` | `400`, `409` | The message is not in a scheduled state |
| `SCHEDULE_ALREADY_SENT` | `409` | The scheduled message already went out, so it cannot be cancelled or moved |
| `SCHEDULE_ENQUEUE_FAILED` | `503` | The message was saved but the scheduler could not queue it, so it will not go out on time. The error carries `message_id`. Reschedule that message; do not create a second one |
| `MESSAGE_WAIT_TIMEOUT` | `408` | No matching message arrived inside the wait window. This is a timeout, not a verdict |

## Webhooks and events

| Code | Status | Meaning |
|---|---|---|
| `INVALID_WEBHOOK_URL` | `400` | The URL is not usable or points at a blocked network |
| `WEBHOOK_REQUIRED` | `400` | The operation needs a subscribed webhook |
| `WEBHOOK_LIMIT_REACHED` | `403` | The plan's webhook count is spent |
| `UNSUPPORTED_EVENT` | `400` | Unknown event type in the request |
| `ALREADY_REPLAYED` | `409` | That event was already replayed |
| `REPLAY_FAILED` | `502` | The replay target rejected the delivery |
| `INVALID_UNSUBSCRIBE_TOKEN` | `400` | The unsubscribe token is wrong or expired |

## Billing and account

| Code | Status | Meaning |
|---|---|---|
| `INVALID_BILLING_REQUEST` | `400` | Unknown plan or interval |
| `PAYPAL_NOT_CONFIGURED`, `PAYPAL_PLAN_NOT_CONFIGURED` | `503` | Checkout is not configured for that plan on this deployment |
| `BILLING_SUBSCRIBE_FAILED` | `500` | Subscription creation failed |
| `WEBHOOK_RELIABILITY_INCLUDED` | `409` | Reliability is standard on every plan. New trial/subscription requests are rejected without a provider call |
| `ADDON_NOT_SUBSCRIBED` | `400` | A legacy billing cancellation has no existing subscription to cancel |
| `EMAIL_ALREADY_IN_USE` | `409` | Another account already uses that address |
| `EMAIL_UNCHANGED` | `400` | The requested address equals the current one |
| `EMAIL_CHANGE_CODE_INVALID` | `400` | The address change code is wrong or expired |
| `ACCOUNT_SELF_DELETE_DISABLED` | `403` | Self service deletion is off on this deployment |
| `INVALID_DELETE_REQUEST` | `400` | The deletion confirmation does not match |
| `ENDPOINT_DEPRECATED` | `410` | The endpoint is retired. The message names its replacement |

## Server and dependencies

| Code | Status | Meaning |
|---|---|---|
| `INTERNAL_ERROR` | `500` | Unhandled fault. A read can be repeated. After a send, read the message back before sending again |
| `COMPLIANCE_CHECK_FAILED`, `READINESS_CHECK_FAILED` | `500` | The compliance or readiness check could not complete |
| `IMPORTS_NOT_CONFIGURED` | `503` | Mailbox import is not configured on this deployment |
| `CONNECTION_INACTIVE` | `400` | The import connection is not active |

A `5xx` is never a verdict on your request. It says we could not decide. Read the
resource back before retrying anything that could send mail twice.
