# Authentication

> For AI agents: the index of these docs is at https://scrapelyserp.com/docs/llms.txt (every page it lists has a Markdown version like this one).

Every request carries an API key from your dashboard. Keys belong to the account, spend its balance, and can be revoked one at a time.

## API keys {#api-keys}

Create and revoke keys under **Dashboard → Developers → API keys**. A key looks like `sk_live_…` and is shown in full once, when you create it.

- Every key spends the same account balance and sees the same watchlists, webhook endpoints and export settings.
- Use one key per environment or service, so you can revoke one without touching the others.
- The request rate limit counts per key; concurrency is per account ([Rate limits & concurrency](/docs/rate-limits)).

:::hint{style="warning" title="Keep keys server-side"}
A key spends your credits. Never put one in browser or mobile code: call Scrapely from your backend and read the key from an environment variable.
:::

## Sending the key {#sending-the-key}

| Method | Example | When |
| --- | --- | --- |
| Bearer header | `Authorization: Bearer sk_live_…` | Recommended. |
| API key header | `X-API-Key: sk_live_…` | For clients that reserve `Authorization`. |
| Query parameter | `?api_key=sk_live_…` | Only for clients that cannot set headers: query strings end up in logs. |

`GET /v1/platforms` and the OpenAPI document are public; everything else needs a key. A cheap way to check one is `GET /v1/account`, which is free and returns the balance.

:::codeGroup{syncKey="lang"}
```bash title="cURL"
curl "https://api.scrapelyserp.com/v1/account" \
  -H "Authorization: Bearer $SCRAPELY_API_KEY"
```
```python title="Python"
import os
import requests

HEADERS = {"Authorization": f"Bearer {os.environ['SCRAPELY_API_KEY']}"}

r = requests.get(
    "https://api.scrapelyserp.com/v1/account",
    headers=HEADERS,
    timeout=30,
)
r.raise_for_status()
data = r.json()
print(data["balance"])
```
```javascript title="Node.js"
const res = await fetch('https://api.scrapelyserp.com/v1/account', {
  headers: { Authorization: `Bearer ${process.env.SCRAPELY_API_KEY}` },
  signal: AbortSignal.timeout(30_000),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
console.log(data.balance);
```
:::

**Full reference →** [`GET /v1/account`](/reference/account#get-account)

## When authentication fails {#failures}

| Answer | Means |
| --- | --- |
| `401 UNAUTHORIZED` | No key, or the key is unknown or revoked. Nothing was charged. |
| `403 DEMO_READ_ONLY` | The key belongs to the public, read-only demo workspace. Use your own account's key. |
| `429 RATE_LIMITED` | Too many calls (or repeated failures) in a short window. Honour `Retry-After`. |

---

## For AI agents

- This page for a human reader: https://scrapelyserp.com/docs/authentication
- The whole space as one Markdown file: https://scrapelyserp.com/docs/llms-full.txt
- Live search + fetch over MCP: https://scrapelyserp.com/docs/_api/public/orgs/affc5b0f-d3c2-423a-8143-9d10db5736ae/spaces/981e6275-da3f-446c-82de-889f59c83b6f/mcp
  - Install (Claude CLI): `claude mcp add scrapely --transport http https://scrapelyserp.com/docs/_api/public/orgs/affc5b0f-d3c2-423a-8143-9d10db5736ae/spaces/981e6275-da3f-446c-82de-889f59c83b6f/mcp`

This Markdown is the same content the page renders — safe to quote and to ground answers in.
