# Authentication

> Authenticate API requests with an API key sent as a Bearer token. How to create, store and revoke keys.

Send an API key with every request to the API, as a Bearer token in the `Authorization` header:

```sh
curl "https://api.ringingbytes.com/v1/detections?limit=1" \
  -H "Authorization: Bearer $RINGING_BYTES_API_KEY"
```

If your tool cannot set `Authorization`, send the key in an `X-API-Key` header instead:

```sh
curl "https://api.ringingbytes.com/v1/detections?limit=1" \
  -H "X-API-Key: $RINGING_BYTES_API_KEY"
```

## Create a key

1. Sign in to the dashboard and open **API keys**.
2. Choose **Create key** and give it a name you will recognise, such as `production` or `staging`.
3. Copy the key. It starts with `rb_live_`, and the dashboard shows it only once.

Keys belong to your organization, so every member sees and can use the same keys. You can create several, for example one per environment, and see when each was last used.

An AI agent can also ask for a key itself. An owner or admin approves it in the dashboard and chooses its permissions and monthly spending cap. See [Agents](https://ringingbytes.com/docs/agents).

## Keep keys secret

- Call the API from your server. A key in a browser or mobile app is visible to anyone who uses it.
- Keep keys in environment variables or a secrets manager, out of source code.
- If a key leaks, revoke it in the dashboard and create a new one. A revoked key stops working at once.

## When authentication fails

A missing, invalid or revoked key gets `401 Unauthorized`:

```json
{
	"defined": false,
	"code": "UNAUTHORIZED",
	"status": 401,
	"message": "Invalid or revoked API key"
}
```

The rate limit is 120 requests per minute per organization, shared by all of its API keys, so creating more keys does not raise it. See [Errors and rate limits](https://ringingbytes.com/docs/errors).
