Errors, refusals and retries
What a refusal looks like, which ones to retry, and how idempotency keys make a retry free.
- Updated
- 23 November 2026
Routes on this page
1 route
- POST
/api/v1/email/sendsend
Sendcub refuses in a single shape, whatever went wrong and whichever route you called. Your code never has to read a sentence to decide what to do.
{
"code": "validation_failed",
"detail": "A field of the request was refused.",
"requestId": "0HNC4K8VQ2M1J:00000003",
"errors": {
"email": ["invalid"],
"fields.last_order_at": ["wrong_type"]
}
}Three fields are always there. code is what your code switches on. detail is one sentence for a human reading a log. requestId is the one value to quote if you ever ask us about a call, because it finds that exact request on our side.
errors appears when the refusal is about fields: the key is the field, dotted for anything nested, and the value is a list of codes rather than sentences. Some refusals add a field of their own, such as the seconds to wait or the id of a conflicting contact.
Status codes, and what each one means for you
| Code | Meaning | What to do |
|---|---|---|
401 | No key, or an unknown, revoked or expired one | Check the header, check the key was not deleted |
403 | The key lacks the scope | Add the scope to the key, in Sendcub |
404 | No such thing in this workspace | It may belong to another workspace |
409 | A conflict. Usually idempotency, sometimes a limit | Read the code. Retrying unchanged repeats it |
413 | The body is larger than the route allows | Send less, or send a batch in pieces |
415 | The body was not sent as application/json | Set Content-Type |
422 | Understood, and refused | Either a field is wrong or a rule said no. The body says which |
429 | Too many requests | Wait the seconds in Retry-After, then continue |
5xx | Our fault | Retry with a growing delay |
Retry 429 and 5xx. Never retry 403, 409, 415 or 422 unchanged: those refusals are about the request, not about timing, so a retry loop just burns your rate limit and delays the fix.
Refusals that are rules, not errors
A 422 is sometimes Sendcub protecting something rather than complaining about your JSON. The ones you will meet:
| Code | Why |
|---|---|
category_required | A send arrived without a category, which decides who may opt out of it |
suppressed | The recipient unsubscribed, bounced hard or complained |
topic_opt_out | The contact opted out of this topic |
review_rejected | The content failed the content checks |
sending_suspended | The workspace cannot send right now |
unknown_field | A custom field is not defined in this workspace yet |
invalid_choice | A value is not one of the options of its choice field |
provider_unavailable | The route out is down. This one is worth retrying |
These are not bugs to work around. Each is the reason a Sendcub workspace can keep sending at all, and treating them as permanent (except the last) is what keeps a bad address from being retried a thousand times.
Idempotency, so a retry is free
A send takes an idempotency key, either as the Idempotency-Key header or as idempotencyKey in the body:
curl -X POST https://api.sendcub.com/api/v1/email/send \
-H "Authorization: Bearer sk_live_your_key_here" \
-H "Idempotency-Key: order-8891-receipt" \
-H "Content-Type: application/json" \
-d '{ "to": "[email protected]", "subject": "Your receipt", "text": "Thank you.", "category": "transactional" }'Either form works, and if you send both they have to be the same string: two different keys in one request is a bug in your client, so it is refused rather than guessed at. A key is at most 100 characters.
Repeat the same key with the same body and you get the first result back, with the header Idempotent-Replayed: true and status 200 instead of 202. Nothing is sent twice.
Repeat the same key with a different body and the call is refused with 409 and idempotency_conflict. That is the protection working: it means your code reused a key for a different thing, which is a bug you want to hear about rather than have quietly papered over.
Use something that identifies the work, not the attempt: order-8891-receipt is right, a fresh random value on every retry defeats the whole mechanism.
When you cannot tell what happened
A timeout is the one case where you do not know whether the work was done. This is exactly what idempotency keys are for: send the same key again. If the first call landed, you get its result; if it did not, the work happens now. Either way you end up in one known state, which is why every job that can be retried should carry a key from the start.
The batch routes take the same approach from the other end: a batch answers for every row it was given, so a retry after a timeout is a comparison rather than a guess.
