Mypayments API

Take M-PESA payments on your own paybill or till without writing Daraja code. You call one API; we talk to Safaricom, confirm every payment with them, and send your server a signed webhook.

How a payment flows

  1. You start it: send an STK Push to the customer's phone, or the customer pays your paybill or till directly (C2B).
  2. We confirm it: Safaricom's callback is only a claim. We ask Safaricom for the result server to server before anything counts as paid.
  3. We tell you: a signed webhook goes to your server, or several servers routed by shortcode, payer number or account-number prefix.
  4. Or you ask: look the payment up by your own reference at any time. The webhook is a convenience; the lookup is the source of truth.

Base URL

text
https://api.mypayments.co.ke/api/v1

Every request is HTTPS with JSON bodies and an Authorization: Bearer mpk_… API key (API keys & scopes). Every response uses one envelope.

What you need

  • A Mypayments business with at least one account: your paybill or till and its Daraja keys, added in the dashboard.
  • An API key from Dashboard → API keys.
  • A webhook endpoint from Dashboard → Webhooks, if you want to be told about payments.

Endpoints at a glance

EndpointScopeDocs
GET /accounts, GET /accounts/{id}accounts:readAccounts
POST /stkstk:initiateSTK Push
GET /transactions/{reference}, GET /transactionstransactions:readTransactions
POST /accounts/{id}/numbers, GET, DELETE /numbers/{id}numbers:manageAccount numbers

Payouts

B2C and B2B payouts are not in the API yet. What exists today.

New here? The quickstart takes you from an API key to a confirmed payment in five minutes.