# API Error Codes Reference
URL: https://emailforagents.ai/docs/errors
Summary: Every error code the Email for Agents API returns, with its HTTP status, the exact condition in the implementation that triggers it, and the concrete fix for each one.

## Errors

Every code the API and MCP server return, what it means, and how to fix it. Only three are worth retrying.

### 400 Bad request

- [invalid_request: The body or a parameter failed validation](https://emailforagents.ai/docs/errors/invalid_request)
- [invalid_cursor: The cursor is malformed or from a different query](https://emailforagents.ai/docs/errors/invalid_cursor)

### 401 Unauthenticated

- [unauthenticated: No key, or one that doesn’t resolve](https://emailforagents.ai/docs/errors/unauthenticated)

### 402 Plan

- [payment_required: This needs a plan the workspace doesn’t have](https://emailforagents.ai/docs/errors/payment_required)
- [quota_exceeded: This month’s allowance or another limit is used up](https://emailforagents.ai/docs/errors/quota_exceeded)

### 403 Not allowed

- [permission_denied: The key is real, but its access doesn’t cover this](https://emailforagents.ai/docs/errors/permission_denied)
- [policy_denied: A sending rule refused the send](https://emailforagents.ai/docs/errors/policy_denied)
- [test_mode_required: A simulation was called against live resources](https://emailforagents.ai/docs/errors/test_mode_required)
- [test_limit_exceeded: A test-mode limit would be passed](https://emailforagents.ai/docs/errors/test_limit_exceeded)

### 404 Not found

- [not_found: It doesn’t exist, or it’s outside this key’s reach](https://emailforagents.ai/docs/errors/not_found)

### 409 Conflict

- [idempotency_conflict: An Idempotency-Key was reused with a different body](https://emailforagents.ai/docs/errors/idempotency_conflict)
- [idempotency_expired: The key matches, but its 30-day window has closed](https://emailforagents.ai/docs/errors/idempotency_expired)
- [address_unavailable: The address or domain is already taken](https://emailforagents.ai/docs/errors/address_unavailable)
- [last_owner_required: A workspace can’t be left without an owner](https://emailforagents.ai/docs/errors/last_owner_required)

### 410 Gone

- [cursor_expired: The cursor points before the oldest kept event](https://emailforagents.ai/docs/errors/cursor_expired)

### 412 Changed

- [version_conflict: It changed since you read it](https://emailforagents.ai/docs/errors/version_conflict)

### 413 Too large

- [payload_too_large: A body, upload or attachment is over its limit](https://emailforagents.ai/docs/errors/payload_too_large)

### 422 Not ready

- [recipient_suppressed: A recipient is on the suppression list](https://emailforagents.ai/docs/errors/recipient_suppressed)
- [domain_not_ready: The domain hasn’t finished verifying](https://emailforagents.ai/docs/errors/domain_not_ready)
- [attachment_not_ready: The file hasn’t passed a scan, or failed one](https://emailforagents.ai/docs/errors/attachment_not_ready)
- [test_mode_unsupported: This doesn’t exist in test mode](https://emailforagents.ai/docs/errors/test_mode_unsupported)
- [reserved_address: That name is reserved on the platform domain](https://emailforagents.ai/docs/errors/reserved_address)
- [environment_immutable: A project can’t switch between live and test](https://emailforagents.ai/docs/errors/environment_immutable)

### 429 Slow down

- [rate_limited: Too many requests, or too many of one kind. Retry with backoff](https://emailforagents.ai/docs/errors/rate_limited)

### 503 Unavailable

- [provider_unavailable: The mail provider couldn’t be reached. Retry with backoff](https://emailforagents.ai/docs/errors/provider_unavailable)
- [temporarily_unavailable: The service, or something it needs, is down. Retry with backoff](https://emailforagents.ai/docs/errors/temporarily_unavailable)

### The error body

Errors from the REST API come back in this shape. The status comes from the code, so a code
always carries the same status.

403 Forbidden

```
{
  "error": {
    "code": "permission_denied",
    "message": "This credential cannot perform that action.",
    "request_id": "req_8Kd2x91",
    "retryable": false,
    "details": {}
  }
}
```

- Branch on `code`, not `message`. The code is a stable value; the
message is written for a person reading a log.
- Quote `request_id`, or the `x-request-id` response header, when you
ask about one request.
- `retryable` can be true only for [rate_limited](https://emailforagents.ai/docs/errors/rate_limited), [provider_unavailable](https://emailforagents.ai/docs/errors/provider_unavailable) and [temporarily_unavailable](https://emailforagents.ai/docs/errors/temporarily_unavailable). Anything else needs something to change first: the request, the account or the
resource.
- `details` adds context on some codes, such as `fields` on
[invalid_request](https://emailforagents.ai/docs/errors/invalid_request) and
`reason_codes` on [policy_denied](https://emailforagents.ai/docs/errors/policy_denied).
It is an empty object when there is none.

### Over MCP

The MCP server sits behind OAuth. A request without a valid access token is refused by the
OAuth layer with a 401 and `WWW-Authenticate`; an unknown or expired token also
gets an `invalid_token` body. Past that, the server answers with the body above
when it refuses a call itself, such as a rate limit or a tool the connection can’t use. When
a tool runs and fails, its result is marked `isError: true` and carries only a
message, as text.

### Codes with no page

The contract declares three more codes that nothing returns: `daily_limit_exceeded`,
`source_unavailable` and `send_already_submitting`. The daily recipient
limit is real; it answers [policy_denied](https://emailforagents.ai/docs/errors/policy_denied).
