Skip to main content
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.
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 below.

Request

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

Response

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.
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:
Things to know before you rely on this:
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.
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.
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.
Connector balances are always live. Asking for a past end_time changes the wallet balances but not connector_balances.
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:
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

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.
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.
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.
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

Payouts

Send money out of the wallet.

Refunds

Send money back to a payer.

Reconciliation

How statements are matched against your transactions.

Quickstart

The full create-and-poll payment loop.