# Authentication

API keys, scopes and headers.

Every request carries the header:

```text
Authorization: Bearer pk_live_...
```

## Two key scopes

| Scope | Access |
|---|---|
| Partner | The whole account: every company, billing, keys. |
| Company | A single company. Targeting another company returns `403 out_of_scope`. |

Use a company key for anything that leaves your premises (your website, a third-party tool, an AI agent): if it leaks, access stays limited to one company.

## Create and revoke a key

In the portal, *API keys* page, or through the API with `POST /api-keys` (partner key required). The secret is shown once. Revoke a key with `DELETE /api-keys/{id}`: it stops working immediately.

## Response format

A success looks like `{ "data": ... }`. An error looks like:

```json
{ "error": { "code": "plan_limit_messages", "message": "...", "details": {}, "request_id": "..." } }
```

Every response carries the `X-Request-Id` header. Give it to support if something goes wrong: they can find the exact request.

## Common errors

The format shared by every route (pagination, Meta errors, retries) is described in [API conventions](/en/docs/conventions).

| HTTP | Code | What to do |
|---|---|---|
| 401 | `unauthenticated` | Key missing, wrong or revoked. |
| 402 | `plan_limit_messages`, `plan_limit_numbers`, `plan_limit_users`, `plan_feature_required` or `subscription_past_due` | Quota, feature or subscription: see [Subscription and quotas](/en/docs/billing). |
| 403 | `out_of_scope` | The company key targets another company. |
| 404 | `not_found` | The identifier does not exist or is not yours. |
| 409 | `invalid_campaign_state` | The action is not possible in the current state (for example pausing a finished campaign). |
| 422 | `validation_failed` | A field is invalid; `details` lists the fields. |
| 429 | `rate_limited` | Too many requests in a short time: wait the number of seconds in the `Retry-After` header, then retry. |
| 429 | `daily_limit_reached` | The number's daily sending cap is reached. It resets at midnight. |
| 429 | `meta_tier_reached` | The number's Meta sending tier is reached for new recipients over 24 hours. Contacts already reached are still possible. |

## Rate limits

Each key can make 300 requests per minute, including 120 message sends (`POST /messages`). Every response carries `X-RateLimit-Limit` and `X-RateLimit-Remaining`. Beyond that, the API answers `429` with `Retry-After` (in seconds): slow down and retry, without multiplying calls.

More than 20 invalid keys from one address within 15 minutes block that address for the rest of the period, even with a valid key.

API and inbox sends are capped per day and per number according to your plan (from 500 on trial to 30,000 on Business). Campaigns and automations do not count toward this cap. The per-minute rate also depends on the plan (120 to 900 requests).

When a key hits its limit, the members who manage the account get an alert in the portal and by e-mail.

## Key lifetime and rotation

At creation, a key can get a lifetime (`expiresInDays`, 1 to 730 days). Seven days before the deadline, the team is notified.

`POST /api-keys/{id}/rotate` creates an identical key and returns its secret in clear text, once. The old key stays valid for 24 hours, so you can switch your tools, then stops working. The portal offers the same "Renew" button.
