What Is a Webhook and How Does It Work? (2026 Guide)

Summarize this post with AI

A 20-minute read, or the key points in about 30 seconds, in the assistant you already use.

Opens in a new tab with the prompt filled in. Nothing passes through this site.

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

Comparison of API polling, where an app repeatedly asks a server for updates and mostly gets 'no', versus a webhook, where the server pushes a single notification the moment an event happens
Polling asks 'any updates?' over and over; a webhook is the doorbell — it fires once, the instant something happens.

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).

FactorAPI pollingWebhook
Who starts itYou, repeatedly askingThe source system pushes to you
TimingOn your schedule (every X seconds)Instantly, when the event happens
EfficiencyWasteful — most checks return nothingEfficient — fires only when there's news
DirectionYour app → their serverTheir server → your app
SetupYou call their endpointYou register your endpoint (URL)
Best forData you need on demandReal-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

How a webhook works: an event happens, the source app sends a POST request with a JSON payload to your endpoint URL, and your server replies 200 OK
The webhook lifecycle: an event triggers a POST to your URL, and you acknowledge it with a 200.

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 requestWebhook
Who makes the requestYour appThe source service
WhenWhenever you decideWhen an event fires
You provideTheir endpoint URLYour endpoint URL
Typical methodGET (to read)POST (to deliver data)
You are the…ClientServer / 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

GET versus POST: GET retrieves data with parameters in the URL and no body, while POST sends data in the request body and carries the JSON payload webhooks use
GET reads with data in the URL; POST sends data in the body — which is exactly why webhooks use POST.

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:

GETPOST
PurposeRetrieve / read dataSend / submit data
Where the data goesIn the URL (query string)In the request body
Has a bodyNoYes — the JSON payload
Used by webhooksRarelyAlmost always
CacheableYesNo
Safe to repeatYes (no side effects)No (may create/change things)
Data visible in the URLYesNo — 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:

http
POST /webhook HTTP/1.1
Host: yourapp.com
Content-Type: application/json
Stripe-Signature: t=1699999999,v1=5257a869e7ecebeda32affa62cdca3fa...

{
  "id": "evt_1P2x3Y",
  "type": "payment_intent.succeeded",
  "created": 1699999999,
  "data": {
    "object": {
      "id": "pi_3P2x3Y",
      "amount": 2000,
      "currency": "usd",
      "status": "succeeded"
    }
  }
}

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:

javascript
// server.js — a minimal webhook receiver in Node/Express
import express from "express";

const app = express();
app.use(express.json()); // parse the JSON body

app.post("/webhook", (req, res) => {
  const event = req.body;
  console.log("Received event:", event.type);

  // React based on the event type
  switch (event.type) {
    case "payment_intent.succeeded":
      fulfillOrder(event.data.object);
      break;
    case "customer.subscription.deleted":
      revokeAccess(event.data.object);
      break;
    default:
      console.log("Unhandled event:", event.type);
  }

  // Acknowledge FAST so the sender doesn't retry
  res.status(200).send("OK");
});

app.listen(3000, () => console.log("Webhook receiver on :3000"));

The same idea in Python with Flask is just as short:

python
# app.py — the same receiver in Python/Flask
from flask import Flask, request

app = Flask(__name__)

@app.route("/webhook", methods=["POST"])
def webhook():
    event = request.get_json()
    print("Received event:", event["type"])

    if event["type"] == "payment_intent.succeeded":
        fulfill_order(event["data"]["object"])

    # Return a 2xx to acknowledge receipt
    return "OK", 200

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.

javascript
import crypto from "crypto";

// Verify that a webhook really came from the source, not an imposter
function isValidSignature(rawBody, signature, secret) {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(rawBody)
    .digest("hex");

  // Constant-time compare avoids timing attacks
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

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:

CodeMeaningWhen to send it
200 / 204SuccessYou received and accepted the event
400Bad requestThe payload was malformed
401UnauthorizedThe signature or secret was invalid
429Too many requestsYou're rate-limiting the sender
500Server errorYour 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

What is the difference between a webhook and an API?▾
A webhook isn't the opposite of an API — it uses one. The difference is direction and timing. With a normal API call, your app is the client and requests data whenever it wants. With a webhook, the roles flip: the other service becomes the client and calls your app the moment an event happens. Same HTTP plumbing, reversed direction — which is why webhooks are nicknamed "reverse APIs."
Why do webhooks use POST instead of GET?▾
Because a webhook's purpose is to deliver data — the event payload — and POST is the HTTP method built for sending data in a request body. GET requests have no body and are meant only for retrieving data. Since a webhook hands you a JSON payload that often triggers an action, POST is the correct, semantic choice.
Are webhooks secure?▾
They can be, if you do your part. Because your endpoint is a public URL, you must verify that each request is genuine — typically by checking a signature the sender includes, computed with a shared secret. Always use HTTPS, verify signatures, and reject anything that fails. Skipping this lets anyone POST fake events to your app.
What happens if my server is down when a webhook fires?▾
Most providers retry failed deliveries on a schedule (often with backoff) for a period of time, so a brief outage usually won't lose events. But you shouldn't rely on that forever — return a 2xx quickly when you succeed, and for critical data, periodically reconcile via the provider's API to catch anything missed.
Can the same webhook event arrive more than once?▾
Yes, and you should plan for it. Retries and network hiccups mean a provider may deliver the same event twice. Make your handler idempotent: record each event's unique id and skip any you've already processed, so a duplicate delivery doesn't charge a customer or send an email twice.
Do I need to be a developer to use webhooks?▾
Not necessarily. Developers build receivers in code, but no-code automation tools like Zapier, Make, and n8n give you a ready-made webhook URL — you paste it into a service, and the platform catches the event and runs your workflow. You still benefit from understanding the concepts here, but you don't have to write a server.

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.

Share