Business
2025-03-28 · 10 min read
M-Pesa Daraja API: The Complete 2025 Integration Guide
Simon & Coster
· Founders, ByKabiro Labs
The Daraja API is Safaricom's developer gateway. Here's exactly how we integrate it.
The three APIs you actually need
- STK Push — Prompts a payment popup on the customer's phone. Best for e-commerce, bookings, subscriptions.
- C2B — Customer initiates payment to your paybill/till. Good for in-store payment.
- B2C — Business to customer. Refunds, payouts, disbursements.
Getting started: sandbox first
Register at the Safaricom developer portal to get a Consumer Key and Secret. The sandbox lets you simulate transactions with test money — always test here before going live.
STK Push flow, simplified
Get an OAuth token from Safaricom, generate a password, post to the processrequest endpoint, the customer enters their PIN, and Safaricom posts the result to your callback URL.
Don't want to deal with the API yourself? ByKabiro Labs handles full Daraja integration: STK Push, callbacks, receipts, reconciliation.
Get M-Pesa integrated ↗