# Security (/docs/security)

Caibo Pay is built so that a single leaked secret is not enough to move your money. Each layer below works on its own; together they cover the key, the network, the notification and the wallet.

<Cards>
  <Card icon={<KeyRound />} title="Secret keys" href="/docs/authentication">
    One key per environment, with only the scopes it needs. Shown once, stored
    only as a fingerprint.
  </Card>
  <Card
    icon={<Globe2 />}
    title="Allowed IPs"
    href="/docs/authentication#allowed-ip-addresses-required"
  >
    A key moves money only from up to 3 addresses you registered. Required in
    live.
  </Card>
  <Card
    icon={<Webhook />}
    title="Signed webhooks"
    href="/docs/webhook-signatures"
  >
    Every notification carries an HMAC-SHA256 signature with a timestamp. Verify
    it before you trust it.
  </Card>
  <Card icon={<Wallet />} title="Non-custodial wallets" href="/docs/wallets">
    Caibo never holds a key, a seed or a share of one. The network enforces your
    limits.
  </Card>
</Cards>

## API keys [#api-keys]

|                      |                                                                                                                                                          |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Format**           | `psp_test_…` works only against sandbox, `psp_live_…` only against live. A key sent to the other environment is rejected like an invalid one.            |
| **Scopes**           | `read` (every `GET`) and `write` (creating, changing and moving money). Give each system only what it needs: a read-only key for reports and dashboards. |
| **Shown once**       | The secret is returned only when the key is created. Caibo stores a fingerprint, never the key.                                                          |
| **Who creates them** | A signed-in member whose role writes (owner, admin, developer). An API key never creates or revokes another key. At most 20 active keys per account.     |
| **Revocation**       | Immediate. Revoke from the dashboard (Developers → API keys) or with `POST /v1/api-keys/{id}/revoke`.                                                    |

<Callout type="warn" title="Server side only">
  A key moves money. Never put it in a browser, a mobile app, a repository or a
  log. If your customer pays from their browser, create the pay-in on your
  server, or use a [hosted page](/docs/hosted-pages).
</Callout>

## Allowed IP addresses [#allowed-ip-addresses]

An API key **moves money only from an address your account registered**. Reading and money coming in work from anywhere; payouts, batches, withdrawals, remittances, refunds, conversions, customer transfers, financial accounts and wallet payments do not.

<Steps>
<Step>
### Find the address Caibo sees [#find-the-address-caibo-sees]

Call `GET /v1/allowed-ip-policy` with your key, from the server that will move money. `request_ip` is the address to register.
</Step>
<Step>
### Register it (up to 3) [#register-it-up-to-3]

In the dashboard, **Settings → Allowed IPs**, an owner or admin adds an IPv4 or IPv6 address, or a network up to a `/24` (IPv4) or `/48` (IPv6), confirming their strongest factor again. It works **at once**, and every owner and admin gets an e-mail and the event `allowed_ip.added`.
</Step>
<Step>
### Watch the refusals [#watch-the-refusals]

A request from any other address is `403 ip_not_allowed` (`403 ip_allowlist_required` while there is none). Each refusal is logged and announced with the event `api_key.ip_refused` and an e-mail, at most once every 15 minutes per key and address.
</Step>
</Steps>

At most **3 addresses** per account (`409 too_many_allowed_ips`: remove one to add another). Wide ranges such as `0.0.0.0/0` are refused, and in live so are private, loopback and link-local addresses. In sandbox an owner or admin can relax the rule while you build; live always enforces it. Details in [Authentication](/docs/authentication#allowed-ip-addresses-required).

## Webhooks you can trust [#webhooks-you-can-trust]

Every delivery is signed with your endpoint's secret (`whsec_…`) in the `Psp-Signature` header:

```text
Psp-Signature: t=1790769600,v1=c0c9eaafdea23b0f8c992b380b286917c6459b0729b2496b8452fa695215e6b8
```

1. Compute HMAC-SHA256 over `t` + `.` + the **raw body**, with the full secret as the key.
2. Compare it with each `v1` in **constant time**.
3. Reject it when `t` is more than **5 minutes** away from your clock.
4. Store the event, answer `2xx` within 10 seconds, and process it once: skip any `Psp-Event-Id` you already handled.

Code ready to paste in Node.js, Python and Go: [Verify the signature](/docs/webhook-signatures). Endpoints must be `https`, public and on port 443. When you rotate the secret, both secrets sign for 24 hours so you never drop a delivery.

## Money that moves exactly once [#money-that-moves-exactly-once]

- **Idempotency.** Every request that moves money carries an `Idempotency-Key`. The same key with the same request returns the original result (`Idempotent-Replayed: true`); the same key with a different request is `409`. Keys never expire. See [Idempotency](/docs/idempotency).
- **Decimal strings.** Amounts are strings with exactly the precision of their currency, never floating-point numbers. See [Amounts and currencies](/docs/money).
- **Screening.** Payouts are screened against sanctions lists before any money moves, and again right before they are sent.

## Wallets only you control [#wallets-only-you-control]

Wallets are smart accounts of your company. **Caibo never holds a key, a seed or a share of one.** You keep the owner key offline and an API signing key on your server; the network itself enforces `per_transaction_max`, `per_day_max` and the list of recipients. Caibo builds what is to be signed, checks it and pays the network fee, and never holds or delays a payment your keys signed within your limits. See [Wallets](/docs/wallets).

## The dashboard [#the-dashboard]

- Members have a role: `owner`, `admin`, `developer` or `viewer`. Disabling a member takes effect at once.
- Sensitive changes, such as adding an allowed IP, ask the person to confirm their strongest factor again (`403 step_up_required` otherwise).

## Checklist before going live [#checklist-before-going-live]

<Accordions>
  <Accordion title="Keys">
    Live keys live only in your secrets manager. Each service has its own key
    with the smallest scope it needs. You know how to revoke one in under a
    minute.
  </Accordion>
  <Accordion title="Network">
    The addresses of the servers that move money are registered (at most 3).
    Your other servers use read-only keys.
  </Accordion>
  <Accordion title="Webhooks">
    You verify every signature against the raw body, reject old timestamps,
    answer 2xx fast and deduplicate by event id.
  </Accordion>
  <Accordion title="Retries">
    Every money request carries an Idempotency-Key derived from your own order
    or payout id, and a retry reuses it.
  </Accordion>
  <Accordion title="Alerts">
    Someone reads the e-mails for allowed_ip.added and api_key.ip_refused, or
    your system listens for those events.
  </Accordion>
</Accordions>

More in [Go live](/docs/go-live).
