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

# API keys

> Create, list and revoke keys.

You can manage keys on your [account page](https://datachad.xyz/account) or through the API. Each account can hold up to 20 active keys.

## Create a key

```bash
curl -X POST https://api.datachad.xyz/v1/keys \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "training cluster"}'
```

```json
{
  "id": 3,
  "name": "training cluster",
  "prefix": "dc_live_f878c6",
  "key": "dc_live_f878c6..."
}
```

The `key` field appears in this response only. datachad stores a hash of the key, so nobody can show it to you again.

## List keys

```bash
curl https://api.datachad.xyz/v1/keys -H "Authorization: Bearer $TOKEN"
```

Each entry shows the key's `prefix`, when it was created and when it was last used. Use `last_used_at` to find keys that are safe to retire.

## Revoke a key

```bash
curl -X DELETE https://api.datachad.xyz/v1/keys/3 -H "Authorization: Bearer $TOKEN"
```

Revocation takes effect immediately. Requests with a revoked key get `401`.

## Rotate a key

1. Create a new key.
2. Deploy the new key to your systems.
3. Check `last_used_at` on the old key to confirm nothing still uses it.
4. Revoke the old key.
