Here's the one-line answer: a webhook is an automated message a system sends to another the instant something happens — a payment succeeds, a form is submitted, code is pushed — by making an HTTP request to a URL you gave it in advance. If a normal API is you walking up to a counter and asking "anything new?", a webhook is the counter calling you the moment there is. It's often described as a "reverse API," and once that clicks, a huge amount of modern software suddenly makes sense.
Webhooks are the quiet engine behind real-time software: Stripe telling your app a card was charged, GitHub kicking off a deploy when you push, Slack reacting to a message. In this guide I'll explain what a webhook is, exactly how the request/response works, why it beats constantly polling an API, and how to build and secure a receiver — with real code and clear tables for GET vs POST and webhook vs API. By the end, you'll be able to reason about webhooks with confidence.
The core idea: don't call us, we'll call you

Imagine you're waiting on a package. You have two options.
- Option one: walk to the front door every five minutes to check if it arrived. Exhausting, and it's almost always a wasted trip.
- Option two: install a doorbell. Do nothing, live your life, and the instant the package arrives, the bell rings.
The first option is polling an API — asking again and again, "Any updates? Any updates?" — and wasting almost every call. The second is a webhook: you register once, then the event comes to you the moment it happens. A webhook is the doorbell for software.
That single shift — from repeatedly asking to being told — is the whole concept. Everything below is how it works in practice.
Webhook vs API polling: the difference that matters
People often frame this as "webhook vs API," but that's slightly off: a webhook uses an API — it's just the API calling you instead of the other way around. The real contrast is between polling (you ask) and webhooks (you're told).
| Factor | API polling | Webhook |
|---|---|---|
| Who starts it | You, repeatedly asking | The source system pushes to you |
| Timing | On your schedule (every X seconds) | Instantly, when the event happens |
| Efficiency | Wasteful — most checks return nothing | Efficient — fires only when there's news |
| Direction | Your app → their server | Their server → your app |
| Setup | You call their endpoint | You register your endpoint (URL) |
| Best for | Data you need on demand | Real-time reactions to events |
The efficiency gap is enormous. Polling an API every minute for an event that happens twice a day is thousands of pointless requests; a webhook makes exactly two. That's why event-driven systems lean on webhooks.
How a webhook works, step by step

The flow is short and always the same:
- You register a URL (your "webhook endpoint," like `https://yourapp.com/webhook`) with the source service, and tell it which events you care about.
- An event happens on the source side — a customer pays, someone stars your repo.
- The source service sends an HTTP POST request to your URL, with the event details in the body (as JSON).
- Your server receives that request, reads the data, and does whatever it needs to — update a database, send an email, start a build.
- Your server responds with a success status (like 200 OK) to acknowledge it. If you don't, the sender assumes failure and retries later.
That's the entire lifecycle: register once, then receive a POST per event and answer 200. The magic is only in the details — the payload format, and keeping it secure.
Webhook vs a regular API call
To be crystal clear about how a webhook relates to a normal API request:
| Regular API request | Webhook | |
|---|---|---|
| Who makes the request | Your app | The source service |
| When | Whenever you decide | When an event fires |
| You provide | Their endpoint URL | Your endpoint URL |
| Typical method | GET (to read) | POST (to deliver data) |
| You are the… | Client | Server / receiver |
Notice the roles flip. In a normal API call your app is the client asking a server. With a webhook, your app itself is the server, and the other service is the client calling you. That reversal is why "reverse API" is such a fitting nickname.
Why webhooks use POST, not GET

Webhooks almost always arrive as POST requests, because POST is built for sending data while GET is built for retrieving it. A webhook's whole job is to hand you a chunk of event data (the payload), so it needs a request body — and GET requests don't carry one. Here's the distinction:
| GET | POST | |
|---|---|---|
| Purpose | Retrieve / read data | Send / submit data |
| Where the data goes | In the URL (query string) | In the request body |
| Has a body | No | Yes — the JSON payload |
| Used by webhooks | Rarely | Almost always |
| Cacheable | Yes | No |
| Safe to repeat | Yes (no side effects) | No (may create/change things) |
| Data visible in the URL | Yes | No — it's in the body |
Because a webhook delivers meaningful data that often triggers an action (charge an order, start a deploy), POST is the correct, semantic choice. A rare few webhooks use GET for trivial pings, but if you're building one, use POST.
What a webhook request actually looks like
When a service like Stripe sends a webhook, the raw HTTP request looks roughly like this — a POST, some headers (including a signature for security), and a JSON body describing the event:
The important parts: the type field tells you what happened, and the data object carries the details. Your job is to read those and react.
Building a webhook receiver (with code)
A receiver is just a normal web server with a route that accepts POST. Here it is in Node.js with Express:
The same idea in Python with Flask is just as short:
Securing your webhook (this is not optional)
Your endpoint is a public URL, so anyone could POST fake events to it. Reputable services solve this by signing each request: they compute a hash of the payload using a secret only you and they know, and send it in a header (like Stripe-Signature). You recompute the same hash and compare — if they don't match, reject it.
Three rules that keep webhooks safe and reliable:
- Verify the signature on every request and reject anything that fails.
- Use HTTPS so the payload can't be read or tampered with in transit.
- Handle duplicates. Networks retry, so the same event can arrive twice. Store each event's unique id and ignore ones you've already processed (this is called idempotency).
The status codes your receiver should return
The sender decides whether to retry based on the status code you return. Send the right one:
| Code | Meaning | When to send it |
|---|---|---|
| 200 / 204 | Success | You received and accepted the event |
| 400 | Bad request | The payload was malformed |
| 401 | Unauthorized | The signature or secret was invalid |
| 429 | Too many requests | You're rate-limiting the sender |
| 500 | Server error | Your handler crashed — sender will retry |
The key habit: return a 2xx as soon as you've safely accepted the event. Returning 500 (or timing out) tells the sender to try again, which is what you want on a real failure — but not something you want to trigger by accident with slow code.
Where you already rely on webhooks
Webhooks are everywhere once you know the name:
- Payments — Stripe or PayPal notifying your app that a charge succeeded or a subscription renewed.
- Git and CI/CD — GitHub sending a "push" event that triggers your build and deploy pipeline.
- Messaging — Slack, Discord, or Twilio delivering incoming messages to your bot in real time.
- E-commerce — Shopify pinging your systems when an order is placed or fulfilled.
- Automation platforms — Zapier, Make, and n8n listen on webhook URLs so one app's event can instantly trigger a workflow.
That last one matters for non-developers: no-code tools give you a webhook URL to paste into any service, then let you build the reaction visually — no server required.
How to test a webhook locally
The classic hurdle: a webhook needs a public URL, but your code runs on localhost, which the outside world can't reach. Two easy fixes:
- Use a tunnel like ngrok to expose your local server on a temporary public URL you can register as the webhook endpoint.
- Use an inspection tool like webhook.site or RequestBin to see exactly what a service sends before you write any code — great for discovering the payload shape.
Most serious webhook providers (Stripe, GitHub) also offer a dashboard to view deliveries, inspect payloads, and re-send events — invaluable when debugging.
Frequently asked questions
The bottom line
A webhook flips the usual request around: instead of your app constantly asking an API "anything new?", the service sends an HTTP POST to your URL the instant something happens. It's the doorbell for software — register once, then react in real time. Learn the loop (register a URL → receive a POST → return 200), respect the two rules that make it robust (verify signatures, handle duplicates), and you can wire almost any two systems together to react instantly.
Webhooks and APIs are two halves of the same skill. If you haven't yet, read the companion guide on how APIs work — together they cover most of how modern software talks to itself.


