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

# API keys

> How keys work, how to send them, rotate them and keep them safe.

## How keys work

* Each billing plan of a project comes with **one key**: one for its subscription, or one for
  pay-as-you-go. The key carries the plan's limits (requests per second, balance or allowance).
* Keys look like `bl_live_` followed by 32 characters.
* A key is shown **once**, when it's created. Bloklake stores only a hash of it; nobody,
  including us, can show it again.
* **One key works on every chain.**
* Sets and prepared queries belong to the **project**, so every key of the project shares
  them, and a rotated key keeps working with them.

![The API keys page](https://mintcdn.com/my-company-7009db77/AEOzPZjunXHOKyLs/images/dashboard/api-keys.png?fit=max\&auto=format\&n=AEOzPZjunXHOKyLs\&q=85\&s=5ef7c33fac5439ea584f528a1876736d)

## Sending the key

```bash theme={null}
curl https://api.bloklake.com/v1/chains/eth/query -H "Authorization: Bearer $BLOKLAKE_API_KEY" …
```

`Authorization: Bearer <key>` is preferred. `x-api-key: <key>` and `X-BL-Api-Key: <key>` work too.
Keys are only accepted in headers, never in the URL.

`/status`, `/v1/schema` and `/healthz` don't need a key. [`GET /v1/account`](https://docs.bloklake.com/api-reference/account)
takes a key but is free: use it to check a key's plan, limit and balance.

## Rotating a key

On **API keys**, **Rotate** issues a new key on the same plan and revokes the old one at once:
requests still using it get `401 key_revoked` until you switch them to the new key. The new key
is shown once; copy it before closing the dialog.

Have the new key's deployment ready before you rotate, or rotate when a short interruption is
acceptable. If a key leaked, rotate right away.

## Deleting a key

**Delete** revokes the key immediately; requests with it get `401 key_revoked`. On
pay-as-you-go, deleting the key is also how you switch the project to a subscription; see
[Subscriptions](https://docs.bloklake.com/billing/subscriptions.md#switching-from-pay-as-you-go).

## Key status

| Status | Meaning | API answer |
| - | - | - |
| active | works | — |
| suspended | the subscription's payment is overdue past the grace period | `403 key_suspended` |
| revoked | deleted, rotated, or its subscription ended | `401 key_revoked` |

## Per-key analytics

Click a key to see its current request rate against its limit, data and spend for 24 hours and
30 days, and its charts by chain. The key list shows when each key was last used.

![A key's analytics page](https://mintcdn.com/my-company-7009db77/AEOzPZjunXHOKyLs/images/dashboard/key-detail.png?fit=max\&auto=format\&n=AEOzPZjunXHOKyLs\&q=85\&s=184f69d309caecb3143d202e369f7f3a)

## Keeping keys safe

* **Never put a key in a browser, mobile app or public repository.** Anyone with it can spend your
  balance or allowance. Call Bloklake from your servers. (The API doesn't send CORS headers, so
  browsers can't call it directly anyway.)
* Keep keys in a secret manager or environment variables, not in code.
* Give each service its own project if you want separate keys, limits and usage.
* If a key leaks, rotate it right away.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.