# Wallets (/fr/docs/wallets)

<Callout type="warn" title="Preview">
Wallets are in preview, in the sandbox, on a test network. Caibo enables them account by account: until then every route answers `403 not_entitled`.
</Callout>

A wallet is a smart account of your company on the network, holding **USDC**. Caibo never holds a key, a seed or a share of one: it computes the wallet, builds what is to be signed, checks it, pays the network fee and follows it on chain. A payment your keys signed within your limits is never held or delayed by Caibo.

You keep two keys (secp256k1):

| Key | What it does | Where you keep it |
| --- | --- | --- |
| **Owner** | Controls the wallet without limits: activates it, and later changes its limits. | Offline, or in your dashboard. |
| **API key** | Signs payments from your server, **only within the wallet's limits**. It has its own account and never needs network fees. | Your own key store. It never leaves it. |

The limits are enforced by the network itself, not by Caibo: at most `per_transaction_max` per payment, at most `per_day_max` per UTC day (refilled each day), and only to the `recipients` you list or to Caibo's settlement address (off-ramps).

In your dashboard, **Settings → [Wallet spending caps](https://dashboard.caibopay.app/settings/wallet-limits)** shows each wallet's caps as the network enforces them, and a suggestion to start from.

## 1. Create the wallet [#1-create-the-wallet]

<Endpoint method="POST" path="/v1/wallets" href="/api#tag/wallets/POST/v1/wallets" />

```bash
curl "$CAIBO_API/v1/wallets" \
  -H "Authorization: Bearer $CAIBO_API_KEY" \
  -H "Idempotency-Key: wallet-main-1" \
  -H "Content-Type: application/json" \
  -d '{
    "owner_address": "0x1111111111111111111111111111111111111111",
    "api_key_address": "0x2222222222222222222222222222222222222222",
    "policy": {
      "per_transaction_max": "500",
      "per_day_max": "2000",
      "recipients": ["0x3333333333333333333333333333333333333333"]
    }
  }'
```

The answer has the wallet's `address` at once (status `counterfactual`): it can **receive USDC right away**, before anything is on chain. Creating touches no network and costs nothing.

## 2. Activate it with the owner key [#2-activate-it-with-the-owner-key]

<Endpoint method="POST" path="/v1/wallets/{id}/activation" href="/api#tag/wallets/POST/v1/wallets/{id}/activation" />

```bash
curl -X POST "$CAIBO_API/v1/wallets/wal_01m3sgb40000000000000000/activation" \
  -H "Authorization: Bearer $CAIBO_API_KEY"
```

The answer is a wallet operation in `requires_signature`. Its `signing` object holds the `digest` to sign, the key that must sign it (`signer_address`) and the whole operation, so your server can **recompute the digest and check what it signs** before signing. Sign the digest itself (no prefix), 65 bytes `r, s, v`, and send it:

<Endpoint method="POST" path="/v1/wallet-operations/{id}/signature" href="/api#tag/wallets/POST/v1/wallet-operations/{id}/signature" />

```bash
curl "$CAIBO_API/v1/wallet-operations/wop_01m3sgb40000000000000000/signature" \
  -H "Authorization: Bearer $CAIBO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "signature": "0x…" }'
```

When the network confirms it, the wallet is `active` and `wallet.activated` is published.

### Sign the digest on your server [#sign-the-digest-on-your-server]

The key signs `signing.digest` exactly as it comes (32 bytes, no message prefix), and the signature is `r`, `s` and `v` (27 or 28), 65 bytes as `0x` and 130 hex digits. Check `signing.signer_address` is the key you are about to use, and the operation is the one you asked for, before signing.

<Tabs items={["Node.js", "Python", "Go"]}>
<Tab value="Node.js">

```js
// npm install viem
import { serializeSignature, sign } from "viem/accounts";

// op: the wallet operation the API answered (status requires_signature).
const signature = serializeSignature(
  await sign({ hash: op.signing.digest, privateKey: process.env.WALLET_KEY }),
);

await fetch(`${process.env.CAIBO_API}/v1/wallet-operations/${op.id}/signature`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CAIBO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ signature }),
});
```

</Tab>
<Tab value="Python">

```python
# pip install eth-account requests
import os

import requests
from eth_account import Account

# op: the wallet operation the API answered (status requires_signature).
signed = Account.unsafe_sign_hash(op["signing"]["digest"], os.environ["WALLET_KEY"])
signature = "0x" + bytes(signed.signature).hex()  # r, s, v (27 or 28)

requests.post(
    f"{os.environ['CAIBO_API']}/v1/wallet-operations/{op['id']}/signature",
    headers={"Authorization": f"Bearer {os.environ['CAIBO_API_KEY']}"},
    json={"signature": signature},
)
```

</Tab>
<Tab value="Go">

```go
// go get github.com/ethereum/go-ethereum
import (
	"bytes"
	"encoding/json"
	"net/http"
	"os"

	"github.com/ethereum/go-ethereum/common/hexutil"
	"github.com/ethereum/go-ethereum/crypto"
)

// op: the wallet operation the API answered (status requires_signature).
key, err := crypto.HexToECDSA(os.Getenv("WALLET_KEY")) // hex, without 0x
if err != nil {
	return err
}
sig, err := crypto.Sign(hexutil.MustDecode(op.Signing.Digest), key)
if err != nil {
	return err
}
sig[64] += 27 // v: 27 or 28

body, _ := json.Marshal(map[string]string{"signature": hexutil.Encode(sig)})
req, _ := http.NewRequest("POST", os.Getenv("CAIBO_API")+"/v1/wallet-operations/"+op.ID+"/signature", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("CAIBO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
```

</Tab>
</Tabs>

The same three steps sign every operation: the activation with the owner key, and each payment and off-ramp with the API key.

## 3. Pay from the wallet with the API key [#3-pay-from-the-wallet-with-the-api-key]

Payments, off-ramps and signatures move money, so your API key is served only from your account's [allowed IP addresses](/docs/authentication#allowed-ip-addresses-required), like every other request that moves money. On chain, the wallet's own limits still hold whoever holds the key.

<Endpoint method="POST" path="/v1/wallets/{id}/transfers" href="/api#tag/wallets/POST/v1/wallets/{id}/transfers" />

```bash
curl "$CAIBO_API/v1/wallets/wal_01m3sgb40000000000000000/transfers" \
  -H "Authorization: Bearer $CAIBO_API_KEY" \
  -H "Idempotency-Key: supplier-invoice-118" \
  -H "Content-Type: application/json" \
  -d '{ "to": "0x3333333333333333333333333333333333333333", "amount": "120.00", "currency": "USDC" }'
```

Before anything is created, Caibo checks the payment against the wallet's limits as the network reads them now. Over a limit, it's `422 wallet_payment_refused` with the reason in `reasons` (`over_transaction_cap`, `over_period_cap`, `recipient_not_allowed`), and **nothing is created, signed or paid**. Otherwise sign `signing.digest` with the API key and send it as above.

## 4. Move USDC to your balance (off-ramp) [#4-move-usdc-to-your-balance-off-ramp]

<Endpoint method="POST" path="/v1/wallets/{id}/offramps" href="/api#tag/wallets/POST/v1/wallets/{id}/offramps" />

```bash
curl "$CAIBO_API/v1/wallets/wal_01m3sgb40000000000000000/offramps" \
  -H "Authorization: Bearer $CAIBO_API_KEY" \
  -H "Idempotency-Key: offramp-2026-11-26" \
  -H "Content-Type: application/json" \
  -d '{ "amount": "300.00", "currency": "USDC" }'
```

It pays Caibo's settlement address (`policy.settlement_address`) from the wallet. Once the network confirms it, the amount is credited to your available USDC balance (`wallet_operation.credited`), once, and pays out like any balance: [convert it](/docs/conversions) or [pay it out](/docs/payouts).

## Statuses of an operation [#statuses-of-an-operation]

| Status | What it means |
| --- | --- |
| `requires_signature` | Waiting for your key's signature, until `expires_at`. |
| `submitted` | Signed and sent to the network. |
| `confirmed` | Executed and final. |
| `failed` | Refused just before it was sent (nothing was paid), or reverted on chain. See `failure_reason`. |
| `expired` | Not signed, or not executed, in time. Nothing moved. |

Follow them with the `wallet.*` and `wallet_operation.*` [events](/docs/events).
