Errors

The Bytesms error envelope ({ statusCode, message, name }) and every error name the API returns, with HTTP status codes.

Error shape

Every /api/v1 error is JSON with the HTTP status, a human-readable message and a machine-readable name. Branch on name (and the status), never on message.

422 Unprocessable Entity
{
  "statusCode": 422,
  "message": "`to` must contain at least one recipient.",
  "name": "validation_error"
}

Some errors add fields. Quota errors (daily_quota_exceeded, monthly_quota_exceeded) and plan-limit errors (plan_limit_exceeded) carry the specific code plus limit and current. Other errors may include a code when one is available. 402 insufficient_credits adds neededThb and availableThb. Treat every extra field as optional:

429 Too Many Requests
{
  "statusCode": 429,
  "message": "Daily email limit reached (100/100). Try again tomorrow or upgrade your plan.",
  "name": "daily_quota_exceeded",
  "code": "daily_limit_reached",
  "limit": 100,
  "current": 100
}
402 Payment Required
{
  "statusCode": 402,
  "message": "Not enough prepaid credit. Top up (or turn on auto-recharge) in the dashboard under Settings → Billing.",
  "name": "insufficient_credits",
  "neededThb": 0.155,
  "availableThb": 0.04
}

Request-body validation failures (wrong types, invalid email addresses, unknown enum values) are returned as 422 validation_error with the individual problems joined into message.

Error names

StatusnameWhen
401unauthorizedMissing, malformed, unknown or expired API key.
401restricted_api_keyA sending_access key called an endpoint other than the email send and WhatsApp endpoints.
402insufficient_creditsThe over-quota recipients (or a WhatsApp message) cost more than the workspace's prepaid credit, after auto-recharge. Body adds neededThb / availableThb — see Credits & billing.
403restricted_api_keyA domain-scoped key sent from another domain (or its domain was deleted), or called a /v1/whatsapp endpoint.
403suspended_api_keyThe API key was suspended.
403invalid_from_addressThe from domain is not a verified domain of this workspace (the workspace has other verified domains).
403validation_errorNo verified domain yet, or [email protected]used to send to anyone other than your own account email or a test address. Also returned when a domain's warm-up daily volume is used up.
403sending_pausedSending is paused for the workspace (e.g. high bounce/complaint rate).
403account_under_reviewThe workspace is under review.
403account_suspendedThe workspace is suspended.
403subscription_past_due_expired, subscription_unpaid, subscription_incomplete, subscription_paused, subscription_canceledThe paid subscription is not in good standing (past the payment grace period, unpaid, …).
403plan_limit_exceededA plan cap was hit; code says which: api_key_limit_reached, domain_limit_reached, segment_limit_reached, contact_limit_reached, contact_limit_exceeded, webhook_limit_reached, member_limit_reached. The body also carries limit (the plan cap) and current (the count when the request was made).
404not_foundThe resource does not exist in this workspace (ids of other workspaces are 404 too).
409idempotency_key_conflictThe Idempotency-Key was already used with a different request body.
409domain_in_use, domain_pending_elsewhereThe domain is verified in another workspace, or claimed there within the last 72 hours.
409validation_errorDuplicate: a contact with this email already exists in the audience, a template alias is taken, a broadcast was already sent.
422validation_errorThe request is invalid (see message).
422invalid_idempotency_keyThe Idempotency-Key header is empty or longer than 256 characters.
422attachments_not_supportedThe request contained attachments (not supported yet).
422invalid_domain, reserved_domainNot a valid fully-qualified domain name, or a platform / consumer-mailbox domain that can't be added.
429rate_limit_exceededToo many requests per second — see Rate limits.
429daily_quota_exceededThe plan's daily email limit (recipients per UTC day) is used up.
429monthly_quota_exceededThe plan's monthly quota is used up on a plan without overage (Free). Paid plans continue from prepaid credit.
5xxapplication_errorSomething went wrong on our side, or a sending server was unreachable. Retry with backoff.

Retrying

Retry 429 rate_limit_exceeded after the retry-after header and 5xx errors with exponential backoff. Retry 402 insufficient_credits once the workspace has topped up. When you retry a send, use an Idempotency-Keyso a request that actually succeeded is not sent twice. Don't retry other 4xx errors unchanged — they fail the same way.

Legacy endpoint

The legacy POST /api/v1/emails/send is not wrapped in this envelope: request-validation failures come back as 400 with { statusCode, message: string[], error }, and it returns the full internal message row on success. New integrations should use POST /api/v1/emails.