Skip to content

Webhook

A webhook is a user-defined HTTP callback: the service POSTs to a URL you provide when an event happens, pushing data in real time instead of forcing you to poll for it.

Definition

What it is

A webhook inverts the direction of the conversation. Instead of your application asking "did anything happen?" every minute, the service calls you when something happens. You register a URL (https://your-app.com/webhooks/stripe), the service stores it, and when the event fires, the service POSTs the event payload to that URL.

The concept is old in event-driven systems and new in the web era. It was formalized as the term webhook by Jeff Lindsay around 2007, in a post titled "Giving Web Applications a Voice". GitHub, Stripe, Shopify and Slack turned the pattern into an industry standard.

Why it matters

Polling is simple to build and expensive to run: every minute, every client asks "anything new?", and the server answers "no" 99% of the time. Webhooks reverse the economics: the server notifies once, when the event fires. Latency drops from "up to one poll interval" to "seconds", and the wasted requests disappear.

Webhook vs polling vs WebSocket vs SSE

Aspect

Webhook

Polling

WebSocket

SSE

Direction

Push (server → your URL)

Pull (client → server)

Bidirectional

Server → client

Latency

Seconds

Poll interval

Real time

Real time

Connection

Per-event HTTP POST

Per-request HTTP

Long-lived socket

Long-lived HTTP

Use case

Integrations, events

Simple status

Chat, collaboration

Feeds, dashboards

Retry

Depends on sender

Client retries

Connection re-establish

Auto-reconnect

The webhook flow

sequenceDiagram
  participant C as Consumer
  participant P as Producer
  participant U as Consumer URL
  C->>P: POST /webhooks {url, events}
  P-->>C: 201 Created
  Note over P: Event happens
  P->>U: POST /webhooks/stripe {payload, signature}
  U-->>P: 200 OK
  Note over P: If no 2xx, retry with backoff

The webhook lifecycle

  1. 2007 — Jeff Lindsay coins "webhook" in a blog post.

  2. 2011 — Stripe ships webhooks as a first-class feature.

  3. 2013 — GitHub launches webhooks for repository events.

  4. 2015 — Slack opens Events API based on webhooks.

  5. 2017 — Stripe introduces HMAC-SHA256 signatures on webhooks.

  6. 2020 — Standard Webhooks specification effort begins.

  7. 2023 — Most major platforms sign and version their webhooks.

How to build a webhook consumer

Consuming a webhook safely

  1. Verify the signature

    Use HMAC-SHA256 with a shared secret and the raw body. Reject anything that does not match.

  2. Deduplicate by event ID

    Webhooks deliver at least once. Store processed event IDs and ignore duplicates.

  3. Respond fast

    Return 2xx within 5 seconds. Push the payload onto a queue and process it in the background.

  4. Make the endpoint idempotent

    Two deliveries of the same event must not create two orders.

  5. Monitor and retry

    Log every webhook. Alert on failures. Let the sender retry; if it doesn't, retry yourself.

Common failures

Origin

The word is a compound of web and hook. Hook in computing means an extension point: a function or URL where external code is called by a framework. Jeff Lindsay combined the two in a blog post titled "Giving Web Applications a Voice" (2007), describing a way for web applications to notify each other via HTTP callbacks. The term spread rapidly; Stripe, GitHub and Slack normalized it into an API convention. The metaphor survived: a webhook is a hook where events land.

Webhooks are user-defined HTTP callbacks. They are usually triggered by some event, such as pushing code to a repository or a comment being posted to a blog.

— Jeff Lindsay, "Giving Web Applications a Voice", 2007
2007 · Jeff Lindsay acuña "webhook"
2011 · Stripe lanza webhooks
2013 · GitHub webhooks
2017 · Stripe firma con HMAC-SHA256
2023 · La mayoría de plataformas firman webhooks

Evidence

FAQ

Webhook vs API?

An API is pull: you call the server. A webhook is push: the server calls you. Most platforms use both: webhooks for events, APIs for queries.

Why verify signatures?

Because the endpoint is public. Without verification, anyone can POST a fake event. Signatures prove the payload came from the expected sender.

What about retries?

Every serious platform retries failed webhooks with exponential backoff for hours or days. Your endpoint must be idempotent.

Can webhooks replace polling entirely?

No. Webhooks are unreliable by design. Keep a reconciliation job that polls daily, to catch the events webhooks lost.

Connections

Etymology

Origin: compound

  • web (noun): from Old English webb, "woven fabric"; extended to the World Wide Web
  • hook (noun): Old English hōc, "a curved piece of metal"; in software, an extension point

Semantic network

Webhookintegratioevent-drivapicallbackSignatureIdempotentpolling

● broader ● narrower ● related

Broader

  • integrations
  • event-driven-architecture

Related

Used in the garden

Sources