# Authentication (/fr/docs/authentication)

Every request carries your key in the `Authorization` header:

```bash
curl https://api-sandbox.caibopay.app/v1/account \
  -H "Authorization: Bearer psp_test_..."
```

## Your keys [#your-keys]

| | Sandbox | Live |
| --- | --- | --- |
| Format | `psp_test_<prefix>_<secret>` | `psp_live_<prefix>_<secret>` |
| Works on | `api-sandbox.caibopay.app` | `api.caibopay.app` |

- **You create them in the dashboard**, in **Developers → API keys**: a name, read or read and write, and the key is created in the mode you're in (test or live). You revoke them there too, and a revoked key stops working at once. Only a signed-in member whose role writes (owner, admin, developer) manages keys; an API key never creates or revokes another key. Up to 20 active keys per account.
- **Live keys wait for your company's verification.** If you opened your account yourself, sandbox works at once, and live keys are created once your company's verification is approved (see [Go live](/docs/go-live)).
- **They're shown only once.** Caibo stores only a fingerprint of the key, not the key itself. Store it in your secrets manager.
- **One key, one environment.** A sandbox key sent to live (or the other way around) is rejected just like an invalid key.
- The **prefix** (the 12 characters after `psp_test_`) identifies the key without revealing it: it's what you see in `GET /v1/account` and in the dashboard, under Developers.

## Permissions (scopes) [#permissions-scopes]

| Scope | Allows |
| --- | --- |
| `read` | All queries (`GET`). |
| `write` | Creating, changing, and moving money. |

A key can have one or both. Use a read-only key for dashboards and reports.

## The key you're using [#the-key-youre-using]

<Endpoint method="GET" path="/v1/account" href="/api#tag/account/GET/v1/account" />

`GET /v1/account` returns your account (`environment`, `primary_treasury_asset`…) and, in `credential`, the key that made the request: its `prefix`, its `scopes`, and its `expires_at` if it expires. The secret is never returned.

## Allowed IP addresses (required) [#allowed-ip-addresses-required]

**Your API keys move money only from IP addresses you registered.** It is mandatory: until your account has an active address, a key can read everything and receive money, but every request that moves money is refused, and from any other address it is refused too. A key that leaks is useless to an attacker on another machine.

| Requests that move money | Always open from anywhere |
| --- | --- |
| `POST /v1/payouts`, `POST /v1/payout-batches`, `POST /v1/withdrawals`, `POST /v1/remittances`, `POST /v1/refunds`, `POST /v1/conversions`, `POST /v1/customer-transfers`, `POST /v1/financial-accounts`, `POST /v1/wallets/{id}/transfers`, `POST /v1/wallets/{id}/offramps`, `POST /v1/wallet-operations/{id}/signature` | every `GET`; money coming in (funding accounts, hosted sessions); cancellations; quotes; customers, beneficiaries and settlement destinations |

- **Add your servers' addresses in the dashboard**, in **Settings → Allowed IPs**: an IPv4 or IPv6 address, or a network up to a `/24` (IPv4) or a `/48` (IPv6). An owner or admin adds them, confirming their second factor (or their password or passkey if they have none) again. **At most 3 allowed IPs per account**: to add another, remove one.
- **A new address takes effect at once**, with no wait, and your owners and admins get an e-mail and the event `allowed_ip.added` at once: if it wasn't one of you, remove it. **Removing is immediate**, from the dashboard or with `DELETE /v1/allowed-ips/{id}`.
- **Which address do we see?** `GET /v1/allowed-ip-policy` with your key answers it in `request_ip`: call it from the server that will move money.
- **Every refusal is logged** and your owners and admins are told (the event `api_key.ip_refused` and an e-mail, at most once every 15 minutes per key and address).
- **Sandbox** follows the same rule. While you build, an owner or admin can relax it in sandbox only (Settings → Allowed IPs); live is always enforced.

```json title="403 — no allowed address yet, or another address"
{
  "error": {
    "type": "permission_error",
    "code": "ip_not_allowed",
    "message": "This request came from 198.51.100.9, which is not one of this account's allowed IP addresses, and an API key moves money only from those. ...",
    "request_id": "req_6d665507f62a5773882fc053"
  }
}
```

## Authentication errors [#authentication-errors]

```json title="401 — key missing, invalid, revoked, expired, or from another environment"
{
  "error": {
    "type": "authentication_error",
    "code": "invalid_api_key",
    "message": "The API key is missing or not valid.",
    "request_id": "req_6d665507f62a5773882fc053"
  }
}
```

```json title="403 — the key doesn't have the scope"
{
  "error": {
    "type": "permission_error",
    "code": "insufficient_scope",
    "message": "This API key does not have the write scope.",
    "request_id": "req_6d665507f62a5773882fc053"
  }
}
```

<Callout type="warn" title="Never in the browser or in an app">
Your key moves money. Use it only from your server. If your customer needs to pay from their browser, create the pay-in on your server and show them the instructions, or use a [hosted page](/docs/hosted-pages).
</Callout>
