Last updated: 4 July 2026

M-Pesa Daraja

M-Pesa Daraja

Live
Auth: API key · Plans: Free, Starter, Business, Enterprise · Tools: 9 · Category: Core Kenya

Query Paybill and Till transactions, balances, and collections in plain English.

Who needs this: Every Kenyan business that collects payments via M-Pesa.

Example questions once connected

  • How much came in via M-Pesa today?
  • Show me yesterday's collections by hour
  • Which customers paid more than KES 10,000 this week?
  • What is my current M-Pesa balance?

What you need before starting

  • A Safaricom M-Pesa Paybill or Till number
  • A Safaricom developer account at developer.safaricom.co.ke
  • Your M-Pesa Consumer Key and Consumer Secret
  • (Optional) Your LNM Passkey for STK push, and Initiator credentials for balance checks

Step-by-step setup

  1. Create a Safaricom developer account. Go to developer.safaricom.co.ke, click Register, verify your email, and log in.
  2. Create an app. Click My Apps → Create New App. Name it "Msharti Integration". Under API Products, select: ✅ Daraja Pull Transactions, ✅ Account Balance, ✅ C2B API. Click Create App.
  3. Copy your credentials. Click your new app. Copy the Consumer Key and reveal and copy the Consumer Secret. Store them safely.
  4. Add your Paybill/Till number. Find the Shortcode field in your app settings and enter your number (e.g. 174379). Save.
  5. Connect in Msharti. Go to Connectors → M-Pesa Daraja → Set Up. Fill in Consumer Key, Consumer Secret, Shortcode, Shortcode Type, and Environment (Sandbox for testing, Production for real data). Click Test Connection.
  6. Confirm success. A green ✅ and "Connected — 4 tools active" means you're done. Msharti auto-registers your shortcode for the Pull API.

Tool reference

These are the tools the AI can call on this connector. Each tool fires automatically when you ask a relevant question.

query_mpesa_history() Pull transactions for a Paybill or Till number over a date range.
Inputs shortcode, start_date, end_date, optional: min_amount
Try asking "Show me yesterday's M-Pesa collections grouped by hour"
Returns KES 412,300 across 187 transactions. Peak hour: 11:00–12:00 (KES 96,400, 43 transactions).
mpesa_reconciliation() Compare M-Pesa collections against invoice records and flag mismatches.
Inputs shortcode, date_range, optional: invoice_reference_list
Try asking "Reconcile yesterday's M-Pesa collections against Sage invoices and flag mismatches"
Returns 23 of 24 payments matched. 1 unmatched: KES 15,000 from 0712345678 at 14:23 — no invoice found.
mpesa_monthly_summary() Return aggregate monthly collection totals and transaction counts for a shortcode.
Inputs shortcode, month (YYYY-MM)
Try asking "Give me a monthly summary for Paybill 522533 for May 2026"
Returns May 2026: KES 4,218,750 total, 1,847 transactions, avg KES 2,284. Peak day: 15 May (KES 312,400).
stk_push_status() Check the outcome of an STK push (Lipa Na M-Pesa payment request).
Inputs checkout_request_id or merchant_request_id
Try asking "Did checkout request ws_CO_26052026 complete successfully?"
Returns Status: Success. Amount: KES 5,000. Phone: 0722***456. Completed at 10:14 AM.

Limits

  • The Pull API stores 48 hours of transactions — a Safaricom limitation. The Data Retention add-on (KES 2,000/Paybill/month) extends this to 3 months.
  • OAuth tokens are cached and auto-refreshed every 55 minutes. A brief unavailability window of under 30 seconds occurs at refresh.
  • Rate limit: 300 calls/min on Starter, 2,000/min on Business, unlimited on Enterprise.

Sandbox test data

Test valueTypeExpected result
174379 Paybill (sandbox) Returns test transaction data

Troubleshooting

ProblemCauseFix
Invalid credentials Wrong Consumer Key or Secret Return to developer.safaricom.co.ke → My Apps → copy again
API not subscribed App missing required API products Edit your app and select Daraja Pull Transactions and Account Balance
Shortcode not registered Pull API not enabled on your shortcode Contact Safaricom support to enable Pull API
Token expired Auth token expired Click Reconnect in the dashboard
Need help? [email protected] — Nairobi-based, same time zone.