Skip to the content
Sendcub

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.

JSON
{
  "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

CodeMeaningWhat to do
401No key, or an unknown, revoked or expired oneCheck the header, check the key was not deleted
403The key lacks the scopeAdd the scope to the key, in Sendcub
404No such thing in this workspaceIt may belong to another workspace
409A conflict. Usually idempotency, sometimes a limitRead the code. Retrying unchanged repeats it
413The body is larger than the route allowsSend less, or send a batch in pieces
415The body was not sent as application/jsonSet Content-Type
422Understood, and refusedEither a field is wrong or a rule said no. The body says which
429Too many requestsWait the seconds in Retry-After, then continue
5xxOur faultRetry 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:

CodeWhy
category_requiredA send arrived without a category, which decides who may opt out of it
suppressedThe recipient unsubscribed, bounced hard or complained
topic_opt_outThe contact opted out of this topic
review_rejectedThe content failed the content checks
sending_suspendedThe workspace cannot send right now
unknown_fieldA custom field is not defined in this workspace yet
invalid_choiceA value is not one of the options of its choice field
provider_unavailableThe 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
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.

Try Sendcub

Sendcub opens to customers soon. Ask for early access and we will tell you the day your account is ready.

Request early access