# Errors

Failed requests use:

```json
{
  "statusCode": 400,
  "code": "VALIDATION_ERROR",
  "message": "Customer service window is closed. Send an approved template message to re-open the conversation."
}
```

`details` is included for Fastify/Zod validation (an array) and when a service passes a details object (some billing errors, and `META_ERROR`). A `ValidationError` constructed with only a message omits `details`. The window error above is that case.

Setup finalize (`POST /setup/finalize` and `POST /api/v1/setup/public/:token/finalize`) keeps its own body, `{ "status": "failed", "error": "..." }`, with the same HTTP status as before. When the failure came from Graph (for example, Meta rejected the signup code), that body also carries `"code": "META_ERROR"` and the same `details` object, and `error` is Meta’s `error_user_msg` or `message`.

Successful calls are not this shape. They are `{ "data": ... }`, plus `meta` on paginated lists. See [Introduction](/whatsapp/api/introduction.md).

`POST /api/v1/messages` returns `201` when the row is queued. Meta’s accept or reject shows up later as `Message.status` and `errorCode`, and on `message.status`. Do not treat `201` as delivered.

| HTTP | `code` | When |
| --- | --- | --- |
| 400 | `VALIDATION_ERROR` | Zod rejected the body, the phone is not `ACTIVE`, the 24-hour window is closed for a non-template, the template name is on another WABA only, the WhatsApp number is already bound to another tenant, or a similar rule failed. Read `message`. |
| 400 | `META_ERROR` | Graph rejected the call (template create is the common case). HTTP status is Meta’s status for 400, 409, 422, and 429. A Meta 404 (unknown Graph object) is returned as 400, so a `404` from Whitelabel WhatsApp Cloud API always means the Whitelabel WhatsApp Cloud API route or resource. Other Meta failures, including 401 and 403 (the stored Meta credential was rejected, not your API key), return 502 with the same body. `message` is `error_user_msg` when Meta sent one, otherwise Graph’s `message`. `details` is `{ "code", "message", "error_user_msg" }` with Meta’s values. `error_user_msg` is `null` when Meta omitted it. No template row is stored. |
| 400 | `EMBEDDED_SIGNUP_FAILED` | Token exchange, register, or finish-binding failed. `message` is the session or caught error. `data.sessionId` is set on the exchange and register routes. Finish-binding’s `400` does not add `data.sessionId`. |
| 400 | `NO_WEBHOOK_URL` | `POST /webhook-config/test` with no URL saved. |
| 400 | `MISSING_CODE` | Headless or hosted finalize without `code`. |
| 401 | `UNAUTHORIZED` | Missing bearer token, unknown key, revoked key, expired key, or Meta webhook signature mismatch. |
| 401 | `SESSION_MISSING` / `SESSION_INVALID` / `SESSION_EXPIRED` | Hosted setup cookie missing, unknown, or older than 15 minutes. `GET /setup/start` and `GET /setup/complete` return that JSON unless `Accept` prefers `text/html`, in which case the body is a localized HTML page and the status is still `401`. |
| 403 | `FORBIDDEN` | Tenant is not `ACTIVE`, scope missing, or phone not on this tenant. Message for a missing scope is `Missing required scope: <scope>`. Message for tenant status is `Tenant is pending` or `Tenant is suspended`. |
| 403 | `CSRF_INVALID` | Hosted setup `POST /setup/finalize` CSRF token does not match the session. |
| 404 | `NOT_FOUND` | Id or setup token not found on this tenant (public setup: unknown token). |
| 409 | `CONFLICT` | Duplicate `externalCustomerId` on this tenant. |
| 409 | `INVALID_STATE_TRANSITION` | Setup link cannot move to in-progress from its current status. |
| 410 | `SETUP_LINK_EXPIRED` / `SETUP_LINK_INVALID` | JSON routes: unused link past `expiresAt` (`SETUP_LINK_EXPIRED`), or status `USED`, `REVOKED`, or `EXPIRED` (`SETUP_LINK_INVALID`). Hosted HTML is `404` for an unknown token and `410` for expired, used, or revoked. `USED` with WhatsApp `COMPLETED` is still `410`, with an “already connected” page. A configured `failureRedirectUrl` is `302` instead of that `410` page. Public status does not use `410`. |
| 422 | `PHONE_NOT_REGISTERED` | Register result is Meta `133010`. The text “already registered” does not override this code. |
| 429 | `REGISTER_RATE_LIMITED` | Register result is Meta `133016`. |
| 429 | `RATE_LIMIT_EXCEEDED` | More than 300 requests in the last minute for this API key. `Retry-After` is `60`. The JSON body does not include the delay. |
| 402 | `PHONE_NUMBER_LIMIT` | The tenant is on a plan that does not allow extra WhatsApp numbers and connecting this one would pass `details.included` (`details`: `included`, `connected`, `planKey`, `extraAllowed: false`). Create, PATCH status, register, Embedded Signup (`data.sessionId` on exchange and register), finish-binding. Tenants without a plan limit never get it. |
| 500 | `INTERNAL_ERROR` | Unexpected failure, including a Graph error that was not mapped. Production responses hide the internal message. |
| 503 | none | `GET /health` when database or Redis is down. Body is the health document with `status` `degraded` or `error`, not the error envelope. |

Hosted and headless setup failures also use these `errorCode` values on the redirect query string and on `setup_link.failed`: `link_expired`, `already_used`, `link_revoked`, `link_not_found`, `session_expired`, `facebook_auth_failed`, `token_exchange_failed`, `phone_verification_failed`, `phone_already_bound`, `waba_limit_reached`, `phone_number_limit`, `internal_error`. A redirect URL that is not on the branding or tenant allowlist is `400` `VALIDATION_ERROR` at create or PATCH time. `javascript:` and `data:` URLs are rejected, including on branding `allowedRedirectUrls`. A `connectionType` outside `allowedConnectionTypes` is the same `400`.

Meta hub verify (`GET /api/v1/webhooks/meta`) uses `403` with `statusCode` and `message` and no `code`.

## Message row errors

When a queued send fails, `GET /api/v1/messages/:id` has `status: "FAILED"` (or stays `PENDING` during a throughput retry) and `data.errorCode`.

A later Meta status webhook stores the code as digits, not `META_<code>`. Example: `131042`.

| `errorCode` | Meaning |
| --- | --- |
| `131042` (and other raw digit strings) | Meta’s status webhook failed the message. The value is the Graph code as text. `131042` is Business eligibility payment issue: that WABA needs a payment method in Meta. Not retried. |
| `META_<n>` | Graph rejected the send while the worker was calling Meta. The job is not retried, except the throughput codes below. |
| `PHONE_DISCONNECTED` | The phone was not `ACTIVE` or the credential was invalid when the worker ran. The worker does not call Meta. |
| `SEND_FAILED` | The worker failed without a Meta code (network or local limiter) and attempts were exhausted, or the row was still pending when the job ended. |
| `HTTP_<status>` | Meta responded without a numeric Graph code and with this HTTP status. Not retried as a Graph business error. |

Throughput codes `130429`, `131056`, and `80007` leave the row `PENDING` and retry until the last of 3 attempts. The first retry waits about 30 seconds, the next about 60 seconds, plus up to 5 seconds of jitter, and never more than 10 minutes. Any other Meta code is final on the first failure.

## Meta codes you will see

The numbers below are Meta’s. A status webhook stores the raw code (`131042`). A rejection during the send call stores `META_<code>`. Register-path mappings are called out in the row.

| Code | What you should do |
| --- | --- |
| `131042` | Business eligibility payment issue. The status webhook stores `errorCode` `131042`. The business adds a payment method on **their** WABA in Meta. Sending another copy does not fix it. |
| `131047` | Re-engagement outside 24 hours. Non-template sends are usually rejected first with `VALIDATION_ERROR` and never call Meta. If Meta still returns `131047`, the row is `FAILED`. A webhook stores `131047`. A worker rejection stores `META_131047`. Not retried. Send an approved template. |
| `131026` | Undeliverable. `FAILED`. A webhook stores `131026`. A worker rejection stores `META_131026`. No retry. Confirm the number. |
| `130429` | Cloud API throughput. Stays `PENDING` and retries. Also respect [Rate limits](/whatsapp/api/rate-limits.md). |
| `131056` | Pair rate limit. Same throughput retry. The local limiter already spaces one message per recipient per 6 seconds. Meta’s pair limit is stricter over a longer window. |
| `80007` | Treated as throughput, same retry as `130429`. |
| `132000` (and nearby template parameter codes such as `132001`–`132015`) | No special case. First failure is final. Match `components` to the approved template and send a new message. This API does not resend a `FAILED` row. |
| `133010` | On the register path: HTTP `422` `PHONE_NOT_REGISTERED`. On a later send: `META_133010`, not retried. |
| `133016` | On the register path: HTTP `429` `REGISTER_RATE_LIMITED`. |

## Duplicate sends

A client retry of `POST /messages` after a `201` creates another message. If the first request timed out, look up recent messages with `GET /api/v1/messages?phoneNumberId=&page=1&limit=20` before posting again. There is no `Idempotency-Key` header.
