What are Webhooks?

The Startup CTO
6 min readJan 21, 2021

--

If you’re a developer in 2021 you’ve probably heard of webhooks before. With so many services like Stripe, Slack, Github, Discord, Zapier, IFTTT offering webhooks as an integration mechanism, they’re hard to avoid. At LogicLoop, webhooks are an integral part of our offering as they allow our users to connect our platform with other services. Let’s dive deep into what they are and why they’re so valuable.

Webhook vs API

Webhooks are like a reverse API call. A third party service provider will call its customer’s endpoint to notify the customer’s system of an event that has occurred. Usually this is because the service provider has to do some sort of asynchronous processing that can take an indeterminate amount of time and instead of having the customer continuously poll for a result, the service provider will just send a webhook when the event has finished processing.

How do webhooks work?

This is best illustrated with an example. Stripe is one of the most popular payment processors on the internet and they use webhooks to notify their customers when a payment has finished processing. If you are a Stripe customer and you use payment methods like ACH transfer, which can take a few days to process, Stripe will send you a webhook to let your system know when that payment has successfully processed. If Stripe did not offer that webhook call, you would have to continuously poll Stripe’s API every hour or so in order to find out when the payment has processed. While continuous polling is strategy that some developers use, it can become pretty resource intensive and inefficient at scale. Moreover, webhook events are generally sent instantly and in real-time so you know immediately when an event has occurred instead of waiting until the next time your system polls for an event.

In layman’s terms, let’s say you wanted to buy the hot new Playstation that just came out from your local GameStop. In this case, GameStop is the service provider and you are the customer. You can continuously call GameStop every hour to see if the Playstation is in stock yet, but the store associate will get very annoyed. Instead, GameStop can just call you back once to let you know when it is available. That call back is the “webhook” call.

Don’t call us, we’ll call you back

How to set up webhooks in practice?

How do you actually set up webhooks? If you are a customer on the webhook consumption side, your service provider will usually have some sort of interface where they let you add endpoints for them to call.

Here is what the Stripe webhook configuration Dashboard looks like

Your service provider will send a HTTP POST request to a unique URL endpoint that your developers set up to handle the results of that webhook event. They will also provide a payload in the body of the POST request that can give you detailed information your system may need to process that event.

If, on the other hand, you are a service provider on the webhook production side of the equation and you want to set up a system where you can notify your customers of events happening on your platform, that is a longer story.

How the best in class offer webhooks

Now that we know what webhooks are, let’s take a look at the webhook offerings of a few top companies: Stripe, Slack, Twilio, and Github.

Stripe

Stripe’s webhook Dashboard

Stripe offers webhooks to notify developers when important events happen on the platform, such as when an asynchronous payment methods processes or when a new invoice is generated. Stripe’s webhook offering is quite comprehensive and they actually send events every time an important object is created or updated, so you can actually use their webhooks to sync Stripe’s data to your own database.

What’s cool about Stripe’s offering that we have not seen many other companies offer is that they include a CLI where you can test out webhook events to your local machine! No surprise given the company is known for being very developer experience friendly.

Slack

Slack’s most popular use case for webhooks is for the opposite use case which is incoming webhooks. If you want to create an application that posts messages to Slack when interesting events happen in your system, you can create a Slack webhook endpoint with a unique URL your system can make a POST request to. When you call that URL, you will see your message show up on the designated Slack channel!

POST https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX Content-type: application/json {     "text": "Hello, world." }

A Slackbot notification

Twilio

Twilio’s webhooks send information to your servers about events that have just occurred. For example, you may elect to get a webhook event every time a text message is sent to a Twilio phone number.

Twilio webhooks diagram

Twilio’s webhooks fall into two categories: one of which is simply informative and tells your application what has happened in the Twilio ecosystem, and another which requires your servers to take some sort of action in response.

An example that falls into the first category is Twilio might send you a webhook event when a voice mail is ready for download.

An example that falls into the second category, as depicted in the diagram above, is when your webhook server can respond to a Twilio event letting Twilio know programmatically how to respond when one of your phone numbers is called.

Github

Github’s webhooks allow you to build integrations that respond to various Github events such as when a pull request is reviewed or when a build is finished running. You can use these notifications for example, to update external issue tracking services you may use such as JIRA, or even block or kick off a code deployment.

Github webhook set up

Github does a good job of showing you a log of all your webhook deliveries and well as details into which ones failed, which is crucial in helping developers debug their integrations.

LogicLoop

LogicLoop is a low-code platform that allows you to write SQL queries on top of your database in order to trigger alerts and automations. We support webhooks at LogicLoop in order allow our users to trigger a variety of actions when their SQL rule runs. For example, you might want to receive an alert whenever a new user signs up on your platform. You may set up a SQL query on LogicLoop like so:

SELECT 
*
FROM
users
WHERE
created_at > current_date - interval ‘1 days’

Then, you can call any API endpoint to get notified of this new user’s signup. This can be Slack’s incoming webhook endpoint to post an alert to Slack, or Stripe’s API to create a new Stripe customer, or an API in your own internal systems. The possibilities are endless.

This was a brief tour of how a few of the most popular B2B applications on the internet utilize webhooks to give their developers a richer experience and create a more integrated and sticky platform. By supporting webhooks, these companies have no doubt enriched the ecosystem around their products, catapulting them into the behemoths they are today.

Now that you’ve read this article you will start seeing webhooks everywhere. It’s hard to unsee them. Good luck!

Sign up to discover human stories that deepen your understanding of the world.

--

--

The Startup CTO
The Startup CTO

Written by The Startup CTO

👋 Hi, I’m Cofounder & CTO of www.logicloop.com — trigger alerts and automations on top of your data. Follow along for all things startups and engineering.

No responses yet

Write a response