/api path, with the same request and response shapes as before.
If you are building a new integration, do not use these endpoints. Use the main API instead, starting with the Payouts guide.
All examples below use the sandbox URL.
Request field names are PascalCase (
TransactionExternalId, PhoneNumber). MerchantIdentifier is accepted on every endpoint so existing integrations keep working, but it is not used. Your merchant account always comes from your access token.Authentication
Get a token
POST /api/tokenization exchanges your consumer key and API key for an access token.
Response
200
expiry is the time it stops working, in RFC 2822 format. Request a new token before then.
Errors
Send the token
Send the token in theAuthorization header on every other call. Send it as is, with no prefix. A Bearer prefix is also accepted.
401. An API key that is revoked or expires after you got the token also makes the token stop working.
Collections
POST /api/collection-payment asks a customer to pay from their mobile wallet. For M-Pesa, the customer gets an STK push prompt on their phone.
Response
200
GET /api/transactions/detail.
Errors
Refunds
POST /api/refund refunds a collection in full.
There is no amount field. The full amount of the collection is refunded.
Response
200
Refunds do not show up in
GET /api/transactions/detail. To see a refund’s status, use GET /api/transactions/list with a date range.Balance
There are three balance endpoints:/api/balanceand/api/balance/v2return the live balances of your connector accounts, such as your M-Pesa paybill or your Airtel account. Balances are fetched from each provider on every call, so a call can take a few seconds./api/balance/v3returns your Pesaswap wallet balance: the balance your payouts are checked against. No provider is called. Use v3 if you need to know whether you can send a payout.
Query parameters
GET /api/balance
200
Fields with no value are left out of the item.
/api/balance ignores Processor, and its mtnBalance and choicebankBalance lists are always empty. Use v2 for MTN and Choice Bank.
GET /api/balance/v2
200
How v2 differs from
/api/balance:
- v2 includes Choice Bank and MTN accounts.
/api/balancedoes not. - v2 honours
Processor./api/balanceignores it. - v2 returns one block per account with the balance as a number.
/api/balancegroups accounts by processor with the balance as a string.
v1 and v2: if a provider cannot be reached, that account is left out and the rest of the response still returns. A missing account does not mean a zero balance.
GET /api/balance/v3
Returns your Pesaswap wallet balance in the format of the original Pesaswap platform.200
- The balance can be negative.
- A currency you have never transacted in returns
0for every amount, not an error. - The fee totals are gross: fees on a payout that was later reversed are still counted, and the refunded fee shows up in your balance instead.
/api/balance and v2:
- v3 returns your Pesaswap wallet balance. v1 and v2 return your connector account balances at each provider.
- v3 does not call any provider, so it is fast and always returns a value.
/api/balanceand/api/balance/v2are unchanged.
Payouts
POST /api/disbursement-payment sends money from your Pesaswap wallet. The Processor field decides where it goes:
Every successful payout request returns the same response:
Response
200
GET /api/transactions/detail.
Mobile money
Bank
Bank payouts use the same endpoint and the same common fields as mobile money.PhoneNumber is optional. The Processor value picks the kind of bank payout, and each kind needs its own extra fields. All bank payouts are sent through Choice Bank.
Common fields
Fields per
Processor
A field that is missing, or sent as an empty or blank string, is rejected.
PesaLink example
Paybill example
Paytill example
Bank codes
Use these codes inBankCode for pesalink payouts. These are the banks Choice Bank can pay.
Only the codes in this table are accepted. Any other code, including the older
80 (Habib Bank AG Zurich) and 83 (Access Bank), is rejected with Invalid BankCode. Use 17 and 26 for those banks.IMT through disbursement-payment
SetProcessor to choice-bank-imt-rails to send an IMT transfer to an M-Pesa account through Choice Bank. This uses its own set of fields. The amount is sent at a conversion rate of 1, in the currency you give.
Other fields, such as
PhoneNumber, Country, PayeeBankCode or PayeeType, are ignored for this Processor. To send the sender’s details and a conversion rate, use POST /api/choice-bank/imt-rails-transfer instead.
Payout errors
All errors have the body{"error":"<message>"}.
IMT transfer
POST /api/choice-bank/imt-rails-transfer sends an IMT payout to an M-Pesa account through Choice Bank, with the sender’s details and a conversion rate.
Response
200
400 with {"error":{"error_type":"invalid_request","message":"...","code":"IR_06"}}.
Transaction status
Status is reported as a number in/detail and as text in /list and in callbacks:
Transaction detail
GET /api/transactions/detail returns one collection or payout by its TransactionExternalId. It looks for a collection first, then a payout. Pesaswap asks the provider for the latest status during the call.
Response
200
If the provider cannot be reached during the call, a payout is returned with the last status Pesaswap holds.
Errors
“Not found” returns status
400, not 404.List transactions
GET /api/transactions/list returns collections, refunds and payouts. It takes a JSON body on a GET request, as the old platform did.
Results are sorted newest first. For a date range, at most 100 collections, 100 refunds and 100 payouts are read, and
Skip and Take apply after that. If you have more than that in a range, use a shorter range.
Response 200
Errors
A
TransactionExternalId that matches nothing returns 200 with "count": 0.
Callbacks
When a collection or payout changes status, Pesaswap calls your callback URL. Pesaswap sets the callback URL on your account. The callback is an HTTPGET request. The payload is a JSON object, URL-encoded, in the data query parameter:
data looks like this:
Callback field names are snake_case, unlike the PascalCase request fields.
Verify a callback
Each callback carries anAuthorization header, and a Signature header if a signing key is set up for your account. The keys used below are set up on your account by Pesaswap. consumer_key is your merchant identifier.
Authorization is Basic followed by base64 of one of these, depending on how your account is set up:
consumer_key:api_keyconsumer_key:api_key:transaction_external_id:amount(extended mode)
Signature is a lowercase hex SHA-256 digest, built like this:
auth = base64(consumer_key + api_key + signing_key)body = base64(id + transaction_external_id + amount + status + processor), using the values fromdataexactly as sent (idas decimal digits,amountwith two decimals)Signature = hex(sha256(auth + body))
Errors
Errors from these endpoints use this shape:
On every endpoint except
/api/disbursement-payment, a body that is not valid JSON, has a missing or wrongly typed field, or is sent without Content-Type: application/json is rejected before it reaches the legacy handler. That error has a different shape:
message names fields in snake_case (phone_number), not in the PascalCase you send.