If your wondering what exactly is a webhook, here is the definition:
A webhook (also called a web callback or HTTP push API) is a way for an app to provide other applications with real-time information. A webhook delivers data to other applications as it happens, meaning you get data immediately.
Unlike typical APIs where you would need to poll for a status check very frequently in order to get your transaction status in real-time, the Reloadly webhook makes communication flow more efficient for both Reloadly and your system.
The only drawback to webhooks is the difficulty of initially setting them up. But don't get discouraged, we will guide you every step of the way and we have an awesome support team that can help you too!
First step: Creating the Webhook Endpoint
Follow the developers guideline to create the webhook endpoint, a HTTPS url.
Second step: Configuring the Webhook Endpoint
Once you’re done creating you webhook endpoint, the next step is to configure it on Reloadly. This can be achieved by registering your webhook on the Reloadly dashboard via a 3-step process:
Navigate to Developers > Webhook on your Reloadly dashboard and click Enable:
Then click on the Add Webhook button:
Add the URL of your webhook endpoint, select the service that your webhook will cover and also the event you want the webhook to receive notifications for:
Here you will also access your webhook signature secret which is used to verify the authenticity of every event you receive from Reloadly.
Once your webhook has been configured, you will receive callbacks from Reloadly for every event that you specified when configuring your webhook. The payload will be in JSON format. If you have multiple webhooks configured, be sure that the event type you are listening for is the same as the event type on each callback received before taking further action.
Your endpoint must quickly return an HTTP successful status code
200 to acknowledge that the notification was received. Delays on this could lead to a timeout which Reloadly will interpret as a failure and will continue to send you the callback for a maximum of 10 times.
If you do not respond to any of these, Reloadly will not attempt to send you the transaction status message for that specific transaction any more and assume that you have consumed it successfully.
There are certain requirements to be fulfilled in order to consume the airtime status:
Your webhook endpoint must be idempotent. Messages are delivered with “at least once” delivery semantics.
When you receive the callback for a specific transaction, you would need to respond with a HTTP status code 2xx to acknowledge receipt of the transaction status message.
If you don’t return a HTTP status code 2xx, Reloadly will interpret it as a failure and will continue to send you the callback for a maximum of 10 times. If you do not respond to any of these, Reloadly will not attempt to send you the transaction status message for that specific transaction any more and assume that you have consumed it successfully.
You would need to return the HTTP status call and process the data asynchronously. Avoid doing voluminous processing in the same processing thread in which you get the callback since that will keep the webhook call waiting. If you hold on to the thread for too long (> 3 seconds), Reloadly terminates the call and assumes that you have successfully consumed the message.