Skip to main content
Use the buy endpoints to purchase cryptocurrency with fiat and credit it directly to your PeerPesa wallet balance. Buy is different from the onramp flow: buy credits your PeerPesa balance, while onramp delivers crypto to an external wallet. The flow is two steps: first request a locked quote with your desired fiat amount and payment method, then execute the quote. Quotes lock the rate and fees for exactly 30 minutes.
All requests require an Authorization: Bearer <token> header. POST endpoints also accept an optional Idempotency-Key header to prevent duplicate transactions. Amounts are decimal strings. Network codes are uppercase as returned by GET /currencies: STELLAR, CELO, BITCOIN.

Generate a buy quote

Request a quote for buying crypto with fiat. The returned quote is locked for 30 minutes.

Endpoint

Request headers

string
required
Bearer token
string
Optional unique key to prevent duplicate quote creation

Request body

string
required
Crypto token to buy, e.g. USDC, USDT, BTC
string
required
Blockchain network, e.g. STELLAR, CELO, BITCOIN
string
required
Fiat currency to pay with, e.g. KES, TZS, NGN, ZAR, ZMW
string
required
Amount as a decimal string
string
required
Currency of the amount: fiat or crypto
string
required
Payment method: mobile_money or bank_transfer

Response fields

string
Quote ID, e.g. bq_...
string
Crypto symbol
string
Network code
string
Fiat currency used
string
Fiat amount to pay
string
Crypto amount you will receive
string
Exchange rate used (fiat per crypto unit)
object
Fee breakdown:
string
Payment method
string
ISO 8601 timestamp. Quote expires 30 minutes after created_at.
string
ISO 8601 timestamp

Example request

Example response


Execute a buy

Execute a previously generated buy quote to create a pending buy transaction. Payment instructions are returned in the response.

Endpoint

Request headers

string
required
Bearer token
string
Optional unique key to prevent duplicate execution

Request body

string
required
ID of the buy quote to execute, e.g. bq_2vT8xKpQrLmN9wZc
object
Payer details. Required for mobile_money.
string
Optional external reference string

Response fields

The response is a wallet transaction object with extra fields for payment instructions.
string
Transaction ID, e.g. txn_...
string
Always buy
string
pending until payment is received, then processing or completed
string
Crypto symbol
string
Network code
string
Crypto amount purchased
object
Fee breakdown as in the quote
string
Net crypto amount credited after fees
string
External reference if provided
string
On-chain transaction hash (null until completed)
object
Instructions for completing payment:
string
ISO 8601 timestamp
string
ISO 8601 timestamp

Example request

Example response

After execution, complete the payment using the returned instructions. Your balance is credited once the payment is received. Track progress with GET /orders/{order_id} or listen for webhook events transaction.processing, transaction.completed, and transaction.failed.

Error codes


Step-by-step flow

1

Request a quote

Call POST /wallet/buy/quote with your desired crypto, network, fiat amount, and payment method.
2

Review the quote

Check the rate, fee, and crypto_amount. The quote is valid for 30 minutes from created_at.
3

Execute the quote

Call POST /wallet/buy with the quote_id. Include payer.phone_number for mobile money.
4

Complete payment

Follow the payment_instructions in the response. Bank transfers require the provided reference.
5

Track completion

Poll GET /orders/{order_id} or wait for webhook events.