# Customer balances (/docs/customer-balances)

A customer balance is money of yours **set apart for one of your [customers](/docs/customers)**, per currency, under your own account (FBO style). Nothing leaves Caibo when you move money between your balance and a customer's: your total stays the same, and what you hold for customers is always visible on its own.

| You want to… | You use |
| --- | --- |
| Open a customer's balance in a currency | `POST /v1/customers/{id}/balances` |
| Move money to or from a customer | `POST /v1/customer-transfers` |
| See what you hold for a customer | `GET /v1/customers/{id}/balances` |
| See what you hold for all of them | the `customers` figure of `GET /v1/balances` |

## 1. Open the balance [#1-open-the-balance]

<Endpoint method="POST" path="/v1/customers/{id}/balances" href="/api#tag/customer-balances/POST/v1/customers/{id}/balances" />

```bash
curl "$CAIBO_API/v1/customers/cus_01m3sgb40000000000000000/balances" \
  -H "Authorization: Bearer $CAIBO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "currency": "USDC" }'
```

```json
{
  "customer_id": "cus_01m3sgb40000000000000000",
  "currency": "USDC",
  "available": "0.000000"
}
```

It opens at zero. Opening one that already exists returns it as it is (`200`). Only an **active** customer gets a new balance. This step is optional: the first transfer to a customer in a currency opens the balance too.

## 2. Move money to the customer [#2-move-money-to-the-customer]

<Endpoint method="POST" path="/v1/customer-transfers" href="/api#tag/customer-balances/POST/v1/customer-transfers" />

```bash
curl "$CAIBO_API/v1/customer-transfers" \
  -H "Authorization: Bearer $CAIBO_API_KEY" \
  -H "Idempotency-Key: fund-customer-7731" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "cus_01m3sgb40000000000000000",
    "direction": "to_customer",
    "amount": "250.00",
    "currency": "USDC",
    "description": "Monthly allowance"
  }'
```

| Field | Description |
| --- | --- |
| `direction` | `to_customer`: from your available balance to the customer's. `from_customer`: back to yours. |
| `amount`, `currency` | What moves, as a decimal string. |
| `description` | Optional. Your own note, up to 200 characters. **No personal data.** |

An allowed transfer is `completed` when it's created: the money already moved. The side the money leaves must cover it (`422 insufficient_funds`).

## 3. Check the customer's balance [#3-check-the-customers-balance]

<Endpoint method="GET" path="/v1/customers/{id}/balances" href="/api#tag/customer-balances/GET/v1/customers/{id}/balances" />

```bash
curl "$CAIBO_API/v1/customers/cus_01m3sgb40000000000000000/balances" \
  -H "Authorization: Bearer $CAIBO_API_KEY"
```

Per currency, the `customers` figure of `GET /v1/balances` is exactly the sum of these balances over all your customers, and it's part of your `total`. See [Your balance](/docs/balances).

## Statuses [#statuses]

| Status | What it means |
| --- | --- |
| `completed` | The money moved. |
| `pending_review` | The risk controls asked a person to look; nothing has moved yet. Approved, the money moves then and it becomes `completed`; rejected, it fails with `risk_rejected`. |
| `failed` | Nothing moved. `failure_code`: `risk_rejected`, or, after an approval, `insufficient_funds` or `customer_not_active` if by then the side the money leaves no longer covers it or the customer was blocked or closed. |

Follow transfers with the `customer_transfer.created`, `customer_transfer.completed` and `customer_transfer.failed` [events](/docs/events).

## Rules to know [#rules-to-know]

- A **blocked or closed** customer receives and gives nothing (`422 customer_not_active`). A customer isn't closed while it holds a balance.
- Like a conversion, a transfer can be refused by a limit on your account (`422 limit_exceeded`), the risk controls (`422 risk_blocked`) or a pause (`503 operation_suspended`); then nothing moves.
- Repeating the request with the same `Idempotency-Key` returns the same transfer: it never moves twice.
