Comprehensive, developer-first documentation for Safaricom's M-Pesa Daraja 3.0 API. Includes OAuth, STK Push, C2B, B2C, Ratiba, QR Code, and Business to Pochi endpoints with production-ready guides and multi-language examples.
# M-Pesa Daraja Ultimate Developer Documentation
The absolute best developer-first documentation repository for Safaricom's M-Pesa Daraja 3.0 API. Built for real-world production integrations, this guide clears the confusing corporate wording and fills the gaps of the official docs.
---
## Why This Repo Exists
While Safaricom's official portal provides the raw endpoints, many developers struggle with:
- Asynchronous Flow Management: Understanding when to use polling vs listening to callbacks.
- Dynamic Security Generation: Confusing base64 generation and timestamp formatting rules.
- Production Readiness: Handling unexpected downtime, retries, and timing issues.
This repository exists to bridge the gap, offering clear markdown breakdowns, comprehensive curl & code examples, flow diagrams, and real-world implementation notes.
---
## Features and Coverage
We cover 100% of the Daraja APIs including:
- OAuth 2.0 Auth
- M-Pesa Express (STK Push)
- Customer to Business (C2B)
- Business to Customer (B2C)
- Transaction Status and Balance Queries
- Business to Business (B2B)
- Bill Manager and Invoicing
- Reversals and Standing Orders
- QR Code Generation
- Tax Remittance
- Business to Pochi
- M-Pesa Ratiba
---
## Repository Structure
```
mpesa-daraja-docs/
README.md # Project Overview and Quick Start
/docs
/getting-started
intro.md # High-Level Architecture
auth.md # OAuth Token Management
/apis
/stk-push
overview.md # STK Flow and Callbacks
request.md # Payload details
response.md # Response samples
callbacks.md # Callback schemas
errors.md # STK-specific errors
examples.md # Implementation Snippets
/c2b
/b2c
/transaction-status
/reversal
/account-balance
/b2b
/bill-manager
/qr-code
/tax-remittance
/business-to-pochi
/ratiba
/guides
stk-flow-explained.md # Advanced STK Logic
mpesa-callbacks-explained.md
common-errors.md
sandbox-vs-production.md
/examples
nodejs.md # Ready-to-use Node.js client
python.md …