> Documentation index: https://docs.scrapier.io/llms.txt
> Auth: header `X-API-Key: <key>` · Base: https://api.scrapier.io/api/v2 · Synchronous; paginate with `cursor` ← `data.next_cursor`.

# Authentication

Send your API key in the X-API-Key header on every request; that is the only way the REST API accepts it.

Every request to `https://api.scrapier.io/api/v2` must carry your API key in the `X-API-Key` header:

```bash
curl "https://api.scrapier.io/api/v2/me" \
  -H "X-API-Key: YOUR_API_KEY"
```

## Get a key

Create and revoke keys at [app.scrapier.io/dashboard/api-keys](https://app.scrapier.io/dashboard/api-keys). Keys start with `sk_live_`.

## Header only

- The REST API reads the key **only** from the `X-API-Key` header.
- Keys in the query string or the request body are ignored.
- Bearer tokens in the `Authorization` header are **not** accepted by the REST API. They work only with the [MCP server](https://docs.scrapier.io/ai/mcp.md).

## When the key is wrong

| Status | When                               | Body                                                                   |
| ------ | ---------------------------------- | ---------------------------------------------------------------------- |
| `401`  | The `X-API-Key` header is missing. | `{"error": "Missing HTTP_X_API_KEY header."}`                          |
| `403`  | The key is unknown or invalid.     | `{"detail": "Authentication service unavailable or invalid API key."}` |
| `403`  | The key was revoked.               | `{"detail": "API key has been revoked."}`                              |

These bodies have no `success` field, and the 403 uses `detail` rather than `error`. Read the message from `error ?? detail`. Details in [Errors](https://docs.scrapier.io/errors.md).

Check a key at any time with the free [`GET /me`](https://docs.scrapier.io/discovery.md) endpoint.

> **Never ship your key to a browser or app:** The API allows cross-origin requests, so a browser _can_ call it directly. That's exactly why you shouldn't: anyone who opens your page or unpacks your app can read an `sk_live_` key and spend your credits. Call Scrapier from your server, a serverless function or an automation tool, and keep the key in an environment variable such as `SCRAPIER_API_KEY`.

## If a key leaks

Revoke it in the [dashboard](https://app.scrapier.io/dashboard/api-keys) and create a new one. Revoked keys get `403` straight away.
