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

# Authentication

> How to authenticate with The Postal Company API using API keys.

# Authentication

All API requests require an API key passed in the `Authorization` header.

## Creating an API key

1. Log in to your [dashboard](https://thepostalcompany.com/api-keys)
2. Click **Create key** and give it a name (e.g. "Production", "My App")
3. Copy the key immediately — it is only shown once

API keys look like this: `tpc_aBcDeFgHiJkLmNoPqRsTuVwXyZ...`

## Using your API key

Include the key in the `Authorization` header as a Bearer token:

```bash theme={null}
curl -X POST https://thepostalcompany.com/api/v1/letters \
  -H "Authorization: Bearer tpc_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
```

## Revoking a key

Go to [API Keys](https://thepostalcompany.com/api-keys) in the dashboard and click **Revoke** next to the key you want to disable. Revoked keys immediately stop working.

## Error responses

| Status | Meaning                              |
| ------ | ------------------------------------ |
| `401`  | Missing, invalid, or revoked API key |

```json theme={null}
{
  "error": "Invalid or revoked API key"
}
```
