# Wallets

A **wallet** is Fynex's per-currency balance ledger for a seller account. Every settlement, payout, and split execution produces append-only ledger entries on the relevant wallet.

Wallets are available through the Payments REST API with your `Authorization: Bearer <seller_token>`. The API is seller-scoped and hides Fynex system wallets.

| Operation | Method & path |
|-----------|---------------|
| List the seller's wallets with balances | `GET /payments-api/v1/wallets?limit={n}&offset={n}` |
| Create a payee wallet in a currency | `POST /payments-api/v1/wallets` |
| Get a single wallet | `GET /payments-api/v1/wallets/{wallet_id}` |
| List a wallet's ledger transactions | `GET /payments-api/v1/wallets/{wallet_id}/transactions?limit={n}&offset={n}` |
| Fund a cashout wallet from the main balance | `POST /payments-api/v1/wallets/{wallet_id}/fund` |

`limit` is 1-100 (default 20); out-of-range or non-numeric values fall back to the default. All balance amounts are in **minor currency units** (`125000` = 1250.00 EUR).

---

## Wallet types

The `type` field describes the role of each wallet:

| Type | Purpose |
|------|---------|
| `main` | Where settled funds land |
| `cashout_balance` | A payee's payout-source balance; bound to one payee and funded from your `main` wallet in the same currency |
| `seller_operational` | Operational float held by the seller |

---

## Wallet object

`GET /wallets` returns `{ "wallets": [...], "total", "limit", "offset" }`; `GET /wallets/{wallet_id}` returns a single wallet.

| Field | Type | Description |
|-------|------|-------------|
| `id` | integer | Wallet ID |
| `payeeId` | integer | Payee the wallet is bound to (distinguishes multiple wallets in the same currency) |
| `type` | string | Wallet type, see above |
| `name` | string | Wallet name |
| `currency` | string | ISO 4217 settlement currency |
| `status` | string | Wallet status, for example `active` |
| `availableBalanceMinor` | integer | Settled funds not under hold. Spendable within the platform; `withdrawableBalanceMinor` is the part that can leave it today |
| `heldBalanceMinor` | integer | Funds reserved against an in-flight payout; released back to available if the payout fails. This is separate from maturity holds; see [Holds](https://docs.fynex.ai/payments-api/v2/docs#tag/holds) |
| `pendingBalanceMinor` | integer | Legacy field; stays `0`. Read `maturingBalanceMinor` instead |
| `withdrawableBalanceMinor` | integer | The part of `availableBalanceMinor` a payout can take now |
| `maturingBalanceMinor` | integer | Settled funds counted in available but still inside the payout maturity hold |
| `totalBalanceMinor` | integer | Available + held + pending |

### Withdrawable vs. maturing

Settled funds count in `availableBalanceMinor` straight away, but each settlement or split leg may remain under a **T+N business-day maturity hold** before it can be paid out. See [Holds](https://docs.fynex.ai/payments-api/v2/docs#tag/holds) for timing and limitations. Check `withdrawableBalanceMinor`, not `availableBalanceMinor`, before creating a payout.

Usually `withdrawableBalanceMinor + maturingBalanceMinor == availableBalanceMinor`, but withdrawable is floored at `0`, so after a debit that takes available below the maturing sum the two no longer add up. Do not rely on the equality.

---

## Create and fund a payee wallet

`POST /payments-api/v1/wallets` provisions a `cashout_balance` wallet for a payee. The seller account comes from your token, not the body.

```bash
curl -X POST https://api.fynex.ai/payments-api/v1/wallets \
  -H "Authorization: Bearer $FYNEX_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"currency": "EUR", "payeeId": 101}'
```

`currency` must be one of `EUR`, `GBP`, `USD`; `payeeId` is required. Provisioning is idempotent: asking again for the same payee and currency returns the existing wallet. The response is `{ "wallets": [ ... ] }`.

`POST /payments-api/v1/wallets/{wallet_id}/fund` tops up a `cashout_balance` wallet from your `main` wallet in the same currency. The body takes `amount` (a decimal string in major units, for example `"100.00"`) and an optional `idempotencyKey` so a retry does not fund twice. The response returns both `wallet` (the funded wallet) and `sourceWallet` (your main wallet after the debit). A Live `main` wallet whose balance is paid out through settlement payouts (card settlements land there) cannot fund a cashout wallet; the call answers `409`.

---

## Ledger transactions

`GET /payments-api/v1/wallets/{wallet_id}/transactions` returns `{ "transactions": [...], "total", "limit", "offset" }`.

| Field | Type | Description |
|-------|------|-------------|
| `id` | integer | Transaction ID |
| `walletId` | integer | Wallet the entry belongs to |
| `direction` | string | `credit` or `debit`. Direction is not in the sign of `amountMinor` |
| `kind` | string | Entry kind, for example `incoming_payment_processed` |
| `amountMinor` | integer | Unsigned magnitude of the entry |
| `currency` | string | ISO 4217 currency |
| `availableDeltaMinor` | integer | Signed change to the available balance |
| `heldDeltaMinor` | integer | Signed change to the held balance. A payout hold is a negative available delta and a positive held delta of the same magnitude |
| `balanceAfterMinor` | integer | Available balance after this entry. Running total; reconcile against it rather than re-summing deltas |
| `heldAfterMinor` | integer | Held balance after this entry |
| `reference` | string | Opaque correlation reference that embeds your payout or payment ID (for example `payout:9001:hold`); treat the format as subject to change |
| `occurredAt`, `createdAt` | string | RFC 3339 timestamps |

---

## Code samples

```bash
curl -s "https://api.fynex.ai/payments-api/v1/wallets?limit=20" \
  -H "Authorization: Bearer $FYNEX_TOKEN"
```

```javascript
const res = await fetch("https://api.fynex.ai/payments-api/v1/wallets?limit=20", {
  headers: { Authorization: `Bearer ${process.env.FYNEX_TOKEN}` },
});
const { wallets } = await res.json();
for (const w of wallets) {
  console.log(`${w.name} (${w.currency}): ${(w.withdrawableBalanceMinor / 100).toFixed(2)} withdrawable`);
}
```

```python
import os, requests

res = requests.get(
    "https://api.fynex.ai/payments-api/v1/wallets",
    params={"limit": 20},
    headers={"Authorization": f"Bearer {os.environ['FYNEX_TOKEN']}"},
)
res.raise_for_status()
for w in res.json()["wallets"]:
    print(f'{w["name"]} ({w["currency"]}): {w["withdrawableBalanceMinor"] / 100:.2f} withdrawable')
```

The samples divide by 100, which is correct for two-decimal currencies such as EUR, GBP and USD.

---

## Use cases

**Check withdrawable balance before requesting a payout.** Read `withdrawableBalanceMinor` on the wallet and compare it with the desired payout amount. If it is insufficient, the payout request is rejected.

**Reconcile balances against your own ledger.** Page through `/wallets/{wallet_id}/transactions` with `limit`/`offset`. Each entry's `balanceAfterMinor` should match your internal running balance.

> [!CAUTION]
> Balance amounts are always in **minor currency units** (for example cents). Never display raw minor-unit amounts to end users without converting them.

## See also

- **[Reconciliation](https://docs.fynex.ai/payments-api/v2/docs#tag/reconciliation)** — Match Fynex settlement records against your own books.
- **[Payouts](https://docs.fynex.ai/payments-api/v2/docs#tag/payouts)** — Request a wallet-to-payee transfer via the REST API.
- **[Holds](https://docs.fynex.ai/payments-api/v2/docs#tag/holds)** — Understand maturity holds and withdrawable balances.
