What are webhooks used for?
Webhooks typically are used to connect two different applications. When an event happens on the trigger application, it serializes data about that event and sends it to a webhook URL from the action application—the one you want to do something based on the data from the first application.
(The term webhook generally means posting an event to another system over the web through an API. Webhooks use HTTP POST messages to trigger actions in another application when an event fires. The current standard data format for this is JSON, but it's possible to build a webhook system using SMS or SMTP events)
Webhook vs API
An API is a messenger that delivers your request to the provider you're requesting it from and then responds to you. On the other hand, Webhook, also called reverse API, web callback, or an HTTP push API, is a way for an app to provide other applications with real-time information.
There are two key differences between APIs and Webhooks: Who calls them, and what’s the flow of information in them.
In APIs, the initiator of the connection is you. For example, you make a change to the service or check the service for an update. But in Webhook, the service is the initiator, and when the update occurs, it’s the service that calls you (or another service). It’s quite important when your actions are dependent on the events on the service, and you want to get informed as soon as they occur.
In APIs, the flow of data is two-sided. You can send and receive the data to and from the service. But in webhooks, the flow is one-sided and you only receive the data from the service.
Please note that APIs and webhooks can be used simultaneously. For example, when you receive a webhook call from the service (which indicates a specific event), you can use API to send back an update to the service regarding the event.