Learn how to use webhooks to receive Mambu Payments (formerly Numeral) events in your application
1. Introduction to webhooks
Mambu Payments uses webhooks to notify your application when an event is created. Webhooks are particularly helpful for asynchronous events, such as a payment being executed by the bank or an account statement being received from a bank.
Events are created when an object is created or updated, either by a user using the API or the dashboard or by Mambu Payments (formerly Numeral). An update can be the update of any attribute, such as a status, a date, or any other data.
For each event, Mambu Payments (formerly Numeral) will send a POST request to your API endpoint in JSON format. This API request contains an event object.
2. Registering a webhook
In order to use webhooks, you should create a webhook on your server and register it in the Mambu Payments dashboard. To register a webhook, go to Developers > Webhooks > Add webhook.
3. Event delivery modes
Webhook support multiple event delivery modes.
| Delivery mode | Order guaranteed | Throughput | Default delivery mode |
|---|---|---|---|
| Individual events | Yes | Base | ✅ |
| Batched events | Yes | High | - |
| Parallel individual events | No | High | - |
| Parallel batched events | No | Highest | - |
The order is defined as the order of events for a given object, based on its lifecycle.
To guarantee order, Mambu Payments (formerly Numeral) waits for the acknowledgment of receipt of an event before sending the next event. This means, for instance, that a payment_order.processing event will always be sent before a payment_order.sent event, as per the payment order lifecycle.
There are some edge cases where the order of the messages delivery is not deterministic (or might not be as you expect). For example, if you create a payment order via a sync HTTP API call, you may receive a notification that the payment order is pending_approval even before you get a response for the sync HTTP API call to create the payment order.
When events are sent in parallel, Mambu Payments (formerly Numeral) does not wait for the acknowledgment of receipt of an event before sending the next event. As a result, order is not guaranteed. As an example, payment_order.sent might be delivered before payment_order.processing event.
The maximum number of events in a batch is currently set to 100 for deliverability and performance reasons. Higher limits can be discussed on a case-by-case basis.
Contact us at [email protected] if you would like to receive events other than as individual events.
4. Webhook event idempotency
In order to guarantee that each event is unique, every webhook payload includes an idempotency_key attribute within its JSON body. Additionally, when an event is sent individually, the TX-Webhook-ID HTTP header is set to the value of the idempotency_key.
The idempotency key is unique for each event / webhook combination. Therefore, if an event is sent multiple times, it will always carry the same idempotency key value, avoiding duplication error
5. Verifying webhooks
Webhooks sent by Mambu Payments (formerly Numeral) are signed so that you check that they have not been modified in transit and verify their authenticity. They also originate from a limited list of IPs. Read our dedicated guide to learn how to verify webhooks.
6. Acknowledgment of receipt
To acknowledge the receipt of an event, your API endpoint must respond with a 2xx HTTP status code to Mambu Payments (formerly Numeral) within 5 seconds.
To guarantee that your webhook receives the events in the correct order:
- The next event is sent once the previous event has been received
- Events are delivered steadily over time one by one
- The processing of events stops at the first failed event
7. Exponential back-off strategy
If your API endpoint takes longer to respond or returns an HTTP status code different from 2xx, the event will be set to pending_retry status and re-sent up to 5 times during a ~2.8-hour period using an exponential back-off strategy. The event is set to failed status after 6 unsuccessful deliveries.
If the event delivery mode is sequential or batched, the processing of the events stops in order to guarantee the order of receipt.
8. Retry events in case of webhook failure
To retry events after you have restored a webhook, use the Retry failed events API endpoints.
9. Re-send an event already delivered
To re-send an event previously successfully delivered to the same or another webhook, use the Resend event API endpoint. This can serve different operational purposes like data analysis or reporting.
