The error shape
{
"error": {
"type": "domain_not_verified",
"message": "acme.com is not verified yet. Publish its DNS records, then check DNS.",
"field": "from"
}
}
type: a stable code. Branch on this.message: what went wrong and what to do. Safe to log and show to developers as it is.field: the input at fault, when one input caused it. In a batch it is prefixed with the position, such as3.subject.
Authentication (401, 403)
| Status | Type | Cause | Fix |
|---|---|---|---|
| 401 | missing_api_key |
No Authorization header |
Send Authorization: Bearer mc_live_.... |
| 401 | invalid_api_key |
Unknown or revoked key | Check the key with GET /v1/whoami; create a new one if revoked. |
| 403 | restricted_api_key |
A sending-only key called a full-access endpoint, or a domain-limited key sent from another domain | Use a full-access key, or the right domain. |
| 403 | forbidden |
The action is not allowed for this key or team, for example managing keys with a key whose creator is no longer an admin or developer | Use a key made by a current admin or developer. |
Domains and sending rights (403, 409)
| Status | Type | Cause | Fix |
|---|---|---|---|
| 403 | domain_not_found |
The from domain is not on your team |
Add it under Domains. |
| 403 | domain_not_verified |
The from domain is added but not verified |
Publish its records, press Check DNS now. |
| 403 | sandbox_recipient |
Your team has not verified a domain, and the recipient is not a team member; or a broadcast was sent from the sandbox | Verify a domain. See Sandbox explained. |
| 403 | sending_paused |
Sending is paused after a review | Open Reviews, read the reason and reply. |
| 409 | domain_taken |
Another team already has this domain | Remove it there, or contact us if it is yours. |
Request problems (400, 422)
| Status | Type | Cause | Fix |
|---|---|---|---|
| 422 | missing_required_field |
A required field is empty, or a template variable without a fallback is missing | Add the field named in field. |
| 422 | validation_error |
A value is wrong: bad address, over 50 recipients, bad scheduled_at, batch over 100, and similar |
Read message and field. |
| 422 | invalid_attachment |
Missing filename, bad base64, over 40 MB, or a path instead of content |
See Attachments. |
| 400 | invalid_idempotency_key |
Idempotency-Key is empty or over 256 characters |
Send 1 to 256 characters. |
Conflicts and state (404, 409)
| Status | Type | Cause | Fix |
|---|---|---|---|
| 404 | not_found |
No such item on your team | Check the id and the team the key belongs to. |
| 409 | invalid_idempotent_request |
Same Idempotency-Key, different body |
Use a new key for a new email. |
| 409 | concurrent_idempotent_requests |
A retry arrived while the first request with that key was still running | Wait a moment and retry. |
| 409 | invalid_state |
The item is not in a state that allows this, such as rescheduling an email that already went out, or editing a sent broadcast | Read the status in message. |
| 409 | already_exists |
The contact is already in this audience | Update it with PATCH instead. |
Limits and billing (402, 429)
| Status | Type | Cause | Fix |
|---|---|---|---|
| 429 | rate_limit_exceeded |
Over your team’s requests per second | Wait retry-after (1 second). Use batch sends. |
| 429 | daily_quota_exceeded |
Starter’s 100 emails for the day (UTC) are used | Wait for midnight UTC, or change plan. |
| 429 | monthly_quota_exceeded |
Starter’s 3,000 emails for the month are used | Change plan under Billing. |
| 402 | card_required |
A paid plan needs a card | Add a card under Billing. |
| 402 | card_declined |
The card was declined | Use another card. |
Errors without this shape
404with{"message": "Not Found"}: the URL does not match any endpoint. Check the path starts with/v1/and ids are full UUIDs.5xx: something failed on our side. Retry with anIdempotency-Key, and checkstatus.mailcandor.com.- Compatible endpoints:
POST /v3/mail/sendanswers SendGrid-style{"errors": [{"message", "field"}]}, and the Postmark endpoints answer with Postmark’sErrorCodeandMessage, so existing SDKs understand them.
Handling errors in code
const res = await fetch('https://api.mailcandor.com/v1/emails', { method: 'POST', headers, body });
if (!res.ok) {
const { error } = await res.json().catch(() => ({ error: { type: 'http_' + res.status, message: res.statusText } }));
if (error.type === 'rate_limit_exceeded') { /* wait 1s and retry */ }
else if (error.type === 'domain_not_verified') { /* alert: DNS problem */ }
else throw new Error(`${error.type}: ${error.message}${error.field ? ` (${error.field})` : ''}`);
}
Full reference: docs.mailcandor.com.