What is a webhook?
A webhook is an automatic message one app sends to a web address you give it, the moment something happens. When a customer pays, Stripe sends your system a message about that payment right away. You don’t ask Stripe whether anything is new. Stripe tells you.
Another name for it is a “reverse API” or an HTTP callback. It’s how most apps announce events to other apps.
How does a webhook work?
Take a payment.
- You register a URL. In the sending app’s settings, you enter the address of a service you run, called the endpoint, and pick which events you care about, such as “payment succeeded.”
- Something happens. A customer pays.
- The app sends an HTTP request. It posts a small package of data, usually JSON, to your endpoint. The package says what happened and carries the details: amount, customer, time.
- Your endpoint answers. It returns a success code, such as 200, to say it got the message.
- Your system acts. It marks the invoice paid, posts to Slack, or starts a longer process.
If your endpoint doesn’t answer, most senders retry for a while, then give up.
What is the difference between a webhook and an API?
An API is a set of requests you can make to an app: “give me this customer,” “create this invoice.” You start the conversation. A webhook is the app starting it: “this invoice was just paid.”
| API call | Webhook | |
|---|---|---|
| Who starts it | You | The other app |
| When | Whenever you ask | When an event happens |
| Best for | Fetching or changing data on demand | Reacting to changes as they happen |
| Cost of waiting | Many requests that return nothing new | None until something changes |
Most integrations use both. A webhook says an order changed. An API call fetches the full order.
What is the difference between a webhook and polling?
Polling means asking an app on a timer: “anything new?” every minute. Most answers are “no,” and an event can wait up to a full interval before you see it. A webhook sends the event when it happens, with no wasted requests. Polling still has a place when an app offers no webhooks, or when you want to catch up after downtime.
What are webhooks used for?
- Payments. A charge succeeds or fails, and billing, access and email update.
- Code and deployments. A push to GitHub starts a build.
- Chat alerts. An incoming webhook posts a message to a Slack or Discord channel.
- Forms and sign-ups. A form submission becomes a CRM lead in seconds.
- Support. A new ticket creates a task or pages an on-call engineer.
- Signatures. A signed contract starts order booking.
What does a webhook look like?
A typical payload is a short JSON document:
{
"event": "invoice.paid",
"id": "evt_1042",
"created": "2026-11-27T14:02:11Z",
"data": { "invoice": "INV-2291", "amount": 4800, "currency": "usd" }
}
Most senders also add a header carrying a signature, which your endpoint can check.
How do you secure a webhook?
A webhook endpoint is a public address, so anyone can post to it. Treat every message as untrusted until you’ve checked it.
- Verify the signature. The sender signs each message with a secret you share. Recompute it and reject anything that doesn’t match.
- Use HTTPS only.
- Check the timestamp, and reject old messages, so a captured one can’t be replayed.
- Keep the URL private, and rotate the secret if it leaks.
- Don’t trust the body. Validate fields before you act on them.
What are webhook best practices?
- Answer fast, work later. Return a success code right away and do the real work afterward. A slow endpoint makes the sender time out and send the event again.
- Expect duplicates. Senders retry, so the same event can arrive twice. Store each event’s ID and skip repeats.
- Don’t count on order. Event 2 can land before event 1. Use the timestamp or fetch the latest state.
- Store the raw event first. If processing fails, you can replay it.
- Retry with backoff, and set failures aside for a person to review.
- Alert on silence. A webhook that stops arriving is often a broken registration, not a quiet day.
How do you test a webhook?
Point the sender at a temporary public URL from a request-catching tool, or a tunnel to your own machine, and trigger a test event. Most senders include a “send test event” button and a delivery log with the response your endpoint gave. Check the log first when a webhook seems to be missing.
Webhooks at Tray
A webhook can start a workflow in Tray iPaaS. When the sending app posts to the workflow’s address, the workflow runs: it can look up the full record, update other systems, and alert a person if a step fails. Tray connects to 12,000+ apps, databases, APIs, and services, and every call is logged. For a worked pattern, see how to build webhook fan-out, which covers signature checks, acknowledging first and replay. A webhook is one way to start a data pipeline; a schedule and an on-demand run are the others.