Webhooks / Callback Url

The webhooks/callback url provide real-time notifications after successfully consuming the API. These events could range from a successful transaction to a failed transaction.

The webhook/callback url should be valid for your system to get a response. If your server or webhook is not reachable, we try a maximum of 4 times, every 120 seconds to reach the webhook.

Some examples of events that you could be notified of include:

  • When you receive a payment transaction.

  • When you performed a successful payout transaction.

  • When you performed a failed transaction.

Sample webhook response on a successful Mpesa payment:

{
    "Message":"Successful",
    "Success": true,
    "Status": 200,
    "Amount": 100,
    "transaction_code": "QWERTY1234",
    "transaction_reference": "12345678901345644",
    
}

Some examples of things you could do with our webhooks include :

  • Update your database when the status of a pending payment is successful.

  • Notify a customer when payment is successful or unsuccessful etc.

Sample webhook response on failed payment:

{
    "Message":"Request cancelled by user",
    "Success": false,
    "Status": 200,
    "transaction_reference":"12345678901345644"
}

For more information on the webhook responses check them out on Mpesa Payments, Card Payments, Mobile Payouts and Domestic Bank Payouts.

Last updated