Getting Started
Introduction
Welcome to the JMSURF PAY API. This guide will walk you through everything you need — from creating your account to accepting real payments.
What is JMSURF PAY?
JMSURF PAY is payment integration software that connects a business's own M-Pesa till, paybill or bank account to its systems. Payments go straight from the customer to that account; JMSURF PAY never holds the money. You integrate once using a simple API, and then you can:
- Send M-Pesa STK Push prompts (customer enters their PIN on their phone)
- Process payments for many shops or branches, each with its own till, paybill or bank (payment channels)
- Create shareable payment links (no coding needed for customers)
Base URL
https://jmsurfpay.co.ke
API Version
v1
Data format
JSON
API Keys — What they are & where to get them
An API Key is like a password that identifies your business when you call the JMSURF PAY API. Every request your server makes must include your Secret Key so the system knows who is making the request.
How to get your API Key (step by step):
- 1Log in to your JMSURF PAY dashboard
- 2Click "API Keys" in the left sidebar
- 3Click the "Create API Key" button
- 4Give your key a name (e.g. "My App" or "Production")
- 5Copy both keys — your Public Key (pk_...) and Secret Key (sk_...)
- 6Store your Secret Key safely — you can only see it once!
Public Key (pk_...)
Safe to share or use in frontend/client-side code. Identifies your account but cannot trigger payments.
Secret Key (sk_...)
Required for all payment API calls. Never share this publicly or put it in a mobile app or website. Use only on your backend server.
// Add to every API request:
curl https://jmsurfpay.co.ke/api/payments/stkpush \
-H "X-API-Key: sk_your_secret_key_here" \
-H "Content-Type: application/json" \
-d '{"phoneNumber":"2547XXXXXXXX","amount":100,...}'Authentication: X-API-Key or HTTP Basic
Send your secret key in one of these ways. They are equivalent: the same keys, the same limits (after 30 wrong keys a minute from one address the API answers 429 RATE_LIMITED), and every wrong key is logged.
| Header | Value |
|---|---|
| X-API-Key | sk_… (your secret key) |
| Authorization | Basic base64("pk_…:sk_…") — public key (the key id) as user name, secret as password |
| Authorization | Basic base64("sk_…:") — secret as user name, empty password |
| Authorization | Bearer sk_… (secret keys only) |
With the public key and secret, both must belong to the same key, otherwise the request gets 401. Most HTTP clients build the Basic header for you:
# cURL builds "Authorization: Basic ..." from -u
curl https://jmsurfpay.co.ke/api/payments/status/CHECKOUT_REQUEST_ID -u "YOUR_PUBLIC_KEY:YOUR_SECRET_KEY"
// Node.js
const auth = "Basic " + Buffer.from(`${process.env.JMSURFPAY_PUBLIC_KEY}:${process.env.JMSURFPAY_SECRET_KEY}`).toString("base64");
await fetch("https://jmsurfpay.co.ke/api/payments/stkpush", { method: "POST", headers: { Authorization: auth, "Content-Type": "application/json" }, body });
# Python
requests.post("https://jmsurfpay.co.ke/api/payments/stkpush", auth=(PUBLIC_KEY, SECRET_KEY), json=payload)Test mode
Every account gets a test key (sk_test_…, with public key pk_test_…) as soon as its email is confirmed. Test keys work before your business is verified and on any plan, including Free. Use the same endpoints and the same request body as live; only the key changes.
- Nothing is sent to M-Pesa and no phone is charged. The prompt is simulated and settles by itself in about 6 seconds.
- The amount picks the outcome:
2= wrong PIN (2001),3= cancelled by the customer (1032),4= no response (1037), any other amount = paid (receipt starts withTEST). - Your webhooks still fire, with
"livemode": falseat the top level and indata. Responses from/payments/stkpushand/payments/statuscarrylivemodetoo. - Test payments never count in totals, Transactions, reports, customers, exports or your plan's monthly volume. You find them under API & keys → Test mode.
- A test key reads test payments only, and a live key live payments only. Idempotency keys are kept apart too.
- Test keys can send payments and read (
GET). Endpoints that change live data or move real money (payouts, plan renewals, provisioning channels) answer403 TEST_MODE_UNSUPPORTED. - Live keys (
sk_…) send real prompts and need a verified business (403 KYC_REQUIREDuntil then).
Payment channels — where does the money go?
A payment channel is a till, paybill or bank account your customers pay into. Every payment goes straight from the customer into that account. JMSURF PAY never holds your money: there is no wallet and nothing to withdraw.
- In your dashboard open Payment channels and click Add channel.
- Choose Till, Paybill or Bank and enter the numbers.
- Copy the channel code (e.g.
tnnt_a1b2c3d4) and send it astenantCodewith each STK push.
Systems such as a POS or ISP billing can create channels automatically with POST /api/saas/provision-tenant.
Quick Start Checklist
- Register a merchant account at https://jmsurfpay.co.ke/register
- Confirm your email: your test key is ready under API & keys → Test mode
- Build and test your integration with the test key (nothing reaches M-Pesa)
- Go to Payment channels → add your till, paybill or bank, and finish Verification
- Create a live key under API & keys → Live and switch your server to it
- Your 14-day free trial starts on sign-up; then choose Starter or Pro, or stay on Free (1 channel, monthly limit)