---
title: "API authentication"
url: "https://coldagentai.com/docs/authentication.md"
canonical_url: "https://coldagentai.com/docs/authentication"
last_updated: "2026-10-17"
type: "conceptual"
summary: "Send a Bearer or X-API-Key key, choose read or write scope, create and revoke keys, and handle per-key rate limits with Retry-After."
related: ["https://coldagentai.com/docs/getting-started.md", "https://coldagentai.com/docs/api.md", "https://coldagentai.com/docs/errors.md"]
install: "claude mcp add --transport http coldagentai-free https://coldagentai.com/api/mcp"
---

# API authentication

> **For AI agents:** the complete index of ColdAgentAI pages is [llms.txt](https://coldagentai.com/llms.txt). Every page is also served as markdown at its URL plus .md.

Send a Bearer or X-API-Key key, choose read or write scope, create and revoke keys, and handle per-key rate limits with Retry-After.

Every request carries an API key. A key is either read or write, and each key has its own rate limit.

## Send the key

Put the key in an `Authorization: Bearer` header, or in an `X-API-Key` header. Both are accepted on every authenticated endpoint.

Bearer header:

```
curl https://api.coldagentai.com/v1/account \
  -H "Authorization: Bearer $COLDAGENTAI_API_KEY"
```

X-API-Key header:

```
curl https://api.coldagentai.com/v1/account \
  -H "X-API-Key: $COLDAGENTAI_API_KEY"
```

A missing, malformed, revoked or unknown key returns `401 unauthorized` with a `WWW-Authenticate: Bearer` header.

## Read and write scope

| Scope | What the key can do |
| --- | --- |
| `read` | Read only. It cannot change state, send mail or spend credits. |
| `write` | Everything a read key can do, plus routes that change state, send mail or spend credits. |

Each operation in the [API reference](https://coldagentai.com/docs/api.md) names the scope it needs, and the OpenAPI document carries the same value as `x-scope`. A read key that calls a write route gets `403 forbidden` with a message that names the route and tells you to use a write key.

## Creating and revoking keys

- `POST /v1/account/keys` creates a key. It needs a write key, and the scope defaults to read.
- The full key is in the creation response once. It is not stored and cannot be shown again. `GET /v1/account` lists keys by id, prefix and scope, never the key itself.
- `DELETE /v1/account/keys/:id` revokes a key at once. A revoked key is rejected with 401 from then on.

Give each agent its own key with the narrowest scope it needs, so you can revoke one without touching the rest.

## Rate limits

Limits are counted per key: 200 requests per 10 seconds by default. Every authenticated response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (Unix seconds).

Over the limit you get `429 rate_limited` with a `Retry-After` header holding the seconds to wait. Wait that long, then send the same request again.

Node:

```
const res = await fetch(url, { headers });
if (res.status === 429) {
  const wait = Number(res.headers.get('retry-after') ?? '1');
  await new Promise((r) => setTimeout(r, wait * 1000));
  // then send the same request again
}
```

## Related

- [Get started with the API](https://coldagentai.com/docs/getting-started.md)
- [API reference](https://coldagentai.com/docs/api.md)
- [API errors](https://coldagentai.com/docs/errors.md)
