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
- You start it: send an STK Push to the customer's phone, or the customer pays your paybill or till directly (C2B).
- We confirm it: Safaricom's callback is only a claim. We ask Safaricom for the result server to server before anything counts as paid.
- We tell you: a signed webhook goes to your server, or several servers routed by shortcode, payer number or account-number prefix.
- 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/v1Every 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
| Endpoint | Scope | Docs |
|---|---|---|
GET /accounts, GET /accounts/{id} | accounts:read | Accounts |
POST /stk | stk:initiate | STK Push |
GET /transactions/{reference}, GET /transactions | transactions:read | Transactions |
POST /accounts/{id}/numbers, GET, DELETE /numbers/{id} | numbers:manage | Account 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.