UMS Pay API Documentation
Accept M-Pesa STK Push payments in your app, website, POS, or ERP. All requests go to our API subdomain with your API key, email, and Account ID.
5-minute setup
Register → connect account → copy API key → send STK push
Get API key
Dashboard → Account Settings → Generate API Key
Webhooks
Receive payment results on your server automatically
Plugins
WooCommerce, API kit ZIP, and integration examples
Your credentials — where to find them
Every API call needs three merchant identifiers. Log in at umspay.co.ke to collect them.
| Field | Where to get it | Example |
|---|---|---|
api_key |
Account Settings → Generate API Key. Starts with UMPAY_. Keep it secret. |
UMPAY_a1b2c3… |
email |
Your registered UMS Pay login email (same as dashboard). | [email protected] |
account_id |
Connected Accounts → copy Account ID for the Paybill/Till/Bank you want to receive into. | UMSPAY1234567890 |
Before going live: your connected account must be active (paid plan or trial). Set your webhook URL per account under Webhook Settings.
Quick start
- Create a free account at umspay.co.ke/register
- Connect a Paybill, Till, or Bank account under Connected Accounts
- Activate the account (subscription or 3-day trial)
- Generate your API key in Account Settings
- POST to
/api/v1/initiatestkpush— customer gets M-Pesa prompt on phone - Confirm payment via webhook or transaction status API
Minimal cURL example
curl -X POST https://api.umspay.co.ke/api/v1/initiatestkpush \
-H "Content-Type: application/json" \
-d '{
"api_key": "UMPAY_your_key_here",
"email": "[email protected]",
"amount": 100,
"msisdn": "254712345678",
"reference": "ORDER-1001",
"account_id": "UMSPAY1234567890"
}'Payment flow
Save the transaction_request_id from the STK response. Use it to poll status or match incoming webhooks. Your custom reference is echoed back in status and webhook payloads.
Initiate STK Push
Sends an M-Pesa STK push to the customer's phone. Amount is in KES. Phone must be Kenyan format 2547XXXXXXXX (leading 0 is also accepted and normalized).
Request body (JSON)
| Parameter | Type | Description | |
|---|---|---|---|
api_key | string | Required | Your UMS Pay API key |
email | string | Required | Registered merchant email |
amount | number | Required | Amount in KES (integer recommended) |
msisdn | string | Required | Customer phone, e.g. 254712345678 |
reference | string | Required | Your order/invoice ID (shown on M-Pesa / reports) |
account_id | string | Required | Connected account to settle funds |
Code examples
curl -X POST https://api.umspay.co.ke/api/v1/initiatestkpush \
-H "Content-Type: application/json" \
-d '{"api_key":"UMPAY_xxx","email":"[email protected]","amount":500,"msisdn":"254712345678","reference":"INV-42","account_id":"UMSPAY1234567890"}'{
"success": "200",
"message": "Request processed successfully",
"transaction_request_id": "UMSPID1507202610231492867"
}{
"ResultCode": "403",
"errorMessage": "Your subscription has expired. Please subscribe to continue using UMS Pay services.",
"subscription_required": true
}Check transaction status
Poll payment result using the transaction_request_id from STK Push. For pending payments, UMS Pay may query Safaricom live before returning status.
| Parameter | Type | Description | |
|---|---|---|---|
api_key | string | Required | Your API key |
email | string | Required | Merchant email |
transaction_request_id | string | Required | ID from STK Push response |
{
"ResultCode": "200",
"ResultDesc": "Success. Request accepted for processing",
"TransactionID": "UMSPID1507202610231492867",
"TransactionAccountID": "UMSPAY1234567890",
"TransactionStatus": "Completed",
"TransactionCode": "0",
"TransactionReceipt": "THF123ABC",
"TransactionAmount": "500",
"Msisdn": "254712345678",
"TransactionDate": "07/15/26 10:23 AM",
"TransactionReference": "INV-42",
"MpesaResponse": "{...}"
}Transaction status values
| TransactionStatus | TransactionCode | Meaning |
|---|---|---|
| Completed | 0 | Payment successful — funds received |
| Failed | 1 | Insufficient M-Pesa balance |
| Failed | 1032 | Customer cancelled STK prompt |
| Failed | 1037 | Timeout — phone unreachable |
| Pending | — | Waiting for customer action |
Transaction status (v2)
Same parameters as v1. Returns structured HTTP status codes and a lighter JSON shape — recommended for new integrations.
| Parameter | Type | Description | |
|---|---|---|---|
api_key | string | Required | Your API key |
email | string | Required | Merchant email |
transaction_request_id | string | Required | STK transaction ID |
Free trial (3 days)
New merchants with a single connected account can start a 3-day API trial before subscribing.
| Parameter | Required | Description |
|---|---|---|
api_key, email, account_id | Yes | Same auth as STK Push |
Returns trial_eligible, trial_active, trial_days_remaining, and trial dates.
Webhooks
Configure a webhook URL per connected account in Webhook Settings. When a payment completes or fails, UMS Pay sends a POST request with JSON body to your URL.
Webhook payload
{
"ResponseCode": 0,
"ResponseDescription": "Success. Request accepted for processing",
"MerchantRequestID": "xxx",
"CheckoutRequestID": "ws_CO_xxx",
"TransactionID": "UMSPID1507202610231492867",
"TransactionAmount": 500,
"TransactionReceipt": "THF123ABC",
"TransactionDate": "20260715102333",
"TransactionReference": "INV-42",
"Msisdn": "254712345678"
}ResponseCode0 = success; other codes = failure/cancel (see error table)TransactionReference= your originalreferencefrom STK PushTransactionReceipt= M-Pesa confirmation code (may be empty until confirmed)- Respond with HTTP 200 quickly; retry logic is on our side if delivery fails
Tip: Use webhooks as primary confirmation; use transaction status API as backup polling.
Error codes & rate limits
| ResultCode | Meaning |
|---|---|
102 | Missing/invalid parameter or bad API key |
401 | Invalid email or API key (trial endpoints) |
403 | Account suspended, inactive, subscription expired, or fraud block |
404 | Account or transaction not found |
429 | Rate limit — too many STK requests (includes retry_after seconds) |
503 | M-Pesa or internal service temporarily unavailable |
Rate limits (STK Push)
- 30 seconds cooldown per phone + account (duplicate STK protection)
- 3 requests/minute per account
- 40 requests/hour per account
High-risk patterns may be blocked automatically (fraud detection). Contact support if legitimate traffic is blocked.
Connected account types
When you connect an account at Connected Accounts, STK funds route based on type:
| Type | What happens |
|---|---|
| Paybill | STK uses your paybill; reference becomes the account number on the paybill |
| Till (Buy Goods) | STK pays your till number; reference stored for reconciliation |
| Bank | STK routes via configured bank paybill + account number |
Each connected account needs an active subscription or trial. Account ID is required on every STK request via account_id.
Ready to test?
Use the dashboard test tool or download plugins for WooCommerce and custom apps.