# Errors

A request that fails says so with an HTTP status and a code your program can branch on.

## The answer of a failed request

The status is `4xx` or `5xx`, and the body is one `error` object.

```json
{
  "error": {
    "type": "conflict_error",
    "code": "domain_taken",
    "message": "This workspace already has that domain.",
    "requestId": "req_5f2c81d09ab3"
  }
}
```

- `code` is what went wrong. Branch on it: it stays the same when the wording changes.
- `message` says it in words, for a person. A wrong input names the field.
- `type` is the family the code belongs to.
- `requestId` names the request. It is also in the `x-request-id` header.

## Kinds of errors

Every error is one of these kinds, and the kind decides the status. Where nothing more exact can be said, the kind is the code itself, as with `unauthorized`, `forbidden`, `not_found` and `validation_error`.

| Code | Status | Meaning |
| --- | --- | --- |
| `unauthorized` | 401 | No key was sent, or the key is wrong or was revoked. |
| `forbidden` | 403 | The key or the person is known but may not do this. |
| `not_found` | 404 | Nothing has that id in this workspace. |
| `validation_error` | 422 | The input is wrong. The message names the field. |
| `conflict` | 409 | The request cannot be done as things stand, for example because a name is taken. |
| `limit_reached` | 403 | The plan of the workspace does not allow more of this. |
| `unavailable` | 503 | A service the method needs is not connected, or it did not answer. |
| `internal_error` | 500 | Something failed on the server. The request id in the answer finds it in the logs. |
| `rate_limited` | 429 | Too much was asked in a short time. Try again later. |

## What to try again

- A `503` means a service behind the API did not answer, or is not connected. When the message says it is safe to try again, nothing was sent or charged.
- A `429` and `idempotency_busy` pass by themselves. Wait a little and repeat.
- A `422`, `403`, `404` or any other `409` will fail the same way again. Change the request first.
- When a send fails without an answer at all, repeat it with the same idempotency key. [Sending email](https://opensend.sh/docs/sending) explains how.

## Every code

These are the codes a method can answer with beyond the kinds above.

| Code | Status | Meaning |
| --- | --- | --- |
| `domain_invalid` | 422 | Give a domain name such as mail.example.com, without a protocol or a path. |
| `domain_taken` | 409 | This workspace already has that domain. |
| `domain_no_provider` | 409 | No sending provider is connected yet, so this domain has no records to check. |
| `email_no_body` | 422 | Give the email a text body, an HTML body, or both. |
| `email_domain_missing` | 422 | The from address must be on a domain this workspace has added and verified. |
| `audience_missing` | 422 | There is no audience with that id in this workspace. |
| `broadcast_sent` | 409 | This broadcast has already been sent. |
| `broadcast_past` | 422 | The time to send at must be in the future. |
| `alias_taken` | 409 | This workspace already has a template with that alias. |
| `webhook_url` | 422 | Give a public https address, such as https://example.com/hooks/mail. |
| `member_taken` | 409 | That person is already in this workspace. |
| `owner_stays` | 409 | The owner of a workspace cannot be removed. |
| `workspace_name` | 409 | Send the name of the workspace as confirm, exactly as it is written, to close it. |
| `workspace_paid` | 409 | This workspace is on a paid plan. Cancel the plan on the billing page, then close it. |
| `owner_role` | 409 | The owner keeps that role until ownership is handed over. |
| `domain_limit` | 403 | This workspace has every domain its plan allows. Remove one, or move to a larger plan. |
| `member_limit` | 403 | Every seat on this plan is taken. Remove someone, or move to a larger plan. |
| `automation_not_active` | 409 | Only an active automation can be paused. |
| `automation_active` | 409 | This automation is already active. |
| `body_invalid` | 422 | The body of the request is not valid JSON. |
| `range_invalid` | 422 | A custom range needs from and to as dates, such as 2026-11-01, with from on or before to. |
| `origin_refused` | 403 | A signed-in browser may only change things from the dashboard itself. |
| `sign_in_off` | 409 | Signing in is not set up on this server yet. |
| `server_owner_only` | 403 | Only the owner of this server, signed in, can change its settings. |
| `not_self_hosted` | 409 | These settings exist only on a server a team hosts itself. |
| `platform_not_linked` | 503 | This workspace is still being connected to the sending platform. Try again shortly. |
| `platform_unreachable` | 503 | The sending platform did not answer. Nothing was sent, so it is safe to try again. |
| `send_refused` | 422 | The sending platform refused this message. |
| `domain_not_verified` | 422 | Verify the domain of the from address before sending from it. |
| `domain_refused` | 409 | The sending platform refused this domain. It may belong to another account. |
| `contact_taken` | 409 | That address is already a contact here. Add that contact to an audience instead. |
| `contact_limit` | 403 | This workspace has every contact its plan allows. Remove some, or move to a larger plan. |
| `email_limit` | 403 | This workspace has sent every email its plan allows this month. Sending starts again on the first of the month, or move to a larger plan. |
| `broadcast_empty` | 409 | Nobody is subscribed to the audience of this broadcast, so there is no one to send it to. |
| `unsubscribe_invalid` | 404 | This unsubscribe link is not valid any more. |
| `billing_off` | 409 | Payments are not connected yet, so plans cannot be changed here. |
| `plan_unsold` | 422 | That plan cannot be bought here. |
| `billing_unreachable` | 503 | The payment service did not answer. Nothing was charged, so it is safe to try again. |
| `ask_off` | 409 | Ask is not connected to a model yet, so nothing was looked up or changed. |
| `ask_unreachable` | 503 | The assistant did not answer. Nothing was changed, so it is safe to ask again. |
| `ask_busy` | 429 | This workspace has asked a lot in the last hour. Try again in a little while. |
| `ask_change_unknown` | 422 | That is not a change the assistant can carry out. |
| `email_no_subject` | 422 | An email needs a subject, its own or the one of its template. |
| `email_no_sender` | 422 | An email needs a sender in `from`, its own or the one of its template. |
| `email_recipients_many` | 422 | An email goes to at most 50 addresses, counting to, cc and bcc together. |
| `email_not_scheduled` | 409 | Only an email that is still scheduled can be cancelled or moved. |
| `email_schedule_past` | 422 | The time to send at has to be in the future. |
| `email_schedule_far` | 422 | An email can be scheduled at most 30 days ahead. |
| `template_missing` | 422 | There is no published template with that id or alias. |
| `template_variable_missing` | 422 | The template needs a value for each of its variables. Missing: |
| `template_designed` | 422 | This template is built from blocks, so its html and its text are made from its design. Send design to change it, or design: null to turn it into an HTML template. |
| `template_written` | 422 | This template is written as HTML, so it has no blocks to change. Send templates.update with a design to turn it into a template built from blocks. |
| `broadcast_designed` | 422 | This broadcast is built from blocks, so its html and its text are made from its design. Send design to change it, or design: null to turn it into a broadcast written as HTML. |
| `attachments_too_large` | 422 | The attachments of one email can be 10 MB together at most. |
| `idempotency_busy` | 409 | A request with this idempotency key is still being handled. Try again in a moment. |
| `idempotency_mismatch` | 409 | This idempotency key was already used with a different request. |
| `email_change_refused` | 409 | The sending platform would not change this email. |
| `suppression_refused` | 422 | The sending platform would not change the suppression list. |
| `suppression_missing` | 404 | That address is not on the suppression list. |
| `key_domain` | 403 | This API key may only send from the domain it was made for. |
| `key_domain_access` | 422 | Only a key with sending access can be limited to one domain. |
| `key_unknown` | 422 | Resend does not know this key. Copy it again from where your program keeps it. |
| `key_enrolled` | 409 | This key is already enrolled. |
| `key_wider` | 422 | This key can only send email at Resend, so it cannot have full access here. |
| `key_test_access` | 422 | A test key only sends, so it cannot have full access. Leave `access` as `sending`. |
| `sandbox_mixed` | 422 | A test address cannot share an email with a real address. Send them as two emails, or use a test key. |
| `sandbox_address` | 422 | There is no test address with that name. The test addresses are: |
| `sandbox_limit` | 403 | This workspace has sent every test email it may send this month. Test emails start again on the first of the month. |
| `source_unreachable` | 503 | Resend did not answer. Nothing was changed, so it is safe to try again. |
| `chat_personal` | 403 | Chats belong to a signed-in person. An API key has none. |
| `automation_incomplete` | 422 | The automation cannot be published yet. |
| `automation_unpublished` | 409 | Publish the automation before you start it. |
| `automation_off` | 409 | Nobody can enter an automation that is not active. |
| `automation_large` | 422 | The flow is too large. Keep long emails in templates. |
| `run_ended` | 409 | That run has already ended. |
| `run_not_failed` | 409 | Only a run that failed at one of its steps can be tried again. |
| `run_exists` | 409 | This person is in the automation already, or may not enter it again. |
| `event_taken` | 409 | This workspace already has an event with that name. |
| `event_data` | 422 | The data does not fit the schema of the event. |
| `contact_missing` | 422 | There is no contact with that id in this workspace. |
| `person_missing` | 422 | Give the address of the person, or the id of a contact. |
| `import_off` | 409 | Imports are off: AUTH_SECRET is not set, so the key of the other account could not be kept sealed. |
| `import_running` | 409 | An import is already running in this workspace. Wait for it, or cancel it. |
| `import_ended` | 409 | This import has already ended. |
| `import_key_restricted` | 422 | This key can only send email at Resend, so it cannot read the account. Make a key with full access there and use that one. |
| `property_taken` | 409 | This workspace already has a contact property with that key. |
| `property_limit` | 403 | A workspace takes 100 contact properties at most. Delete one first. |
| `topic_missing` | 422 | There is no topic with that id. |
| `topic_limit` | 403 | A workspace takes 100 topics at most. Delete one first. |
| `topic_in_use` | 409 | A broadcast that has not been sent yet uses this topic. Change or delete that broadcast first. |
| `images_off` | 409 | Storage for images is not connected yet, so the image was not kept. |
| `image_url` | 422 | The url has to be the public https address of an image, such as https://example.com/logo.png. |
| `image_large` | 422 | The content is larger than 5 MB, which is the most an image can be. |
| `image_kind` | 422 | The content has to be a PNG, JPEG, GIF or WebP image. Its kind is read from the file itself, not from its name. |
| `image_svg` | 422 | The content is an SVG image, which is not taken. Send a PNG, JPEG, GIF or WebP image. |
| `support_off` | 409 | The contact form is not connected on this server yet, so the message was not sent. |
| `support_refused` | 403 | The message did not pass the check that keeps programs out of the contact form, so it was not sent. |
| `support_busy` | 429 | Too many messages came from here in the last hour. Try again in a little while. |
| `support_undelivered` | 503 | The mail service did not take the message. Nothing was sent, so it is safe to try again. |
