APIs are not the same as Webhooks. APIs are request-based models that provide results when a request is made, while Webhooks are event-based, meaning they give results as the events change states.
Webhook process
Webhooks provide a mechanism for real-time updates based on resource availability. Consider a scenario where timely information is crucial for effective inventory management in a retail setting. Rather than constantly checking for stock availability, a more streamlined approach is implemented. Registering interest with the inventory provider and supplying relevant contact details sends notifications once the desired resources become available, paralleling the functionality of webhooks.
The webhook provider establishes a webhook to notify third-party app providers, such as ourselves, about the status of available resources. Upon replenishing the stock, the webhook provider initiates an HTTP POST request to the specified URL, leveraging listeners (contact information). Subsequently, third-party app providers can utilize the available resources according to their requirements. The webhook process unfolds as follows:
- Resources ready for allocation (Event)
- The inventory provider notifies us (via listeners) upon stock replenishment
- We retrieve the resources (HTTP POST request fires as a callback)
- We employ the resources as needed (third-party providers)
In contrast, if a similar operation were conducted using APIs, the process would not involve waiting for the inventory provider to initiate contact regarding stock updates. APIs operate on request, where a request made to the API provider yields a response containing the requisite information. Consequently, maintaining the resource stock becomes essential to keep the API endpoint accessible for request initiation.
For instance, consider creating an API for location-based services. In this context, soliciting information about a specific location would involve a GET request to the servers to retrieve the necessary data.
So, when we ask for resources from the third-party provider, we send a GET request to the servers. For example, you create an API for maps.
Simply put, webhooks are your go-to when you need updates triggered by events. APIs, on the other hand, are the speedy solution for situations demanding instant access to fresh information.
Understanding these distinctions allows for informed decisions when choosing between webhooks and APIs based on the specific requirements of a given application or system.
Use of Webhooks at Insider
We, at Insider, use Webhooks to automate email marketing. Insider helps you to create email marketing lists either manually or automatically. Tasks like adding a new user when they sign up or deleting a user when they unsubscribe can be extremely tedious. Therefore, we handle such requests by automatically updating the database using Webhooks:
- When a user joins the list
- An email gets delivered, clicked, opened, unsubscribed, or marked as spam
- Real-time user interactions updated in the database
- Automatic or manual user segmentation
You can also choose to react to certain events using webhooks. Like:
- React to spam reports
- Identify bounced email addresses
- Create analytics for your email program
Once you set this webhook, you will receive POST requests for the specified URL. So, are you ready for automatic event updates using Insider Webhooks with Insider?