Errors
Every error code the API returns and what to do about it.
Error shape
Failed requests use the normal response envelope with success: false. Decide what to do from status_code and error; show messageto a person if you like, but don't branch on its text.
Response
400 Bad Request
{
"success": false,
"status_code": 400,
"status_text": "Bad Request",
"message": "insufficient balance",
"error": "creation_error"
}Error codes
| Status | error | When it happens |
|---|---|---|
| 400 | validation_error | A field is missing, empty, too long or the wrong type. message names the field. |
| 400 | creation_error | The request was valid but couldn't be carried out: sender name not approved or not yours, not enough balance, WhatsApp template not approved, amount below the bundle price, name already taken. |
| 400 | invalid_parameter | A path parameter is malformed — usually an id that isn't a UUID. |
| 400 | verification_error | The OTP is wrong, expired or already used. |
| 400 | idempotency_conflict | The same Idempotency-Key was reused for a different request body. |
| 401 | missing_token | No API key was sent. |
| 401 | invalid_token | The API key is wrong or was deleted. |
| 401 | account_not_found | The key's account no longer exists. |
| 401 | account_disabled | The account is switched off. |
| 401 | account_not_verified | The account hasn't been verified yet. |
| 403 | forbidden | The key may not access this resource (e.g. another customer's sender name). |
| 404 | not_found | No resource with that id belongs to you. |
| 405 | method_not_allowed | Wrong HTTP method for this path. |
| 429 | rate_limited | Too many requests in a short time. Wait for Retry-After seconds. |
| 500 | server_error | An unexpected problem on our side. It's logged and we're alerted. |
Handling errors
- 4xx (except 429): fix, don't retry. Sending the same request again will fail the same way.
- 429 and 5xx: retry with backoff. Wait 1 s, 2 s, 4 s… up to a minute, and honour
Retry-After. - Timeouts on sends: retry with the same Idempotency-Key so the message isn't sent twice.
- Log the error code and your request id so support can find the request quickly.
Retry helper (JavaScript)
async function callNbm(url, options, attempt = 0) {
const res = await fetch(url, options);
const body = await res.json();
if (body.success) return body.data;
const retryable = res.status === 429 || res.status >= 500;
if (retryable && attempt < 5) {
const wait = Number(res.headers.get("Retry-After")) || 2 ** attempt;
await new Promise((r) => setTimeout(r, wait * 1000));
return callNbm(url, options, attempt + 1);
}
throw Object.assign(new Error(body.message), { code: body.error, status: res.status });
}