Errors
When the Oblic API refuses a request, its HTTP status says what kind of problem it is, and its body says exactly what: a code your code can act on, and a message a person can read, which often says what to do.
The error envelope
A refusal
{
"status": "error",
"data": null,
"errors": [
{ "cd": "TO[0]", "message": "must be a well-formed email address" }
]
}
cdis the code, in capitals, and is what to branch on: messages may change.errorshas one entry for each problem, so a body with two fields wrong answers both.- A refusal before the route runs, for the key, its address, its scopes or the sub-account it names, leaves
dataout. A204answer has no body at all.
Status codes
| Status | Means |
|---|---|
200, 201, 202, 204 | Done; made; queued, for a send or a replay; done, with nothing to say |
400 | The request is not valid as it is: a field, a parameter or the body |
401 | No key, or one Oblic doesn't know. See Authentication |
402 | INSUFFICIENT_BALANCE: a marketing SMS or WhatsApp message, and the wallet that pays for the account is empty. Sign-in codes, transactional messages and replies still go |
403 | The key's address, scopes or role don't allow it, or the account may not do it, such as a sub-account making sub-accounts |
404 | No such route, or the account has no such thing |
405, 415 | The route doesn't take that method, with an Allow header, or that content type: send application/json |
409 | It conflicts with what is there: an Idempotency-Key used for another message, or a template that exists already |
413 | MESSAGE_TOO_LARGE: the message is too large to send |
422 | Understood, but it can't be done as asked: a sender not verified, a template not approved, a number that opted out |
429 | A limit is reached, with a Retry-After header in seconds |
500 | Something went wrong in Oblic |
502 | Meta refused a step of connecting a WhatsApp number |
503 | A service Oblic depends on is unavailable just now; nothing was done |
Each page lists the codes of its routes, such as Messages and Webhooks.
Validation errors
- A body field that is missing or not valid comes back with its path as
cd, in capitals, such asTO,TO[0],FROMNAMEorATTACHMENTS[0].FILENAME, and the rule it broke asmessage. Adding contacts to a list is the exception: a contact that is not valid isBAD_REQUEST, as a parameter is (see Contact lists). - A query or path parameter that is not valid, such as a
limitof500or acursorthat is not one, isBAD_REQUEST, withmessagenaming it: "limitis not valid." - A body that is missing, or not JSON, is
BAD_REQUEST: "The request body is missing, or is not valid JSON for this route." - A route that isn't there is
404 NOT_FOUND, "There is no such route." - A field the route doesn't know is ignored.
Retrying
- Try again later on
429, waiting theRetry-Afterseconds, and on500,503or no answer, waiting longer each time. Send each retry of a send with the sameIdempotency-Key, so that it is sent once. See Messages. - Change something first on any other
4xx: the same request will be refused again. On402, top up the wallet. The exception is422 OUTSIDE_PROMOTIONAL_HOURS, which comes withRetry-Aftertoo: the same SMS goes once the hours open.