Initiate MPESA STK Push

POST https://upesipay.com/api/v2/payments

Initiate an MPESA STK Push request to a customer's phone

Headers

Parameter Type Description
Authorization* String Basic auth token
Content-Type* String application/json

Request Body

Parameter Type Description
amount* Integer Payment amount (e.g., 100)
phone_number* String Customer phone number (e.g., 0787677677)
channel_id* Integer Your registered payment channel ID (e.g., 2133)
provider* String Value: m-pesa
external_reference String Your unique reference to track this transaction (e.g., INV-009)
customer_name String Customer name (Optional)
callback_url String Your endpoint URL for payment status response
credential_id String Optional: The ID of your registered credential for custom Mpesa Daraja integration

Responses

201 Created - Upon Successful Request

{
  "success": true,
  "status": "QUEUED",
  "reference": "E8UWT7CLUW",
  "CheckoutRequestID": "ws_CO_02012026164321519708344109"
}

Warning

  • STK Abuse Protection: If an account sends more than 10 successive failed or cancelled STK requests to the same phone number, that specific phone number will be blocked from receiving further STK push requests from the account for 24 hours. Other phone numbers on the account are not affected. Developers should avoid sending too many failed/cancelled requests to the same phone number in quick succession.
  • General Abuse Protection: If an account accumulates over 50 failed requests within a sliding window of 6 hours, the account will be restricted from sending further STK push requests for 4 hours. If this number reaches 500 within that window, the restriction is for 24 hours. At 1000 failed requests, the restriction increases to 72 hours. The strategy uses a sliding window and failed/cancelled requests are counted within a 6-hour window.

Notes

  • channel_id - Your wallet channel ID can be found under Payment Channels menu
  • provider - Use 'm-pesa' for MPESA channels

Try It Out

Please set your authentication token in the sidebar to test this API.

Code Samples

curl -X POST \
  'https://upesipay.com/api/v2/payments' \
  -H 'Authorization: Basic YOUR_AUTH_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"amount":100,"phone_number":"0787677677","channel_id":2133,"provider":"m-pesa","external_reference":"INV-009","customer_name":"John Doe","callback_url":""}'

Was this page helpful?

Previous

Learn how to get available bank paybills for channel registration.

Get Bank Paybills

Next

Learn how to integrate payment buttons for simple payment collection.

Payment Button