# Authentication

> `Authorization: Bearer <api key>` on tenant routes.

There is no OAuth flow for integrators. There is no per-customer key. One key acts on every customer in the tenant. Pass `phoneNumberId` or `customerId` to choose the business.

How keys are created, where `rawKey` sits in the JSON, and why admin is not a tenant-key API: [Tenants](/whatsapp/concepts/tenants.md).

## Partner key

**Dashboard → WhatsApp → API keys** creates the key your backend uses for every customer. The partner preset includes:

`messages:send`, `messages:read`, `conversations:read`, `templates:read`, `templates:write`, `media:read`, `media:write`, `webhooks:manage`, `usage:read`, `api_keys:read`, `api_keys:manage`, `phone_numbers:read`, `phone_numbers:write`, `customers:read`, `customers:write`, `setup-links:manage`.

`conversations:read` is on that preset. `GET /api/v1/conversations/window` needs it. `media:read` and `media:write` were added on 2026-10-21; keys created before that need a new key (or an operator) to read stored media. The raw key is shown once, next to `data`.

## Scopes

Checked only for tenant keys.

| Scope | Routes |
| --- | --- |
| `customers:read` / `customers:write` | `/api/v1/customers` |
| `setup-links:manage` | `/api/v1/customers/:id/setup-links`, `/api/v1/branding` |
| `phone_numbers:read` / `phone_numbers:write` | `/api/v1/phone-numbers`, Embedded Signup |
| `messages:send` / `messages:read` | `/api/v1/messages` |
| `templates:read` / `templates:write` | `/api/v1/templates` |
| `webhooks:manage` | `/api/v1/webhook-config`, including `POST /webhook-config/rotate-secret` |
| `api_keys:read` | `GET /api/v1/api-keys` |
| `api_keys:manage` | `GET`, `POST`, and `DELETE /api/v1/api-keys` |
| `usage:read` | `/api/v1/usage` |
| `billing:read` | `/api/v1/billing` |
| `contacts:read` / `contacts:write` | `/api/v1/contacts` |
| `conversations:read` | `/api/v1/conversations`, including `GET /conversations/window` |
| `media:read` / `media:write` | `/api/v1/media` |

A missing scope is `403` `FORBIDDEN` with message `Missing required scope: <scope>`.

These are the scopes an integrator normally sets. The full list also includes `business_profile:read`, `business_profile:write`, `calls:read`, `calls:write`, `groups:read`, `groups:write`, `groups:send`, `groups:manage`, `conversions:read`, and `conversions:write`. A send that sets `recipientType` to `group` also requires `groups:send`.

A key minted only for sending does not include `templates:write`, `webhooks:manage`, `usage:read`, or `api_keys:manage`. Add those if the same backend creates templates, sets the webhook, reads usage, or mints more keys.

`api_keys:read` or `api_keys:manage` can list keys. Only `api_keys:manage` can create or revoke. A tenant key cannot grant a scope it does not already have. Omitting `scopes` on `POST /api/v1/api-keys` copies the caller’s scopes. Keys created before `api_keys:read` and `api_keys:manage` existed do not gain those scopes automatically.

List responses include `keyPrefix`, `scopes`, `createdAt`, and `lastUsedAt`, plus `id`, `name`, `expiresAt`, and `revokedAt`. They never include the raw key, the hash, or `lastUsedIp`. Create returns `rawKey` once, next to `data`. `DELETE /api/v1/api-keys/:id` returns 409 when the key that authenticated the request is the last active key. Active means not revoked and not expired. Revoking a different key is allowed. A key from another tenant is 404.

`POST /api/v1/webhook-config/rotate-secret` (scope `webhooks:manage`) returns a new signing secret once. The previous secret stops matching immediately. There is no overlap window. The next delivery is signed only with the new secret. Set that env to the returned value before relying on deliveries again. Nothing in server startup rotates an existing tenant secret. `GET /webhook-config` still returns `hasSecret` only.

## Other surfaces

| Surface | Auth |
| --- | --- |
| `GET /health` | None. `503` when a dependency check fails. |
| `GET /api/v1/webhooks/meta` | Meta hub challenge. A bad verify token is `403` with `statusCode` and `message`, and no `code`. |
| `POST /api/v1/webhooks/meta` | Meta `X-Hub-Signature-256` (`sha256=` plus HMAC-SHA256 of the raw body). A bad signature is not stored. `true` returns `401`. A valid signature is stored, then `200` `EVENT_RECEIVED`, then processed asynchronously. `503` if it cannot be stored (Meta retries). |
| `GET /setup/:token` and `/api/v1/setup/public/:token` | The setup-link token in the path. |
| `/mcp` and `/api/v1/mcp` | Tenant API key. See [MCP](/whatsapp/mcp.md). Not required to send messages. |

Integrators get a key from **Dashboard → WhatsApp → API keys** after signup. That screen is the partner key. Settings → API keys is a different list.
