# Authentication

> Authenticate API calls with an API key or an OAuth access token, see what each auth error means, and read the rate limit headers of every response.

Every request to `https://promptgale.com/v1` needs an API key or an OAuth access token.

## API keys

Create a key in the dashboard under API keys. Keys start with `pk_live_`. We store only a hash, so a lost key cannot be recovered: revoke it and create a new one.

Send the key in either header. They are equivalent; send one.

```http
Authorization: Bearer pk_live_...
```

```http
X-API-Key: pk_live_...
```

The samples in these docs read the key from the `PROMPTGALE_API_KEY` environment variable.

## What an auth failure looks like

| Situation | Status | Code |
| --- | --- | --- |
| No key in the request | 401 | `MISSING_API_KEY` |
| Unknown or revoked key | 401 | `INVALID_API_KEY` |
| Read-only token on a route that creates or cancels work | 403 | `FORBIDDEN` |

Every 401 carries `WWW-Authenticate: Bearer realm="promptgale"`.

## OAuth access tokens

Apps that act for a user can use OAuth instead of a key: `Authorization: Bearer pgo_at_...`.

- Flow: authorization code with PKCE, asking for `resource=https://promptgale.com/v1`.
- Discovery: `/.well-known/oauth-protected-resource/v1`.
- Scope `mcp:read` reads. Scope `mcp` also creates and cancels tasks, grids and batches.

API keys have full access. Browsers may call the API directly (CORS, no cookies).

## Rate limits

Each API key may send a set number of requests per minute (600 by default). Every response carries `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`. Over the limit you get 429 `RATE_LIMITED` with `Retry-After` in seconds.

---

Docs index: https://promptgale.com/llms.txt · Full reference: https://promptgale.com/llms-full.txt · OpenAPI: https://promptgale.com/v1/openapi.json
