> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pesaswap.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Wallet balance

Every profile has a Pesaswap wallet. Money you collect lands in it, money you pay out leaves it, and fees are swept from it. `POST /wallet/balance` tells you what is in that wallet right now, per currency.

> [!NOTE]
>
> This is your Pesaswap wallet balance, not the balance of a connector account such as an M-Pesa paybill. The two are different numbers — see [Connector balances](#connector-balances) below.

## Request

`POST /wallet/balance` takes a `profile_id` and nothing else is required.

```bash curl theme={"system"}
curl --request POST \
  --url https://api.sandbox.pesaswap.io/wallet/balance \
  --header "api-key: {{api_key}}" \
  --header "Content-Type: application/json" \
  --data '{
    "profile_id": "{{profile_id}}"
  }'
```

```javascript Node.js theme={"system"}
const response = await fetch("https://api.sandbox.pesaswap.io/wallet/balance", {
  method: "POST",
  headers: {
    "api-key": "{{api_key}}",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    profile_id: "{{profile_id}}",
  }),
});

const balance = await response.json();
console.log(balance);
```

```python Python theme={"system"}
import requests

response = requests.post(
    "https://api.sandbox.pesaswap.io/wallet/balance",
    headers={
        "api-key": "{{api_key}}",
        "Content-Type": "application/json",
    },
    json={"profile_id": "{{profile_id}}"},
)

balance = response.json()
print(balance)
```

```php PHP theme={"system"}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.sandbox.pesaswap.io/wallet/balance",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "api-key: {{api_key}}",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "profile_id" => "{{profile_id}}",
    ]),
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

| Field | Required | What it does |
| - | - | - |
| `profile_id` | Yes | The profile whose wallet to read. Balances are per profile, not per merchant. |
| `time_range` | No | Point-in-time cutoff. Only `end_time` affects the result. |
| `include_connector_balances` | No | Also fetch live connector account balances. Defaults to `false`. |

## Response

```json theme={"system"}
{
  "merchant_id": "merchant_1767864525",
  "profile_id": "pro_OeiqmxKqV53ksl5WC5r1",
  "balances": [
    {
      "currency": "KES",
      "running_balance": 150000
    },
    {
      "currency": "USD",
      "running_balance": 4200
    }
  ]
}
```

> [!WARNING]
>
> `running_balance` is in **minor units**. `150000` with `currency: "KES"` means KES 1,500.00, not 150,000 shillings. Divide by 100 before showing it to anyone.

`balances` has one entry per currency the profile has ledger activity in. A currency you have never transacted in does not appear — treat a missing currency as zero, not as an error.

## Balance as of a past moment

Pass `time_range.end_time` to ask what the wallet held at a given instant. This is what you want for a month-end figure, or for checking a balance against a statement.

```bash theme={"system"}
curl --request POST \
  --url https://api.sandbox.pesaswap.io/wallet/balance \
  --header "api-key: {{api_key}}" \
  --header "Content-Type: application/json" \
  --data '{
    "profile_id": "{{profile_id}}",
    "time_range": {
      "start_time": "2026-10-01T00:00:00Z",
      "end_time": "2026-11-01T00:00:00Z"
    }
  }'
```

> [!NOTE]
>
> `start_time` is required by the shared date-range type but is **ignored** in this computation. The result is always a running balance from the beginning of the ledger up to `end_time` — never a sum of movements inside the window. If you want movements over a period, list the ledger entries instead.

Omitting `time_range`, or omitting `end_time` inside it, both mean "no cutoff" — the current balance.

## Connector balances

Set `include_connector_balances: true` to also return the live balances of connector accounts, such as an M-Pesa payout paybill:

```json theme={"system"}
{
  "merchant_id": "merchant_1767864525",
  "profile_id": "pro_OeiqmxKqV53ksl5WC5r1",
  "balances": [
    { "currency": "KES", "running_balance": 150000 }
  ],
  "connector_balances": [
    {
      "connector_name": "daraja",
      "account_name": "Utility Account",
      "short_code": "4319449",
      "currency": "KES",
      "balance": "28400.00",
      "account_status": 0
    }
  ]
}
```

Things to know before you rely on this:

> [accordion] It is opt-in because it is slow
>
> Connector balances are fetched live from the gateway on each call, which can take a few seconds. The default is `false` so a routine balance check stays fast.

> [accordion] Not every account is visible
>
> A Pesaswap admin decides which connector accounts a merchant can see. If none is visible for the profile, `connector_balances` is left out of the response entirely rather than returned empty.

> [accordion] An unreachable account is silently omitted
>
> If a connector cannot be reached, that account is dropped from the list and the rest of the response still returns. The call does not fail — the wallet balance is what you asked for. So never read a missing account as a zero balance.

> [accordion] time\_range does not apply
>
> Connector balances are always live. Asking for a past `end_time` changes the wallet `balances` but not `connector_balances`.

> [accordion] balance is a string, in major units
>
> Unlike `running_balance`, the connector `balance` field is a decimal string already formatted to two places (`"28400.00"`). Do not divide it by 100.

`account_status` comes straight from the connector: `0` normal, `1` locked, `2` closed.

## What moves the balance

The wallet balance is the running total of ledger entries. Each entry has an `entry_type`:

| `entry_type` | Direction | When it is written |
| - | - | - |
| `payin` | Credit | A payment from a customer succeeds |
| `payout` | Debit | A payout is sent |
| `refund` | Debit | A payment is refunded to a customer |
| `processor_fee` | Debit | The connector's own cost on a successful pay-in or payout |
| `gateway_fee` | Debit | The Pesaswap fee, swept on a successful pay-in or payout |
| `payout_tax` | Debit | Tax withheld from a payout |
| `fx_debit` | Debit | The source side of a currency conversion |
| `fx_credit` | Credit | The target side of a currency conversion |
| `manual_credit` | Credit | An adjustment made by Pesaswap |
| `manual_debit` | Debit | An adjustment made by Pesaswap |

> [!NOTE]
>
> `payout_tax` is the one fee taken **out of** the amount sent rather than charged on top: the recipient receives the payout minus the tax, while the wallet gives up the full requested amount.

To see the individual entries behind a balance, `POST /wallet/list` with the same `profile_id`. It accepts `entry_type`, `currency`, `connector`, `resource_id`, `time_range`, `limit` and `offset`, so you can trace a balance back to the payment, payout or refund that moved it.

## Common errors

> [accordion] Reading running\_balance as major units
>
> The single most common mistake. A dashboard showing "KES 150,000" when the real balance is KES 1,500.00 is a minor-unit bug, not a balance problem.

> [accordion] Expecting a currency that is not there
>
> `balances` only lists currencies with ledger activity. Code that reads `balances[0]` assuming it is KES will break for a profile whose first entry is in another currency. Look the currency up instead.

> [accordion] Using the connector balance as your available funds
>
> A connector paybill balance is the float sitting at the gateway. It is not your Pesaswap wallet balance and it is not what you can pay out. Use `balances` for that.

> [accordion] Wrong profile\_id
>
> Balances are scoped to a profile. A merchant with several profiles has a separate wallet for each, and querying the wrong one returns a valid but unrelated balance.

## Next steps

> [card] [Payouts](https://docs.pesaswap.io/essentials/payments-guide/payouts.md)
>
> Send money out of the wallet.

> [card] [Refunds](https://docs.pesaswap.io/essentials/payments-guide/refunds.md)
>
> Send money back to a payer.

> [card] [Reconciliation](https://docs.pesaswap.io/essentials/explore-pesaswap/payment-operations/reconciliation/overview.md)
>
> How statements are matched against your transactions.

> [card] [Quickstart](https://docs.pesaswap.io/essentials/payments-guide/quickstart.md)
>
> The full create-and-poll payment loop.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.