daraja-openapi

API reference / M-PESA Express

Send an STK Push payment prompt

POST/mpesa/stkpush/v1/processrequest

Checked against the Safaricom sandbox on 1 December 2026

Asks the customer to approve a payment on their phone. A ResponseCode of "0" means only that Daraja accepted the request; the payment result arrives later at your CallBackURL, or can be read with the STK Push Query.

In the SDKs

SDKMethod
TypeScriptstkPush()
Pythonstk_push()
PHPstkPush()
KotlinstkPush()
SwiftstkPush()

Request

EnvironmentURL
Sandboxhttps://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest
Productionhttps://api.safaricom.co.ke/mpesa/stkpush/v1/processrequest

Send the access token as Authorization: Bearer <token>, and the body as JSON.

FieldTypeDescription
BusinessShortCodestringRequiredA paybill or till number. Matches ^[0-9]{5,7}$.
PasswordstringRequiredBase64 of BusinessShortCode + Passkey + Timestamp.
TimestampstringRequiredThe time of the request in Kenyan time (EAT), formatted YYYYMMDDHHmmss. Matches ^[0-9]{14}$.
TransactionTypestringRequiredCustomerPayBillOnline for a paybill, CustomerBuyGoodsOnline for a till. One of CustomerPayBillOnline, CustomerBuyGoodsOnline.
AmountintegerRequiredWhole Kenyan shillings. At least 1.
PartyAstringRequiredA Kenyan mobile number in international format without the plus, e.g. 254708374149. Matches ^254(7|1)[0-9]{8}$.
PartyBstringRequiredA paybill or till number. Matches ^[0-9]{5,7}$.
PhoneNumberstringRequiredA Kenyan mobile number in international format without the plus, e.g. 254708374149. Matches ^254(7|1)[0-9]{8}$.
CallBackURLstring (uri)RequiredThe public HTTPS URL that receives the result. Matches ^https://.
AccountReferencestringRequiredShown to the customer as the account number. Up to 12 characters. 1–12 characters.
TransactionDescstringRequiredA short note about the payment. Up to 13 characters. 1–13 characters.

Example request

curl -X POST "https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "BusinessShortCode": "174379",
  "Password": "MTc0Mzc5YmZiMjc5ZjlhYTliZGJjZjE1OGU5N2RkNzFhNDY3Y2QyZTBjODkzMDU5YjEwZjc4ZTZiNzJhZGExZWQyYzkxOTIwMjYxMTMwMTAxMDAw",
  "Timestamp": "20261130101000",
  "TransactionType": "CustomerPayBillOnline",
  "Amount": 1,
  "PartyA": "254708374149",
  "PartyB": "174379",
  "PhoneNumber": "254708374149",
  "CallBackURL": "https://example.com/mpesa/callback",
  "AccountReference": "INV-1001",
  "TransactionDesc": "Invoice 1001"
}'

Response

Daraja accepted the request and sent the prompt.

FieldTypeDescription
MerchantRequestIDstringRequired
CheckoutRequestIDstringRequiredIdentifies this payment in the callback and the STK Push Query.
ResponseCodestringRequired"0" means Daraja accepted the request.
ResponseDescriptionstringRequired
CustomerMessagestring

Errors

StatusMeaning
400Daraja rejected the request. An HTTP 401 with "Invalid API call as no apiproduct match found" means your Daraja app does not have this API product enabled: add it to the app on the Daraja portal, then request a new access token.
401Daraja rejected the request. An HTTP 401 with "Invalid API call as no apiproduct match found" means your Daraja app does not have this API product enabled: add it to the app on the Daraja portal, then request a new access token.
429Daraja's gateway is rate-limiting this app. Observed in the sandbox for an STK Push Query sent seconds after the STK Push (2026-12-01). The body does not follow the usual error shape, so read the status code, wait, and retry with backoff.
500Daraja rejected the request. An HTTP 401 with "Invalid API call as no apiproduct match found" means your Daraja app does not have this API product enabled: add it to the app on the Daraja portal, then request a new access token.

See errors and rate limits for what to do with each.

Example response

{
  "MerchantRequestID": "29115-34620561-1",
  "CheckoutRequestID": "ws_CO_30112026101000123708374149",
  "ResponseCode": "0",
  "ResponseDescription": "Success. Request accepted for processing",
  "CustomerMessage": "Success. Request accepted for processing"
}

Callback

Daraja calls these on your server. They are not signed: confirm with Daraja before you act on one. See handling callbacks.

The payment result

Sent to CallBackURL from your request.

Daraja POSTs the outcome to your CallBackURL. ResultCode 0 means the customer paid; any other value means the payment did not happen. CallbackMetadata is present only when the payment succeeded. Respond with HTTP 200 quickly; the callback is not signed and may be lost, so reconcile unconfirmed payments with the STK Push Query.

FieldTypeDescription
BodyobjectRequired
Body.stkCallbackobjectRequired
Body.stkCallback.MerchantRequestIDstringRequired
Body.stkCallback.CheckoutRequestIDstringRequired
Body.stkCallback.ResultCodeintegerRequiredCommon results. Daraja may return others; treat any non-zero code as not paid. - 0 paid - 1 insufficient balance - 1001 another transaction is in progress for this customer - 1019 the prompt expired - 1025 / 9999 Daraja could not send the prompt - 1032 the customer cancelled - 1037 the customer's phone could not be reached, or they did not respond - 2001 the customer entered the wrong PIN
Body.stkCallback.ResultDescstringRequired
Body.stkCallback.CallbackMetadataobject
Body.stkCallback.CallbackMetadata.Itemarray of objectRequired

View the source of this page

Built by ByteGigs Labs. Apache 2.0. M-PESA, Daraja and Safaricom are trademarks of Safaricom PLC; this project is independent and not endorsed by Safaricom.