> ## Documentation Index
> Fetch the complete documentation index at: https://docs.newlead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Authenticate every request with a subaccount API key.

```bash theme={null}
curl https://rest.newlead.ai/v1/me \
  -H "Authorization: Bearer $NEWLEAD_API_KEY"
```

```json theme={null}
{
  "object": "me",
  "api_key": { "id": "3f1e9c62-…", "prefix": "NL-1a2b3c4d5e", "name": "n8n" },
  "organization": { "id": "8d27b5a0-…", "name": "Your agency" },
  "subaccount": { "id": "b7d4e2a1-…", "name": "Your client" },
  "rate_limits": { "requests_per_minute": 120, "outbound_calls_per_minute": 5 }
}
```

Send your API key as a Bearer token in the `Authorization` header, over HTTPS. `GET /v1/me` answers `200` when the key works, and says which subaccount it belongs to.

The API also accepts the same key in the `x-api-key` header.

## Keys and scope

Keys start with `NL-`. Copy the whole key, including the part after the underscore.

* Each key belongs to one subaccount and can read and change only that subaccount's data.
* A resource in another subaccount returns `404 resource_not_found`, the same as one that does not exist.
* Organization keys do not work on `/v1`. They return `403 api_key_forbidden`.
* Managing webhook endpoints needs a key created by someone whose role can configure agents.

## Create and revoke a key

Manage keys in **Settings › API** of each subaccount. You need a role that can manage API keys.

The full key is shown only once, when you create it. If a key leaks, revoke it and create another: a revoked key stops working immediately.

> [!WARNING]
>
> Use the key only on your server, never in a website or a mobile app. Anyone who has it can read your leads, send messages and place calls.

## Authentication errors

| Status | Code | What to do |
| - | - | - |
| `401` | `api_key_missing` | Send the key in the `Authorization` header. |
| `401` | `api_key_invalid` | Check the key. It does not exist, is revoked or its subaccount no longer exists. |
| `402` | `subscription_inactive` | Reactivate the subscription or subaccount. Until then, only reads work. |
| `403` | `api_key_forbidden` | Create a key inside the subaccount, or use one whose role can configure agents. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.