// errors

Errors

Every error returns the same envelope with a stable, machine-readable code. Branch on code, not the HTTP status alone - several scenarios can share one status.

{
  "status": "error",
  "statusCode": 402,
  "code": "INSUFFICIENT_CREDITS",
  "message": "Not enough credit balance to send this message.",
  "path": "/v1/messages",
  "data": null,
  "details": { "required": 2.8, "available": 1.2 }
}

The envelope fields:

FieldDescription
statusAlways "error".
statusCodeMirrors the HTTP status.
codeThe stable discriminator to branch on.
messageHuman-readable, safe to log; override for UX copy.
pathThe request path that produced the error.
fieldErrorsPer-field messages on validation failures.
dataAlways null on errors.

Error codes

CodeHTTPMeaning
VALIDATION_ERROR422A field failed validation. See fieldErrors.
INVALID_API_KEY401The API key is missing or invalid.
API_KEY_REVOKED401The API key has been revoked.
API_KEY_SCOPE_DENIED403The key lacks the required scope for this call.
INSUFFICIENT_CREDITS402Not enough credit balance. Top up and retry.
NO_VALID_RECIPIENTS400No recipient passed validation (bad numbers).
SUPPRESSED_RECIPIENT400A recipient is on your opt-out / suppression list.
SENDER_ID_NOT_APPROVED403The requested sender ID is not approved.
IDEMPOTENCY_KEY_CONFLICT409The Idempotency-Key was reused with a different body.
PROVIDER_SEND_FAILED502The upstream network could not be reached.
RATE_LIMITED429Too many requests. Back off and retry.
NOT_FOUND404The requested resource does not exist.
INTERNAL_ERROR500An unexpected server error. Safe to retry idempotently.

Branch on code

A business 403 (API_KEY_SCOPE_DENIED) is not the same as an auth 403 (FORBIDDEN). Keying on code keeps your handling correct as the API grows.

Next: API reference