# Limits & errors

Rate limits, sizes and every error the email API returns, with what to do about each.

> **Early access: the API may change.** Limits on this page can still change before general availability, and limits for an account can be raised on request.

## Rate limit {#rate-limit}

Each account can make **20 requests per second** across the email API by default. Every response carries the current state:

| Header | Meaning |
|---|---|
| `ratelimit-limit` | Requests allowed per second. |
| `ratelimit-remaining` | Requests left in the current second. |
| `ratelimit-reset` | Seconds until the window resets. |
| `retry-after` | On a `429`, how many seconds to wait before retrying. |

Over the limit, requests get `429` with `rate_limit_exceeded`. Wait for `retry-after`, then retry with the same `Idempotency-Key`. To send many emails at once, use a [batch](https://oncharge.io/docs/messaging/sending#batches) of up to 1,000 rather than one request per email. If you need more, ask support.

## Sizes and counts {#sizes}

| Limit | Value |
|---|---|
| Recipients per email | 50 in total across `to`, `cc` and `bcc` |
| Email size | 40 MB, attachments included, after encoding |
| Emails per batch | 1,000 (no attachments, no `scheduled_at`) |
| Scheduling | Up to 30 days ahead |
| `Idempotency-Key` | Up to 256 characters, kept 24 hours |
| Tag names and values | ASCII letters, numbers, `_` and `-`, up to 256 characters |
| List page size | 1 to 100 (default 20) |
| Email log | 90 days |
| Free allowance | 3,000 emails a month, with no daily cap. Prices: [Email & SMS pricing](/pricing#messaging). |

## Errors {#errors}

Every error has the same shape:

```json
{
  "error": {
    "type": "validation_error",
    "message": "to: at most 50 recipients in total across to, cc and bcc.",
    "param": "to"
  }
}
```

- `type` is one of the values below. Branch on it rather than on the HTTP status.
- `message` is meant for people: log it, but don't parse it.
- `param` names the field at fault, when there is one.

## Error types {#error-types}

| `type` | Usual status | What happened | What to do |
|---|---|---|---|
| `validation_error` | `400` or `422` | A field is missing, malformed or over a limit. | Fix the request; `param` says which field. Don't retry unchanged. |
| `authentication_error` | `401` | The API key is missing, wrong or revoked, or a signed request's signature failed. | Check the `Authorization` header and the key. |
| `permission_error` | `403` | The key can't do this: a `sending` key calling another endpoint, or a key limited to another domain. | Use a key with the right scope. |
| `not_found` | `404` | No such email, domain, template or other object in your account. | Check the id. |
| `idempotency_conflict` | `409` | The `Idempotency-Key` was used in the last 24 hours with a different body. | Use a new key for a different email. |
| `domain_not_verified` | `403` or `422` | The `from` domain is not verified, or not yet. | [Verify the domain](https://oncharge.io/docs/messaging/domains#verify). |
| `recipient_suppressed` | `422` | The address is on your suppression list after a bounce, complaint or unsubscribe. | Don't retry. See [Suppressions](https://oncharge.io/docs/messaging/sending#suppressions). |
| `content_blocked` | `422` | OnCharge's compliance check refused the content for your store's category. The message says which rule. | Change the content. If you think the check is wrong, contact support. |
| `rate_limit_exceeded` | `429` | Too many requests per second. | Wait for `retry-after`, then retry. |
| `daily_quota_exceeded` | `429` | The account has reached its sending quota for the day. | Retry later, or ask support about your quota. |
| `internal_error` | `500` | Something failed on OnCharge's side. | Retry with the same `Idempotency-Key` after a short wait. |

Retry only `rate_limit_exceeded`, `internal_error` and network failures, with a growing wait between tries and the same `Idempotency-Key` each time, so a retry never sends twice.

## The compliance check {#compliance}

Every email, from the API, SMTP or a marketing flow, is checked before it is sent: against the rules for your store's category, and for claims no store may make, such as promises to cure or treat. Transactional and marketing mail each have their own rules, and the check also looks for promotional wording slipped into transactional mail. When an email is refused, `content_blocked` tells you which rule applied.
