API reference / Transaction Status
Look up an M-PESA transaction
/mpesa/transactionstatus/v1/queryChecked against the Safaricom sandbox on 1 December 2026
Returns the details of a transaction by its receipt (TransactionID), or by
OriginatorConversationID for a B2C payment whose receipt you never got. Use
it to confirm C2B payments and to recover lost results. The answer arrives at
ResultURL, not in the response.
In the SDKs
| SDK | Method |
|---|---|
| TypeScript | transactionStatus() |
| Python | transaction_status() |
| PHP | transactionStatus() |
| Kotlin | transactionStatus() |
| Swift | transactionStatus() |
Request
| Environment | URL |
|---|---|
| Sandbox | https://sandbox.safaricom.co.ke/mpesa/transactionstatus/v1/query |
| Production | https://api.safaricom.co.ke/mpesa/transactionstatus/v1/query |
Send the access token as Authorization: Bearer <token>, and the body as JSON.
| Field | Type | Description |
|---|---|---|
Initiator | stringRequired | The API operator created on the M-PESA org portal. testapi in the sandbox. |
SecurityCredential | stringRequired | The initiator's password encrypted with Safaricom's public certificate (RSA, PKCS #1 v1.5 padding), base64-encoded. The sandbox and production use different certificates. |
CommandID | stringRequired | Always TransactionStatusQuery. |
TransactionID | string | The M-PESA receipt. Required unless you send OriginatorConversationID. |
OriginatorConversationID | string | The ID you gave a B2C payment, when you have no receipt. |
PartyA | stringRequired | Your shortcode, or a phone number for IdentifierType "1". |
IdentifierType | stringRequired | "1" phone number, "2" till, "4" shortcode. One of 1, 2, 4. |
ResultURL | string (uri)Required | Matches ^https://. |
QueueTimeOutURL | string (uri)Required | Matches ^https://. |
Remarks | stringRequired | 2–100 characters. |
Occasion | string |
Example request
curl -X POST "https://sandbox.safaricom.co.ke/mpesa/transactionstatus/v1/query" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"Initiator": "testapi",
"SecurityCredential": "EsJocK7+NjqZPC3I3EO+TbvS+xVb9TymWwaKABoaZr/Z/n0UysSs..",
"CommandID": "TransactionStatusQuery",
"TransactionID": "TKU3XXXXXX",
"PartyA": "600984",
"IdentifierType": "4",
"ResultURL": "https://example.com/mpesa/status/result",
"QueueTimeOutURL": "https://example.com/mpesa/status/timeout",
"Remarks": "Confirm payment"
}'Response
Daraja queued the request. This is not the outcome: that arrives at ResultURL.
| Field | Type | Description |
|---|---|---|
ConversationID | stringRequired | |
OriginatorConversationID | stringRequired | |
ResponseCode | stringRequired | "0" means Daraja queued the request. The outcome comes to ResultURL. |
ResponseDescription | stringRequired |
Errors
| Status | Meaning |
|---|---|
400 | Daraja 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. |
401 | Daraja 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. |
500 | Daraja 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
{
"ConversationID": "AG_20261201_2010325b025970fbc403",
"OriginatorConversationID": "6f2b8c1e-3c1d-4a8e-9a55-0d1bc7a2f001",
"ResponseCode": "0",
"ResponseDescription": "Accept the service request successfully."
}Callbacks
Daraja calls these on your server. They are not signed: confirm with Daraja before you act on one. See handling callbacks.
The result of a B2C, B2B, reversal, status or balance request
Sent to ResultURL from your request.
ResultCode 0 means the request succeeded. Details arrive as key/value
pairs in ResultParameters, which is missing when the request failed.
Not signed: match it to your request by OriginatorConversationID and
ConversationID, and answer HTTP 200.
| Field | Type | Description |
|---|---|---|
Result | objectRequired | |
Result.ResultType | integerRequired | |
Result.ResultCode | integer or stringRequired | 0 means success. Some APIs send it as a string. |
Result.ResultDesc | stringRequired | |
Result.OriginatorConversationID | stringRequired | |
Result.ConversationID | stringRequired | |
Result.TransactionID | string | |
Result.ResultParameters | object | |
Result.ResultParameters.ResultParameter | array of object or object | One item or a list, depending on the API. |
Result.ResultParameters.ResultParameter[].Key | stringRequired | |
Result.ResultParameters.ResultParameter[].Value | string or number | |
Result.ReferenceData | object | |
Result.ReferenceData.ReferenceItem | array of object or object | |
Result.ReferenceData.ReferenceItem[].Key | stringRequired | |
Result.ReferenceData.ReferenceItem[].Value | string or number |
Example body
{
"Result": {
"ResultType": 0,
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"OriginatorConversationID": "6f2b8c1e-3c1d-4a8e-9a55-0d1bc7a2f001",
"ConversationID": "AG_20261201_2010325b025970fbc403",
"TransactionID": "TKU3XXXXXX",
"ResultParameters": {
"ResultParameter": [
{
"Key": "TransactionAmount",
"Value": 100
},
{
"Key": "TransactionReceipt",
"Value": "TKU3XXXXXX"
},
{
"Key": "ReceiverPartyPublicName",
"Value": "254708374149 - John Doe"
}
]
},
"ReferenceData": {
"ReferenceItem": {
"Key": "QueueTimeoutURL",
"Value": "https://internalsandbox.safaricom.co.ke/mpesa/b2cresults/v1/submit"
}
}
}
}The request timed out in M-PESA's queue
Sent to QueueTimeOutURL from your request.
M-PESA could not process the request in time. Its outcome is unknown: check with the Transaction Status query before retrying a payment.
| Field | Type | Description |
|---|---|---|
Result | objectRequired | |
Result.ResultType | integerRequired | |
Result.ResultCode | integer or stringRequired | 0 means success. Some APIs send it as a string. |
Result.ResultDesc | stringRequired | |
Result.OriginatorConversationID | stringRequired | |
Result.ConversationID | stringRequired | |
Result.TransactionID | string | |
Result.ResultParameters | object | |
Result.ResultParameters.ResultParameter | array of object or object | One item or a list, depending on the API. |
Result.ResultParameters.ResultParameter[].Key | stringRequired | |
Result.ResultParameters.ResultParameter[].Value | string or number | |
Result.ReferenceData | object | |
Result.ReferenceData.ReferenceItem | array of object or object | |
Result.ReferenceData.ReferenceItem[].Key | stringRequired | |
Result.ReferenceData.ReferenceItem[].Value | string or number |