M-Pesa API for SaaS platforms: pay each client directly

JMSURF PAY guide · updated 23 November 2026

If you build software for other businesses (a POS, school system, ISP billing, property or booking platform), each of your clients wants M-Pesa payments to land in their own till, paybill or bank account, not in yours. JMSURF PAY is built for exactly this: one API key for your platform, one payment channel per client, and every payment goes straight to that client. This is how JMSURF's own systems, such as JMSURF POS and JMSURF ISP, take M-Pesa payments for their clients.

How the model works

  • Your platform has one JMSURF PAY account on the Pro plan (registering client channels through the API is a Pro feature).
  • Each client is a payment channel with its own code (tnnt_…) and its own destination: a till, a paybill (with an optional account) or a bank account through the bank's paybill.
  • When your software sends a prompt with that client's tenantCode, the customer pays the client directly. Nothing passes through your account or through JMSURF PAY.
  • Webhooks for every client's payments come to your platform's webhook address, with channelId so you know whose payment it is.

Register a client's till, paybill or bank

Call POST /api/saas/provision-tenant when a client saves their M-Pesa details in your software. Send source (your system's name) and externalId (your id for the client): calling again with the same pair updates that channel instead of creating a new one, so it is safe to call on every save.

cURL: a till

curl -X POST https://jmsurfpay.co.ke/api/saas/provision-tenant \
  -H "X-API-Key: YOUR_LIVE_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Mama Njeri Shop",
    "source": "my-pos",
    "externalId": "shop-1043",
    "accountType": "till",
    "accountNumber": "XXXXXXX",
    "accountName": "Mama Njeri Shop"
  }'

Body: a bank account through the bank's paybill

{
  "name": "Greenfield Academy",
  "source": "my-school-system",
  "externalId": "school-88",
  "accountType": "bank",
  "businessNumber": "247247",
  "accountNumber": "YOUR_CLIENTS_BANK_ACCOUNT_NUMBER",
  "accountName": "Greenfield Academy"
}

Response (201 created, 200 updated)

{
  "plan": { ... },
  "tenantCode": "tnnt_...",
  "tenantId": 118,
  "name": "Mama Njeri Shop",
  "source": "my-pos",
  "externalId": "shop-1043",
  "isActive": true,
  "settlementAccountId": 204,
  "created": true,
  "createdAt": "..."
}

accountType is till, paybill or bank. For a bank, businessNumber is the bank's paybill (Equity 247247, KCB 522522, Co-operative Bank 400200 and so on) and accountNumber is the client's bank account. Look a channel up later with GET /api/saas/tenant/:tenantCode.

Request payments for a client

Node.js

// Charge a customer of that client: the money goes to the client's own till
await fetch("https://jmsurfpay.co.ke/api/payments/stkpush", {
  method: "POST",
  headers: { "X-API-Key": process.env.JMSURFPAY_SECRET_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    tenantCode: client.tenantCode,    // saved from provision-tenant
    phoneNumber: "2547XXXXXXXX",
    amount: 850,
    accountReference: "RCPT5521",
    transactionDesc: "Sale 5521",
  }),
});

Who is responsible for what

PartyResponsible for
Your platformKnowing your clients, the payment details they enter, and support for your software.
JMSURF PAYSending the payment requests, recording M-Pesa's answers, webhooks, reports and the API.
Safaricom M-Pesa and the banksMoving the money from the customer to your client's till, paybill or bank account.

Limits to know

Provisioning needs a live key (test keys get 403 TEST_MODE_UNSUPPORTED). Starter allows 3 payment channels and Pro has no limit. Prompts to the same phone are limited to 3 in 2 minutes per account, which protects your clients' customers from repeated prompts.

Questions about a platform integration? WhatsApp +254 712 504 593 or read the software platforms page.

Start on the Free plan: 1 payment channel, up to KES 50,000 a month, test keys included. Questions? WhatsApp +254 712 504 593.

Read next

© 2026 JMSURF PAY. All rights reserved. · ODPC reg. no. 194-9812-26EBPowered by JMSURF TECHNOLOGIES LTD