daraja-openapi

API reference / M-PESA Express

Check the result of an STK Push

POST/mpesa/stkpushquery/v1/query

Checked against the Safaricom sandbox on 1 December 2026

Returns the outcome of an STK Push. Use it to confirm a payment before you deliver, and to recover results whose callbacks never arrived. While the customer is still deciding, Daraja answers with an error (errorCode 500.001.1001, "The transaction is being processed"); retry after a few seconds. Querying too often, or right after the push, returns HTTP 429: wait at least a few seconds before the first query and back off between queries.

In the SDKs

SDKMethod
TypeScriptstkQuery(), waitForStkResult()
Pythonstk_query(), wait_for_stk_result()
PHPstkQuery(), waitForStkResult()
KotlinstkQuery(), waitForStkResult()
SwiftstkQuery(), waitForStkResult()

Request

EnvironmentURL
Sandboxhttps://sandbox.safaricom.co.ke/mpesa/stkpushquery/v1/query
Productionhttps://api.safaricom.co.ke/mpesa/stkpushquery/v1/query

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}$.
CheckoutRequestIDstringRequired

Example request

curl -X POST "https://sandbox.safaricom.co.ke/mpesa/stkpushquery/v1/query" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "BusinessShortCode": "174379",
  "Password": "MTc0Mzc5YmZiMjc5ZjlhYTliZGJjZjE1OGU5N2RkNzFhNDY3Y2QyZTBjODkzMDU5YjEwZjc4ZTZiNzJhZGExZWQyYzkxOTIwMjYxMTMwMTAxMDAw",
  "Timestamp": "20261130101000",
  "CheckoutRequestID": "ws_CO_30112026101000123708374149"
}'

Response

The current result of the STK Push.

FieldTypeDescription
ResponseCodestringRequired
ResponseDescriptionstringRequired
MerchantRequestIDstringRequired
CheckoutRequestIDstringRequired
ResultCodestringRequiredThe payment result as a string. "0" means paid. See StkResultCode.
ResultDescstringRequired

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

{
  "ResponseCode": "0",
  "ResponseDescription": "The service request has been accepted successsfully",
  "MerchantRequestID": "29115-34620561-1",
  "CheckoutRequestID": "ws_CO_30112026101000123708374149",
  "ResultCode": "0",
  "ResultDesc": "The service request is processed successfully."
}

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.