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" }
  ]
}
  • cd is the code, in capitals, and is what to branch on: messages may change.
  • errors has 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 data out. A 204 answer has no body at all.

Status codes

StatusMeans
200, 201, 202, 204Done; made; queued, for a send or a replay; done, with nothing to say
400The request is not valid as it is: a field, a parameter or the body
401No key, or one Oblic doesn't know. See Authentication
402INSUFFICIENT_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
403The 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
404No such route, or the account has no such thing
405, 415The route doesn't take that method, with an Allow header, or that content type: send application/json
409It conflicts with what is there: an Idempotency-Key used for another message, or a template that exists already
413MESSAGE_TOO_LARGE: the message is too large to send
422Understood, but it can't be done as asked: a sender not verified, a template not approved, a number that opted out
429A limit is reached, with a Retry-After header in seconds
500Something went wrong in Oblic
502Meta refused a step of connecting a WhatsApp number
503A 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 as TO, TO[0], FROMNAME or ATTACHMENTS[0].FILENAME, and the rule it broke as message. Adding contacts to a list is the exception: a contact that is not valid is BAD_REQUEST, as a parameter is (see Contact lists).
  • A query or path parameter that is not valid, such as a limit of 500 or a cursor that is not one, is BAD_REQUEST, with message naming it: "limit is 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 the Retry-After seconds, and on 500, 503 or no answer, waiting longer each time. Send each retry of a send with the same Idempotency-Key, so that it is sent once. See Messages.
  • Change something first on any other 4xx: the same request will be refused again. On 402, top up the wallet. The exception is 422 OUTSIDE_PROMOTIONAL_HOURS, which comes with Retry-After too: the same SMS goes once the hours open.
Was this page helpful?