# AtmoRouter — Authentication

Source: https://atmorouter.dev/docs/authentication

Only endpoints that intentionally differ from the standard API carry a chip; the chip links to the note that explains the difference.

Pass your key as a bearer token. The `x-api-key` header is also accepted for clients that prefer it.

`/api/dashboard/register` `/api/dashboard/login` `/api/dashboard/keys` `/api/dashboard/keys/{id}`

Atmo keys stay on Atmo. Atmo keys carry the `ar-` prefix. An Atmo key works only here — keys are not portable to other gateways, and a key issued by another gateway does not work here.

Two credentials for two surfaces. Inference takes a Bearer `ar-` key (or `x-api-key`); the dashboard uses a session cookie instead. An `ar-` key never acts as a session, and a session cookie never authenticates inference.

```http
Authorization: Bearer ar-xxxxxxxxxxxx

# or
x-api-key: ar-xxxxxxxxxxxx
```

## Key properties

| Property | Meaning |
| --- | --- |
| prefix | Every key starts with ar- so it is easy to spot in logs and secret scanners. |
| rate_limit | Requests per minute for your whole account, counted across all your keys together. Omit the field and the key gets 500; an explicit value must be between 1 and 1000. Any other value (including 0 and negatives) is rejected with 400. |
| allowed_models | Optional allowlist of model ids. Calls to any other model are rejected with 403. |
| enabled | Keys carry no enable toggle: revoking deletes the key immediately (DELETE below), and the next call with it returns 401. There is no grace window. |

## Rate limits

Inference, playground and webhook limits renew every minute and answer `429` when spent. Inference limits are enforced per account, not per key — creating extra keys never multiplies your budget. A missing `rate_limit` becomes 500, while an explicit value must be between `1` and `1000`. Any other value (including `0` and negatives) is rejected with `400`; legacy keys still storing 0 or a negative are throttled at the 500 default.

| Surface | Limit | Scope | When exceeded |
| --- | --- | --- | --- |
| Inference (/v1/*) | Your key's rate_limit (default 500, valid 1..1000) | Per account, all keys combined | 429 without Retry-After, back off exponentially |
| Playground chat | 20 requests/min | Per signed-in user | 429 without Retry-After, back off exponentially |
| Webhooks (provider callbacks) | 30 requests/min | Per client IP | 429 with Retry-After, wait the stated seconds |
| Login and step-up checks | 20 tries per IP + 8 per account, each 15-min window | Per IP and per account; locks out 15 min | 429 with Retry-After, wait the stated seconds |
| Concurrency at low balance | Balance up to $0.05: 1 in flight; up to $0.25: 3 | Per account | 429 without Retry-After, let requests finish or top up |

## Managing keys from the API

The dashboard calls the same JSON API you can call yourself: log in once to fill a cookie jar, then create, list, check balance, and revoke. These endpoints take the session cookie (the login token also works as a bearer); API keys never work here.

```bash
# 1. Log in (the jar keeps the session cookie)
curl -c jar.txt https://atmorouter.dev/api/dashboard/login -H "Content-Type: application/json" -d '{"email":"you@example.com","password":"..."}'

# 2. Create a key (omit rate_limit for the 500/min default; explicit values must be 1..1000, anything else answers 400)
curl -b jar.txt https://atmorouter.dev/api/dashboard/keys -H "Content-Type: application/json" -d '{"name":"prod-app","rate_limit":500}'
# -> {"id":"...","key":"ar-...","message":"key created"} — save the key now, it is shown in full exactly once

# 3. List keys (previews only, never full secrets)
curl -b jar.txt https://atmorouter.dev/api/dashboard/keys

# 4. Check balance (for automation)
curl -b jar.txt https://atmorouter.dev/api/dashboard/balance
# -> {"balance":12.5}

# 5. Revoke a key (immediate; an unknown id, or one owned by someone else, answers 404)
curl -b jar.txt -X DELETE https://atmorouter.dev/api/dashboard/keys/{id}
# -> {"status":"ok"}
```

`POST` generates `ar-` plus 48 hex characters from 24 secure random bytes and returns the full secret once: lose it and you revoke and recreate, since `GET` only ever returns a 12-character preview per key. `DELETE` removes the key for your account immediately and answers `404` when the id is unknown or belongs to someone else, while a malformed id answers `400`. There is no rotate endpoint: to rotate, create the replacement first, then delete the old key.

## Good practice

Create one key per application rather than sharing a single key. Each request records which key made it, so separate keys let you revoke one without disrupting the others. The dashboard usage view aggregates per account today; a per-key cost breakdown is planned. Never commit a key to source control or ship it in client-side code. Anyone holding it can spend your balance.

What usage tracking records. The server stores the key id with each keyed request, but `GET /api/dashboard/usage` and `GET /api/dashboard/usage-stats` aggregate per account, with breakdowns by model and provider. Requests through the playground carry no key id by design.

A key is shown in full exactly once, at creation. If you lose it, revoke it and create a new one; we cannot recover the original value.

No rotation, revoke and recreate. There is no key-rotation endpoint: rotation with a 24-hour grace window is not available on Atmo today. You revoke the old key (`DELETE /api/dashboard/keys/{id}`) and create a new one; the old key stops working immediately, with no grace window.

## Account and session

These endpoints back signup, sign-in state, and account management in the dashboard. They use the session cookie, not an `ar-` key.

`POST /api/dashboard/resend-verification`  — Re-sends the signup verification email.

`POST /api/dashboard/complete-registration`  — Completes signup with the emailed token and a new password; returns no session, sign in afterwards.

`GET /api/dashboard/me`  — Returns the session's user id, email, and balance.

`POST /api/dashboard/reset-password`  — Changes the password with the current one; requires a signed-in session.

`POST /api/dashboard/logout`  — Destroys the session. POST only; other methods return 405.

`POST /api/dashboard/delete-account/request`  — Starts the three-step account-deletion flow with your password; the confirmation token follows by email.

`POST /api/dashboard/delete-account/confirm`  — Confirms deletion with the emailed token. Malformed or wrong tokens answer 400; the endpoint also carries a per-address and global hourly budget, so sustained attempts answer 429 with `Retry-After` and a `retry_after_seconds` field.

`POST /api/dashboard/delete-account/cancel`  — Cancels a pending deletion and restores the account and keys.
