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.

Base URL https://api.umspay.co.ke

Your credentials — where to find them

Every API call needs three merchant identifiers. Log in at umspay.co.ke to collect them.

FieldWhere to get itExample
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

  1. Create a free account at umspay.co.ke/register
  2. Connect a Paybill, Till, or Bank account under Connected Accounts
  3. Activate the account (subscription or 3-day trial)
  4. Generate your API key in Account Settings
  5. POST to /api/v1/initiatestkpush — customer gets M-Pesa prompt on phone
  6. 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

1. Your server calls STK Push 2. Customer enters M-Pesa PIN 3. Safaricom confirms 4. UMS Pay updates status 5. Webhook POST to your URL

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

POST /api/v1/initiatestkpush

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)

ParameterTypeDescription
api_keystringRequiredYour UMS Pay API key
emailstringRequiredRegistered merchant email
amountnumberRequiredAmount in KES (integer recommended)
msisdnstringRequiredCustomer phone, e.g. 254712345678
referencestringRequiredYour order/invoice ID (shown on M-Pesa / reports)
account_idstringRequiredConnected 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
{
  "success": "200",
  "message": "Request processed successfully",
  "transaction_request_id": "UMSPID1507202610231492867"
}
Inactive account
{
  "ResultCode": "403",
  "errorMessage": "Your subscription has expired. Please subscribe to continue using UMS Pay services.",
  "subscription_required": true
}

Check transaction status

POST /api/v1/transactionstatus

Poll payment result using the transaction_request_id from STK Push. For pending payments, UMS Pay may query Safaricom live before returning status.

ParameterTypeDescription
api_keystringRequiredYour API key
emailstringRequiredMerchant email
transaction_request_idstringRequiredID from STK Push response
Completed
{
  "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

TransactionStatusTransactionCodeMeaning
Completed0Payment successful — funds received
Failed1Insufficient M-Pesa balance
Failed1032Customer cancelled STK prompt
Failed1037Timeout — phone unreachable
PendingWaiting for customer action

Transaction status (v2)

POST /api/v2/transactionstatus

Same parameters as v1. Returns structured HTTP status codes and a lighter JSON shape — recommended for new integrations.

ParameterTypeDescription
api_keystringRequiredYour API key
emailstringRequiredMerchant email
transaction_request_idstringRequiredSTK transaction ID

Free trial (3 days)

New merchants with a single connected account can start a 3-day API trial before subscribing.

POST /api/v1/start-trial
ParameterRequiredDescription
api_key, email, account_idYesSame auth as STK Push
POST /api/v1/check-trial-status

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"
}
  • ResponseCode 0 = success; other codes = failure/cancel (see error table)
  • TransactionReference = your original reference from STK Push
  • TransactionReceipt = 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

ResultCodeMeaning
102Missing/invalid parameter or bad API key
401Invalid email or API key (trial endpoints)
403Account suspended, inactive, subscription expired, or fraud block
404Account or transaction not found
429Rate limit — too many STK requests (includes retry_after seconds)
503M-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:

TypeWhat happens
PaybillSTK uses your paybill; reference becomes the account number on the paybill
Till (Buy Goods)STK pays your till number; reference stored for reconciliation
BankSTK 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.

Open test payments Download plugins Contact support