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

# Create and use an API key

> How to get a SafeConduct API key, where to send it in each API format, and how to revoke it.

Every request to SafeConduct carries an API key. A key belongs to your account, spends your account's balance, and has its own [settings](https://docs.safeconduct.ai/settings.md).

## Create a key

**1. Sign in**

Open [safeconduct.ai](https://safeconduct.ai) and sign in. SafeConduct is invite-only for now: if you have no account, join the waitlist on the [sign-up page](https://safeconduct.ai/signup) and the invite arrives by email with your first API key.

**2. Open API keys**

In the console, go to [API keys](https://safeconduct.ai/keys).

**3. Name the key and create it**

Under **Create a key**, type a name that says what will use it, for example `tm-bot-eu`, and press **Create key**.

**4. Copy it now**

The full key is shown once. It starts with `sy_live_`. Copy it and keep it in an environment variable or a secret store; the console only shows its first characters afterwards.

> [!TIP]
>
> Use one key per bot or per environment. Each key has its own routing settings and its own daily cap, and the console shows what each one spent.

## Send the key

| API format | Where the key goes |
| - | - |
| Native API (`/v1/...`) | The `Authorization: Bearer` header, or `X-API-Key` where that header can't be set |
| createTask format | `clientKey` in the JSON body |
| 2Captcha format (`in.php`, `res.php`) | The `key` parameter |

To check that a key works, read your balance. It costs nothing.

```bash curl theme={null}
curl https://api.safeconduct.ai/v1/balance \
  -H "Authorization: Bearer $SAFECONDUCT_KEY"
```

```python Python theme={null}
import os, requests

r = requests.get(
    "https://api.safeconduct.ai/v1/balance",
    headers={"Authorization": f"Bearer {os.environ['SAFECONDUCT_KEY']}"},
)
print(r.json())
```

```javascript Node.js theme={null}
const res = await fetch("https://api.safeconduct.ai/v1/balance", {
  headers: { Authorization: `Bearer ${process.env.SAFECONDUCT_KEY}` },
});
console.log(await res.json());
```

A missing, wrong or revoked key gets `401` with the code `UNAUTHORIZED`.

## Keep it safe

* **Set a daily cap.** A key without one can spend the whole balance if it leaks. The cap is one of the key's [settings](https://docs.safeconduct.ai/settings.md#daily-cap).
* **Don't put it in code you publish**, in a browser page or in a URL you log. The 2Captcha format carries the key in the request's parameters, so prefer the form body to the query string there.

## Revoke a key

On [API keys](https://safeconduct.ai/keys), open the key and revoke it. It stops working within 30 seconds, for good. Tasks already running finish and are billed normally. Create a new key to replace it; a revoked key can't be brought back.


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