Getty Images
Webhooks explained simply, with examples
Webhooks make significant use of basic API call mechanisms and set event triggers in a few clicks of a button -- all without the overhead of heavy request-response structures.
From system failure events to trade and stock notifications, modern software simply cannot wait for a polling process or a nightly refresh. Enter webhooks -- one way to integrate systems by a series of near-instant message updates, each tied to an independent event.
This article explains the basic process and principles of how webhooks work -- including how they differ from APIs -- and then presents some everyday examples of webhooks in action.
What are webhooks?
Webhook is a term used to describe a callback method in which one software system uses APIs to instantly notify another of an event. That means one application can send a web-based message request every time a qualifying event happens. To use webhooks effectively, the notifying system must possess the ability to register events and link them to a URL. When a particular event happens, like a buy order on a trading desk, the URL is called over the web with a payload of the event.
An API (in the form of the new URL) will then notify a second system. This flips the idea of the API around: The platform isn't asking for anything but instead relays its request message. Exactly what message this contains, as well as where it goes, is completely customizable, requiring only a user-supplied recipient web address.
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. Developers can create command lines, set up configuration files or pipe it directly through a user interface to achieve this.
Webhook examples
A webhook needs two things: a sender and a receiver. The sender must be configured to recognize that an event has occurred. It can then notify the receiver -- an application with an API to send the messages to -- of the event. Webhooks are an easy way to send text-based responses to users when certain events occur inside an application. Most modern platforms such as Gmail, Slack, Discord, GitHub and Google Calendar support webhooks or a similar architectural approach.
Some real-world examples of webhooks include the following:
- Instagram photos that automatically upload to X, formerly known as Twitter.
- A connected doorbell configured to flash certain lights inside a home as it rings.
- Sending GitHub update notifications to Slack or Discord channels as messages.
- Creating a Microsoft Teams channel that relays messages when people buy or sell certain stock s.
APIs respond to requests; webhooks are a messaging strategy that is event-based. Thus, the webhook will call the downstream system's API when something happens. For instance, let's say a developer runs a Discord channel related to a GitHub project and wants to have an automated message alert the channel to any new code updates that occur in the public repository. By adding a webhook using Discord's channel integration options, GitHub will not only send an automated message to the channel based on certain predetermined events but also configure it as a link to a page that shows the details of the change.
Matt Heusser is managing director at Excelon Development, where he recruits, trains and conducts software testing and development.