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

# Authentication

> How to authenticate with the AgentPost REST API using Bearer tokens.

## API Tokens

AgentPost uses Bearer token authentication. The same tokens work for both the REST API and the MCP API.

### Generate a token

1. Log in to the [AgentPost dashboard](https://agentpost.email)
2. Go to **Settings > API Tokens**
3. Click **Create Token** and give it a name
4. Copy the token immediately — it is shown only once

### Use the token

Include it in the `Authorization` header of every request:

```bash theme={null}
curl https://agentpost.email/api/v1/domains \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
```

### Token security

* Tokens grant full access to your account (mailboxes, messages, domains, sending)
* Treat tokens like passwords — do not commit them to source control
* Revoke compromised tokens immediately at **Settings > API Tokens**
* Tokens do not expire, but you can revoke them at any time

## Unauthenticated Requests

Requests without a valid token receive a `401` response:

```json theme={null}
{
  "message": "Unauthenticated."
}
```
