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 |
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 |
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
2007 — Jeff Lindsay coins "webhook" in a blog post.
2011 — Stripe ships webhooks as a first-class feature.
2013 — GitHub launches webhooks for repository events.
2015 — Slack opens Events API based on webhooks.
2017 — Stripe introduces HMAC-SHA256 signatures on webhooks.
2020 — Standard Webhooks specification effort begins.
2023 — Most major platforms sign and version their webhooks.
How to build a webhook consumer
Consuming a webhook safely
Verify the signature
Use HMAC-SHA256 with a shared secret and the raw body. Reject anything that does not match.
Deduplicate by event ID
Webhooks deliver at least once. Store processed event IDs and ignore duplicates.
Respond fast
Return 2xx within 5 seconds. Push the payload onto a queue and process it in the background.
Make the endpoint idempotent
Two deliveries of the same event must not create two orders.
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
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
- api
- callback
- signature
- idempotent
- polling
- event-driven
Stripe (2024). Webhooks. https://stripe.com/docs/webhooks
GitHub (2024). Webhooks documentation. https://docs.github.com/en/webhooks
Standard Webhooks (2023). Standard Webhooks Specification. https://github.com/standard-webhooks/standard-webhooks
Jeff Lindsay (2007). Giving Web Applications a Voice. https://progrium.github.io/blog/2007/06/29/webhooks/
Etymology
Origin: compound
web(noun): from Old English webb, "woven fabric"; extended to the World Wide Webhook(noun): Old English hōc, "a curved piece of metal"; in software, an extension point
Semantic network
● broader ● narrower ● related
Used in the garden
- Mastering Headless: Directus & Next.js for Hyper-Efficient SaaS Devs (3×)
- Unleash Linux Power: Bash Scripting Secrets for LatAm Founders (1×)
- Algorithmic Arbitrage: Capitalizing on B2B Marketplace Inefficiencies (1×)
Sources
Stripe (2024). Webhooks. https://stripe.com/docs/webhooks
GitHub (2024). Webhooks documentation. https://docs.github.com/en/webhooks
Standard Webhooks (2023). Standard Webhooks Specification. https://github.com/standard-webhooks/standard-webhooks