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
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
Passtime_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.time_range, or omitting end_time inside it, both mean “no cutoff” — the current balance.
Connector balances
Setinclude_connector_balances: true to also return the live balances of connector accounts, such as an M-Pesa payout paybill:
It is opt-in because it is slow
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.Not every account is visible
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.An unreachable account is silently omitted
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.
time_range does not apply
time_range does not apply
Connector balances are always live. Asking for a past
end_time changes the wallet balances but not connector_balances.balance is a string, in major units
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 anentry_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.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
Reading running_balance as major units
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.
Expecting a currency that is not there
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.Using the connector balance as your available funds
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.Wrong profile_id
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
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.