Errors and rate limits
Error format
Every error has the same body, and the HTTP status matches statusCode:
{ "statusCode": 422, "name": "missing_required_field", "message": "Missing `to` field." }
Branch on name, not on the message text. The SDK returns it as error.name.
| Status | name | Meaning |
|---|---|---|
| 400 | validation_error | The body is not valid JSON, a field is invalid, or the API key is unknown (outside the send endpoints). |
| 400 | invalid_idempotency_key | The Idempotency-Key is empty or longer than 256 characters. |
| 400 | invalid_region | A domain region that is not one of the four supported. |
| 401 | missing_api_key | No Authorization: Bearer header. |
| 401 | validation_error | The API key is unknown, on POST /emails or POST /emails/batch. |
| 401 | restricted_api_key | The key's permission does not allow this call (a sending-only key outside the send endpoints, or a support key that tries to send). |
| 403 | validation_error | The from domain is not verified, or the key is limited to another domain. |
| 403 | suspended | Sending is suspended for the project or the domain. |
| 404 | not_found | The resource does not exist in your project, or the route does not exist. |
| 405 | method_not_allowed | The path exists but not with this method. |
| 409 | invalid_idempotent_request | An idempotency key was reused with a different body. |
| 409 | concurrent_idempotent_requests | The first request with this key is still running, or its outcome is not yet known. |
| 409 | validation_error | A conflict, such as a domain name that is already taken. |
| 422 | missing_required_field | A required field is missing. |
| 422 | validation_error | A field is present but not acceptable. |
| 422 | invalid_attachment | An attachment lacks base64 content or a filename. |
| 429 | rate_limit_exceeded | The project's hourly sending cap is reached. |
| 429 | daily_quota_exceeded | The project's daily sending cap is reached. |
| 500 | application_error | The provider did not accept the message, or something failed on our side. |
Retrying
A 5xx means the outcome is uncertain, so retry, with the same Idempotency-Key on a send. Me Send never answers 5xx after a provider has accepted a message. A 4xx will not succeed on retry unless you change the request, except 429 and a 409 concurrent_idempotent_requests, which clear with time.
Rate limits
There is no per-request throttle and no X-RateLimit header. Limits are sending caps for the project, counted over a rolling window:
| Cap | Window | Default |
|---|---|---|
| Hourly | The last 60 minutes | 200 emails |
| Daily | The last 24 hours | 1,000 emails |
The operator of your project can change them. A send that would take the project over a cap answers 429 and carries a Retry-After header with the seconds until enough of the window has passed. A batch is checked as a whole before any of it is sent. Scheduled emails count when they are sent; test mode sends never count. Mail to the simulated test addresses is also counted like any other send.
Inbound mail has its own cap (500 messages an hour by default); senders retry later when it is reached.
const response = await fetch('https://api.mesend.co/emails', { method: 'POST', headers, body });
if (response.status === 429) {
const wait = Number(response.headers.get('Retry-After') ?? 60);
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
}
Pagination
List endpoints take limit (1 to 100, default 20) and an after id for the next page, and answer { "object": "list", "has_more": true, "data": [...] }. Some also take before. A limit that is not an integer is a 400.