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

# Authentication

> How to authenticate with the Dot Prediction API.

## API Key

All data endpoints require an API key. Pass it via header:

```bash theme={null}
curl https://api.dotprediction.io/v1/api/markets?provider=polymarket \
  -H "X-API-Key: YOUR_API_KEY"
```

Alternatively, use `Authorization: Bearer YOUR_API_KEY`.

## Creating an API Key

1. Register or log in to get a session cookie
2. Create a key:

```bash theme={null}
curl -X POST https://api.dotprediction.io/v1/api/auth/api-keys \
  -H "Content-Type: application/json" \
  -b "jwt=YOUR_SESSION_COOKIE" \
  -d '{"name": "production-key"}'
```

Save the `key` from the response immediately -- it cannot be retrieved later.

## Managing Keys

| Action     | Method   | Endpoint                     |
| ---------- | -------- | ---------------------------- |
| List keys  | `GET`    | `/v1/api/auth/api-keys`      |
| Revoke key | `DELETE` | `/v1/api/auth/api-keys/{id}` |

Both require session authentication via the `jwt` cookie.

## Session Auth

Account management endpoints use JWT cookie-based sessions. A session is set automatically on register (`POST /v1/api/auth/register`) or login (`POST /v1/api/auth/login`). Google OAuth is also supported via `GET /v1/api/auth/google`.

## Error Responses

| Status | Meaning                              |
| ------ | ------------------------------------ |
| `401`  | Missing or invalid API key / session |
| `429`  | Rate limit exceeded                  |
