# Create an API key

> Authenticate every request with a scoped bearer token.

Sendtern authenticates requests with API keys. Each key belongs to one workspace and carries one permission level.

## Create a key

1. **Open API Keys**: Go to [API Keys](https://sendtern.com/dashboard/api-keys) and press **Create API key**.

2. **Name it**: Use a name that says where it lives, for example `production-web` or `staging-worker`. You'll thank yourself when you need to revoke one.

3. **Choose a permission**: Pick **Sending only** unless the key must manage domains or other keys.

4. **Copy it once**: The full token is shown a single time. Sendtern stores only a hash, so a lost key can't be recovered. Create a new one instead.

## Permissions

| Permission | Can call | Use it for |
| --- | --- | --- |
| Sending only | POST /emails, POST /emails/batch, POST /test/emails | Apps, background jobs, AI agents |
| Full access | Every endpoint: emails, domains, API keys | Infrastructure scripts and CI only |

## Use the key

Send the key in the `Authorization` header with the `Bearer` scheme. Requests without it fail with `401`.

```
Authorization: Bearer st_your_api_key
```

## Rotate and revoke

- Create the new key first, deploy it, then revoke the old one. There is no downtime.
- Revoking takes effect immediately. Requests with a revoked key return `401 invalid_api_key`.
- Every key shows when it was last used, so you can spot keys nobody needs anymore.

> **warning:** Never ship an API key to a browser or mobile app, and never commit it to a repository. Anyone holding a key can send email as you. See [Key security](https://sendtern.com/docs/security).
