M-Pesa API
M-Pesa API integration
Boldrails is a licensed payment-gateway provider that delivers M-Pesa collections and payouts through one API, built on Safaricom's Daraja. We let businesses accept and send KES via STK Push, C2B and B2C, then settle in fiat or crypto, in a single integration that also covers MTN MoMo, Airtel Money and Orange Money. Onboarding typically takes 3 to 5 business days.
- STK Push, C2B and B2C
- Fiat or crypto settlement
- One multi-rail integration
- Built for high-risk merchants
Last updated: 15 June 2026

Overview
What is the M-Pesa API (Daraja)?
The M-Pesa API, accessed through Safaricom's Daraja portal, is a set of web-service endpoints that let businesses collect and disburse money over M-Pesa in KES. Daraja exposes the core flows you'll use to take and send payments: STK Push for collections, C2B for Paybill and Till pay-ins, B2C for payouts, plus B2B, Reversal, Account Balance and Transaction Status. Every call authenticates with an OAuth token, and results come back to HTTPS callback URLs you control.
Boldrails provides that same M-Pesa rail as a managed, licensed layer. We hold the licences and acquire and settle M-Pesa transactions directly, so you integrate once with us instead of wiring raw Daraja yourself. You collect and pay out in KES through our API, and we handle the auth, callbacks and reconciliation underneath.
Payment flows
STK Push, C2B and B2C explained
STK Push (also called Lipa Na M-Pesa Online or M-Pesa Express) is a prefilled prompt that pops up on a customer's phone. They enter their M-Pesa PIN, and the payment confirms back to your app. It's the standard way to collect from a customer in real time. Here is how the three core flows split by direction of money:
| Flow | Direction | What it does |
|---|---|---|
| STK Push | You request, customer pays | Merchant-initiated: you trigger a prompt that pops up on the customer's phone; they pay by entering their PIN (collections). |
| C2B | Customer initiates | Customer-initiated: the customer pays your Paybill or Till number from their own M-Pesa menu, with optional validation before you accept. |
| B2C | You pay out | Disbursements to customers: salaries, refunds, supplier payments, winnings. |
Boldrails exposes all three through one API and one set of credentials. You don't manage a separate connection per flow; collections via STK Push and C2B, and payouts via B2C, run through the same Boldrails integration.
Integration
How to integrate the M-Pesa Daraja API
Integrating raw Daraja takes six steps:
- 1
Get a Paybill or Till number
Open an M-Pesa business account and gather your KYB documents (KRA PIN, CR12). You need a shortcode before you can call any API.
- 2
Create a Daraja app
Register on Safaricom's developer portal to get your Consumer Key and Consumer Secret.
- 3
Generate an OAuth token
Exchange your Consumer Key and Secret for an access token. Tokens expire after about one hour, so you refresh them on a schedule.
- 4
Build your API call and register callbacks
Construct your STK Push, C2B or B2C request, and register the HTTPS callback URLs that receive each transaction result.
- 5
Test in the sandbox
Use Safaricom's sandbox with the test Paybill 174379 and passkey to run transactions end to end before touching real money.
- 6
Request production
Apply for production credentials and IP whitelisting, then switch your endpoints from sandbox to live.
Or skip the wiring with Boldrails. You call one Boldrails endpoint, and we manage token refresh, STK Push prompt expiry, retries, idempotent confirmations, the sandbox-to-production switch and reconciliation. One integration replaces the work above and adds payouts and settlement.
Comparison
Boldrails M-Pesa API vs direct Daraja integration
Raw Daraja gives you the rail, but you build and maintain everything around it: token refresh, callback handling, retries, reconciliation, and KYB onboarding, all for M-Pesa alone and settled into an M-Pesa balance. A managed layer takes that work off your team.
IntaSend is another managed layer worth naming honestly. It abstracts Safaricom's complexity with SDKs and webhooks, supports bulk payouts up to 5,000 per request, and settles in KES and other fiat. It is Kenya-centric and does not offer crypto settlement or non-M-Pesa African rails. Boldrails covers M-Pesa plus MTN MoMo, Airtel Money and Orange Money in one integration, settles in fiat or crypto, and is built for high-risk and high-volume merchants.
| Feature | Raw Daraja (DIY) | IntaSend | Boldrails |
|---|---|---|---|
| Setup time | Days to weeks | Hours | 3 to 5 days |
| Token refresh (1-hour TTL) | Manual | Automatic | Automatic |
| STK Push timeout and retries | You build | Handled | Handled |
| Reconciliation | Manual | Handled | Automated |
| Rails in one integration | M-Pesa only | M-Pesa only | M-Pesa + MTN MoMo + Airtel + Orange |
| Settlement | M-Pesa balance | KES fiat (multi-currency wallet) | Fiat or crypto |
| Mass payouts | Manual | Up to 5,000 per request | Mass payouts |
| High-risk acceptance | n/a | Betting stated | Forex, crypto, betting where licensed |
Coverage and settlement
Coverage and settlement (KES, fiat or crypto)
You collect and pay out in KES through M-Pesa: STK Push and C2B for pay-ins, B2C for payouts. Boldrails then settles to you in fiat or crypto, your choice. We run mass payouts at scale through B2C and reconcile every transaction for you, so finance teams aren't matching statements by hand. Because M-Pesa, MTN MoMo, Airtel Money and Orange Money sit behind one integration, you collect across rails in Kenya and beyond without separate builds.
| Capability | M-Pesa via Boldrails |
|---|---|
| Collections | STK Push, C2B (Paybill / Till) in KES |
| Payouts | B2C disbursements, mass payouts at scale |
| Settlement currency | Fiat or crypto |
| Settlement timing | T+1 to T+2 |
| Reconciliation | Automated per transaction |
| Other rails, one integration | MTN MoMo, Airtel Money, Orange Money |

Pricing
Is the M-Pesa Daraja API free?
Yes, the Daraja API is free to access and test. Safaricom charges no API subscription or setup fee, and the sandbox is free to use. Live transactions are different: they carry Safaricom's standard per-transaction tariffs, and managed gateways add their own processing fee on top.
| Provider | M-Pesa processing fee |
|---|---|
| IntaSend | 3% |
| Paystack (Kenya) | 1.5% |
| Flutterwave (Kenya) | 2.9% |
| Boldrails | From 2.9%, by volume and risk |
Boldrails pricing is quoted by volume and risk profile. Our quote includes fiat-or-crypto settlement and multi-rail routing across M-Pesa, MTN MoMo, Airtel Money and Orange Money, which the others don't offer.
Who it's for
Built for high-risk and high-volume merchants
Boldrails is built for high-risk and high-volume merchants. We accept:
- Licensed forex and CFD brokers
- Crypto exchanges and wallets
- Licensed betting operators
- E-commerce stores
- Subscription and SaaS businesses
- Remittance and payout businesses
Connect M-Pesa through one API
Connect M-Pesa collections and payouts through one Boldrails API, settle in fiat or crypto, and add MTN MoMo, Airtel Money and Orange Money without a second build. Onboarding typically takes 3 to 5 business days.
FAQ
M-Pesa API questions
Last updated: 15 June 2026