DEV Community

ADEKOLA Abdwahab
ADEKOLA Abdwahab

Posted on • Edited on

How does webhook works

Here is a video link to this explanation: https://youtu.be/SP4x9VHNEC8

A quick analogy for a webhook is a SMS and email credit alert we (Nigerians) get. Instead of checking your account every second to know when someone pays you (when an event happens on your account), they send messages to your provided email / phone number.

In the Dev world, this would be easier for a developer who has developed and interacted APIs before to grasp.

APIs (URL) are called to ask for some information (resources) or perform some actions on some resources.

A simple example of API calling is that a front-end will call a backend API when a user wants to login (an event). Let say this happens on a platform called FlutterHook.

"I don't want to be checking myself to know when a particular event happens on your system/server, so when this event happens on your system/server let me know by calling this my URL"

That's what webhook system is all about. Instead of polling (asking and checking up by yourself) the system will alert you.

A more practical example is:

If you are treasurer of a big school which has merchant account on Flutterwave and the students pay school fees via Flutterwave, you don't want to be checking your Flutterwave dashboard every time to know who has paid then update the students' records on the school app.

In this case, what can be done is to provide an API URL (that points to the school server) on Flutterwave as a webhook. Flutterwave will then send you / call that API endpoint with the details of any payment (event). So you don't have to be checking yourself.

When Flutterwave calls that API endpoint you (a Dev) can then work on the logic and update the DB / students record accordingly.

Top comments (0)