kollekt Start here

M-Pesa API: how to integrate it

The M-Pesa API, called Daraja, lets your app take payments from Safaricom M-Pesa users in Kenya. The best-known flow is STK Push: your app sends a payment prompt to the customer's phone, they enter their PIN, and the money arrives. Here's what you need to get started and go live.

Last updated · By the Kollekt team

Key facts

How the integration works

  1. Create an account on the Daraja portal and create an app to get your consumer key and secret.
  2. Test in the sandbox with the test shortcode and passkey.
  3. Get an access token, then call the STK Push endpoint with the amount, the customer's phone number (2547XXXXXXXX) and your callback URL.
  4. The customer enters their M-Pesa PIN on the prompt.
  5. Safaricom calls your callback URL with the result. Confirm it from your server before giving value.
  6. Apply to go live with your Paybill or Till number, then swap in your production credentials.

Want it done for you?

Kollekt integrates M-Pesa into your app or store. Built your app but stuck on payments? Kollekt integrates mobile money for you.

Questions people ask

Do I need a Paybill or Till number to use the M-Pesa API?

For live payments, yes. Daraja production access is tied to a Paybill or Till number registered with Safaricom. If you don't have one, a payment gateway that supports M-Pesa lets you accept it through their account setup instead.

Does the M-Pesa API work outside Kenya?

Daraja is for Safaricom M-Pesa in Kenya. M-Pesa in other countries, like Tanzania (Vodacom) or DR Congo, is run by different operators with their own APIs and onboarding.

Sources

One API for mobile money across Africa.

Explore our platform