Skip to content

Mpesa Query API

Tip

  • All requests are Post requests, and the data format is json
Brief Description
  • Check transaction results by MPESA transaction codes
Request URL
  • /api/queryResultByCode
Request Method
  • Method: POST
  • Content-Type: application/json
Name required type desc
merchantNo Yes String -
Body
Name required type desc
code Yes String MPESA transaction codes
timestamp Yes String Timestamp (1715941383720)
sign Yes String Except for the sign field, all remaining fields should be sorted alphabetically by their first letter, combined into key1=value1key2=value2, and encrypted using the app secret as salt via MD5. The final sign value should be in lowercase.
Request Parameter Example
{
    "code": "SHL2A6WAQU",
    "timestamp":"2222222222",
    "sign": "000000000"
}
Response Result
Name required type desc
msg Yes String Request result (when returning success, it only indicates that the request was successful and cannot be used for merchant-side logic judgment)
code Yes String Request response code (when returning 0000, it only indicates that the request was successful and cannot be used for merchant-side logic judgment). For specific error codes, please refer to the business error code enumeration.
timestamp Yes String Transaction time
success Yes String Transaction result
data Yes Object Return object
data.platFormTradeNo Yes String MPESA transaction codes
data.amount Yes String transaction amount
data.status Yes String Request result, merchants can use this for logic processing. When the result is 0000, it indicates a successful transaction; 0015 indicates processing; all other codes indicate errors and can be treated as failures.
data.message Yes String Error description
data.mpesaReceiptNumber Yes String MPESA transaction codes
data.successTime Yes String Transaction success time (Kenya time)
{
    "msg": "success",
    "code": "0000",
    "timestamp": 1719830071094,
    "success": true,
    "data": {
        "platFormTradeNo": "5286e98841194687a95d25b5f3be346d",
        "tradeNo": "00000020",
        "amount": 3.0000,
        "status": "00029",
        "mpesaReceiptNumber": "SHL2S6WAAU",
        "message": "REJECTED_TRANSACTION",
        "successTime": "2024-07-01 18:34:31"
    }
}