Developers
Request a payment. Get a webhook.
A clean REST API over Safaricom's Daraja: we handle tokens, passkeys, callbacks, timeouts and result codes.
1. Ask for the payment
POST /v1/businesses/{id}/payments with the amount, the currency and how the payer pays: M-Pesa and their phone number. It returns at once with status pending; the payer has about a minute to enter their PIN.
curl https://api.payments.lmn.co.ke/v1/businesses/$BUSINESS_ID/payments \
-H "Authorization: Bearer $MALIPO_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-41123" \
-d '{
"amount": 1250,
"currency": "KES",
"paymentMethod": {
"type": "mobile_money",
"provider": "mpesa",
"phone": "+254712345678"
},
"reference": "ORD-41123",
"description": "2 bags of maize flour",
"metadata": { "orderId": "41123" }
}'2. Receive the result
Check Malipo-Signature before trusting a webhook: v1 is the hex HMAC-SHA256 of "<t>.<raw body>" with your endpoint's secret. Reject timestamps older than 5 minutes; dedupe on id (delivery is at least once, retried for about a day). The "Send test" button sends a webhook.test event that carries no payment.
POST /your/webhook
Malipo-Signature: t=1763640000,v1=5f2b0c…
Malipo-Event-Id: evt_8kq2m1xzr4t7v9b3n6c5
Malipo-Event-Type: payment.succeeded
Content-Type: application/json
{
"id": "evt_8kq2m1xzr4t7v9b3n6c5",
"type": "payment.succeeded",
"createdAt": "2026-11-20T09:40:07Z",
"data": {
"id": "pay_3nt9wqk2m7x4c8v6b5z1",
"status": "succeeded",
"amount": 1250,
"currency": "KES",
"country": "KE",
"fee": 6.25,
"flow": "prompt",
"paymentMethod": {
"type": "mobile_money",
"provider": "mpesa",
"phone": "254712•••678"
},
"payerName": "WANJIKU K.",
"receipt": "UK4Q7H2M9P",
"reference": "ORD-41123",
"metadata": { "orderId": "41123" },
"failure": null,
"accountId": "acc_x2m8k4q7w1z5c9v3b6n0",
"accountType": "till",
"accountNumber": "5123456",
"environment": "production",
"completedAt": "2026-11-20T09:40:05Z"
}
}Endpoints
Base URL https://api.payments.lmn.co.ke · Authorization: Bearer pk_live_…
- JSON in and out. Responses are { status, code, message, errors, data }; failures add error, a stable code to branch on, and errors names the fields to fix.
- Amounts are in the currency's main unit (shillings, not cents). M-Pesa takes whole amounts.
- Phone numbers are in international format: +254712345678. A number without its country code is refused, so it can never be read as another country's.
- Send an Idempotency-Key with every payment request: a retry with the same key returns the first payment instead of prompting twice.
Start here · Which business a key belongs to (the id goes in every other path), and what you can take payments with.
- GET
/v1/meWho am I: the key, its scopes and its business - GET
/v1/payment-methodsWhat we take, by country and currency, and what's coming (no key needed; ?country=KE)
Payments · Ask a payer to pay and follow the payment to its receipt.
- POST
/v1/businesses/{id}/paymentsAsk a payer to pay: amount, currency and paymentMethod (M-Pesa today: a prompt on their phone) - GET
/v1/businesses/{id}/paymentsList payments; filter by status, flow, accountId, days or q (receipt, reference, phone) - GET
/v1/businesses/{id}/payments/{paymentId}One payment, with its timeline - POST
/v1/businesses/{id}/payments/{paymentId}/queryAsk the provider for the latest status - POST
/v1/businesses/{id}/payments/{paymentId}/reversalRequest a reversal (not available yet: M-Pesa needs initiator credentials)
Payment links · Checkout pages you share on WhatsApp, SMS or a printed QR.
- POST
/v1/businesses/{id}/linksCreate a link (fixed or open amount) - GET
/v1/businesses/{id}/linksList links with what each collected - PATCH
/v1/businesses/{id}/links/{linkId}Pause, resume or edit a link
Accounts · Where payments are paid into: M-Pesa tills and paybills today. Each takes one payment method in one currency.
- GET
/v1/businesses/{id}/accountsList connected accounts, with today's totals - GET
/v1/businesses/{id}/accounts/{accountId}One account: its provider, currency and capabilities
Webhooks · Where we POST payment events.
- GET
/v1/businesses/{id}/webhooksList endpoints - POST
/v1/businesses/{id}/webhooksAdd an endpoint (the signing secret is returned once)
Asking for a payment
POST /v1/businesses/{id}/payments
amountnumberrequiredIn the currency's main unit: 1250 is KES 1,250. M-Pesa: whole amounts from 1 to 250,000.currencystringrequiredISO 4217 code: "KES". It has to match the account the payment is paid into.paymentMethod.typestringrequiredWhat the payer pays with: "mobile_money".paymentMethod.providerstringrequiredWhose service carries it: "mpesa". GET /v1/payment-methods lists every live type, provider and currency.paymentMethod.phonestringrequiredThe payer's number in international format: "+254712345678".accountIdstringThe account it's paid into (a till or paybill). Left out: your default account for that method and currency.referencestringShown to the payer and on your statement: a paybill account number or your order number. M-Pesa shows up to 12 characters.descriptionstringFor you: up to 200 characters.metadataobjectYour own keys (up to 20, 40 characters each) with string, number or true/false values. Returned on the payment and in every webhook.
Failure codes
failure.code on a payment that didn't go through
cancelled_by_customerThe payer cancelled the prompt.insufficient_fundsThe payer didn't have enough to pay.wrong_pinThe payer entered the wrong PIN.customer_unreachableThe prompt never reached the payer's phone (off, no network, SIM busy).customer_busyThe payer had another transaction in progress.expiredThe payer didn't answer in time.provider_errorThe provider refused or never took the request; failure.message says why.declinedThe provider declined it for another reason; failure.providerCode has its own code.
Events
payment.succeeded
Money received: a prompt was paid, a link was paid, or a payer paid your account directly.
payment.failed
It didn't go through: cancelled, not enough money, wrong PIN, no answer. failure.code says which.
payment.pending
A prompt is on the payer's phone (sent right after you ask for the payment).
payment.reversed
The provider reversed a payment.
account.status_changed
An account went live, broke (keys rejected, split missing) or was fixed.
Built to last
Within /v1 we only ever add: new optional request fields, new response fields, new endpoints, and new values in lists such as provider, flow, failure.code and event types. Nothing is renamed or removed. Ignore fields and values you don't recognise (treat an unknown provider as one you don't support yet, never as an error). A change that would break callers gets a new version, /v2, run alongside /v1.
Test without money
- Create a free account and connect Safaricom's sandbox shortcode 174379 with your Daraja sandbox keys.
- Create a test API key.
- Call the same endpoints. Webhooks and the console behave exactly as live.
Your till, fully connected by lunchtime.
Connect a till or paybill, send yourself KES 1, and watch it land. No setup fee, no monthly fee: you pay only when you get paid.