Skip to main content
By Jonas AnderssonCo-founder
4 min read

Definition

What is a webhook?

A webhook is a way for one system to notify another that something has happened. When an event occurs in system A, a form submitted, a payment completed, a record updated, system A sends a notification to a URL in system B, immediately and automatically. System B does not have to ask. It just receives.

The alternative is polling: system B periodically asks system A "has anything changed since I last checked?" Polling works but is inefficient, most of the time nothing has changed, and every check that returns nothing is wasted work. Webhooks solve this by inverting the relationship: instead of the receiver asking, the sender notifies.

How it works

Three things that need to be in place for a webhook to work.

Component 1

An event in the sending system

Something has to happen for a webhook to fire. A new contact created. A deal moved to a new stage. An order completed. The sending system needs to be configured to fire the webhook when this specific event occurs. Most modern SaaS tools have webhook settings that let you choose which events trigger a notification and where to send it.

Component 2

A URL in the receiving system

The receiving system needs to expose a URL that it is listening on, a webhook endpoint. When the event fires in system A, system A sends an HTTP POST request to this URL, containing the event data as JSON. The receiving system processes the data and sends back a 200 response to confirm it received it.

If the receiving system does not respond with 200, the sending system usually retries. The retry logic varies by platform, some try three times, some try indefinitely with backoff. This is why a webhook endpoint that fails silently (returns 200 without actually processing the data) can cause problems: the sender thinks it worked, but it did not.

Component 3

Logic in the receiving system

Receiving the webhook is not the same as doing something useful with it. The receiving system needs logic that processes the incoming data and takes the appropriate action: creating a record, updating a status, triggering a workflow, sending a notification.

This logic is where most webhook implementations get complicated. The data that arrives may not match exactly what the receiving system expects. Fields may be named differently. Required fields may sometimes be missing. The receiving system needs to handle these cases explicitly rather than failing silently when the incoming data does not match the expected format.

The key difference from APIs

APIs pull. Webhooks push.

An API call is a request-response: you ask for data and get a response. You initiate it. A webhook is a notification: the other system tells you something happened. They initiate it.

Use an API when you need data on demand, you want to look up a specific record, run a query, or fetch the current state of something. Use a webhook when you need to react to events, something changed in another system and you want to know immediately rather than checking periodically.

In this articleTap to open the section map

The failure mode to know

A silent webhook failure is worse than a loud one. Return 200 without processing, and the sender thinks it worked.

The mitigation is logging: every incoming webhook should be logged with its payload, its processing result, and the outcome. When something seems wrong, the log tells you whether the webhook arrived, whether it was processed, and what happened when it was.

Key takeaways

  • A webhook pushes from the sender, the receiving system does not poll, it listens.
  • Three components required: an event trigger, a receiving endpoint, and logic to handle the payload.
  • A webhook endpoint that returns 200 without processing the data is a silent failure.

If you only remember one thing

APIs pull. Webhooks push. The difference determines who has to be paying attention.

Continue the thinking

Connections

Sources

References behind this piece

  1. About webhooks

    GitHub Docs

Jonas Andersson, co-founder of Mannvit Labs

Written by

Jonas Andersson

Co-founder, Mannvit Labs

Co-founder of Mannvit Labs, leading systems, data, automation, and technical delivery. He spent four years before this running e-commerce for a Swedish retailer, from SEO to campaigns.

He builds the internal tools and data workflows these guides come out of. See the builds.

  • Automation & workflow design
  • Operational systems
  • Commercial data & reporting