A webhook is an HTTP request that sends event data from one application to another when a specific event occurs. It helps separate systems share real-time data through application integration, without repeated checks for system updates. What happens when one app changes while another keeps waiting for its next check? The payload is the structured event data carried in an HTTP request. Some receivers need a follow-up API request because the payload may not include a complete record. A webhook is most useful when another system needs to react to a change without waiting for a scheduled check.
How Webhooks Work in Practice

When a customer’s payment succeeds, the payment system can send the registered application an event without waiting for it to ask. A webhook delivery begins with a chosen event and ends when the receiver accepts the request. The payment system is the event source, and the order app is the receiver.
Most providers send webhook requests as HTTP POST requests with JSON payloads. The payload may include a payment ID, status, amount, and event ID. The receiver can use those fields to match the event to an order.
Register an endpoint and select events
First, the application owner registers the webhook endpoint with the payment provider. The owner chooses which event types should trigger a request, such as a successful payment. Some providers require a registration handshake or challenge before accepting an endpoint, while others do not.
Send the event payload
Next, the customer completes payment and the source creates a payment-success event. The source sends an HTTP request to the registered endpoint with the event payload. The request usually includes headers that describe its content and identify the delivery.
Acknowledge and process the delivery
The receiver checks the request and returns a response to show whether it reached the endpoint. After that, it can process the event, update the order, and send a receipt. A receiver may first save the event for later work rather than finishing every task during the request.
The event ID helps the receiver connect a delivery to later processing and records. A payment notice may tell the app that a charge succeeded, but not include every customer or invoice field. Treat the payload as a notice of what happened, not automatically as the full record the receiver needs.
Set Up a Webhook Endpoint
A webhook endpoint is a route on your server that an event provider can reach at the URL you register. The receiver needs a route for the provider’s HTTP method, a registered URL, and subscriptions to the intended events. The URL must work from outside your local network.
For example, a payment provider may send POST requests to an endpoint such as your application’s payment-events route. The server must accept the request and match the event types you selected. Keep provider-specific limits in mind when planning separate endpoints.
| Setup detail | GitHub | Stripe |
|---|---|---|
| URL reachability | Disallows localhost and 127.0.0.1 | Requires publicly accessible HTTPS URL |
| Registration capacity | 20 repository or organization webhooks per event type | 16 event destinations |
| Transport | HTTPS is not stated as required here | HTTPS required for registered endpoints |
GitHub does not accept localhost or 127.0.0.1 as a webhook URL, and its localhost restriction matters during local setup. Stripe also requires a publicly reachable HTTPS endpoint. A temporary public tunnel can expose a development server for testing, but the provider must reach the registered URL.
Before adding subscriptions, confirm that the server route accepts the provider’s method and returns a response. A route that works only from your laptop cannot receive an external delivery. Check that the registered address is publicly reachable before expecting deliveries from an external provider.
Webhooks vs. APIs, Polling, WebSockets, and Pub/Sub

A webhook pushes an event to a destination, while a client API request asks another system for data or an action. Webhooks and APIs complement one another: an event can prompt the receiver to call an API for more detail. An API uses a request-and-response pattern, with the client starting each request.
For example, a webhook may report that a payment changed, then the receiver can use an API to fetch the full account record. An [API request] can also return structured data such as JSON or XML when the client asks for it.
| Communication method | Who initiates | Connection pattern | Best-fit task |
|---|---|---|---|
| API request | Client | Request and response | Get data or request an action |
| Polling | Client | Repeated requests on a schedule | Check for updates at set times |
| Webhook | Source server | Event-triggered HTTP request to a URL | Notify one destination about an event |
| WebSocket | Either connected side | Ongoing two-way connection | Exchange messages during an active session |
| Pub/sub | Publisher | Broker routes messages to subscribers | Send messages to multiple subscribers |
Polling sends client requests on a schedule, even when nothing has changed. A source server starts a webhook request only after its selected event occurs. That makes the webhook a direct connection between a producer and a destination URL, not a brokered channel.
Pub/sub uses a broker to route messages to multiple subscribers, while a webhook sends a request directly to one endpoint. WebSockets keep a connection open for two-way communication. Choose a WebSocket for ongoing two-way exchange, not for a one-way event notification.
Real-World Webhook Examples

A GitHub push can trigger a webhook that tells a build system new code is ready for testing. A clear webhook example names the triggering event, the data sent, and the receiver’s next action. Those three details make the integration easier to review and debug.
Stripe webhooks can report payment events so an order or account app can update a customer’s status. The payload may identify the payment and its new state. If the app needs more information, it can request that record through an API.
A GitHub push can send code-change details to a build service, which can start a test workflow. The receiver may use the repository and commit information to choose what to build. The event itself does not run the tests.
A Shopify order event can notify fulfillment software that a new order needs attention. The receiver can pass the order details into a shipping workflow. Businesses that coordinate carrier updates may also use cargo tracking software to follow shipment milestones.
Slack supports webhook-based notifications, so an operations system can send an alert to a channel. Teams may connect those alerts with broader employee communication tools when staff needs updates and follow-up in one place.
An event notification may not contain every detail needed for the next action. A receiver might need to fetch a full order or customer record before changing its own data. For each integration, decide which event matters and what the receiving application should do with it.
Secure Webhooks Before Processing Them

A public webhook route can receive forged requests, so verify authenticity before trusting an event or acting on its data. Check the provider’s signature before processing the payload as a real event. A signature helps show that the request came from a party with the shared secret.
A signing secret is a private value used to create or verify a message signature. A URL token is a secret placed in the endpoint address, so it can leak through logs or other records. Providers use different signature formats and headers, so never assume one provider’s method works for another.
- Require HTTPS and TLS 1.2 or higher, with a certificate from a trusted certificate authority.
- Verify the provider’s signature with its documented header and secret.
- Keep the exact raw request body for signature verification.
- Compare signatures with a constant-time function, not a normal equality check.
- Check subscriber-supplied callback URLs for server-side request forgery risks.
GitHub recommends a secret with its X-Hub-Signature-256 header, which uses HMAC-SHA256. Stripe signatures use a signing secret that begins with whsec_. Stripe also needs the original raw request body for verification.
Parsing JSON and then re-serializing it can change the signed bytes. The signature check can fail even when the visible data looks unchanged. The raw-body signature rule avoids that mismatch.
OWASP’s Webhook Security Cheat Sheet advises HTTPS, signature checks, and constant-time comparison. A 32-byte cryptographically random secret is a sound default. The Standard Webhooks scheme allows secrets from 24 to 64 bytes.
If your service accepts callback URLs from subscribers, permit HTTPS and reject non-public IP addresses when connecting. This helps reduce server-side request forgery, or SSRF, where an attacker tries to make your server contact private systems. Reject a delivery when its signature does not validate, rather than processing its payload as trusted input.
Handle Retries, Duplicates, and Event Order
A provider retry can deliver the same event again even when the first request already reached your server. Use a stable event ID to prevent duplicate processing, and do not assume events arrive in delivery order. A timeout or unsuccessful response may cause a provider to try the delivery again.
GitHub expects a 2xx response within 10 seconds, or it ends the connection and records a failed delivery. Stripe recommends a quick successful 2xx response before complex work causes a timeout. During a surge, GitHub may also temporarily throttle webhook deliveries.
| Delivery condition | Safe receiver action | Failure to avoid |
|---|---|---|
| Duplicate delivery | Check stable event ID and return 2xx | Repeating the same account or order change |
| Out-of-order delivery | Use event time or current record state | Replacing newer data with older data |
| Slow or unavailable receiver | Acknowledge valid events quickly and queue work | Holding the request open during long tasks |
Store processed event IDs so a redelivery can be recognized. GitHub redeliveries reuse the original X-GitHub-Delivery value as a deduplication key. Return 2xx for a valid duplicate, because repeating a successful action is not needed.
Events may reach the receiver in a different order from when they occurred. GitHub payload timestamps can help establish event time. Use timestamps or current record state to avoid applying an older change over a newer one.
Stripe webhook libraries use a five-minute default timestamp tolerance to reject stale signed deliveries. That check helps limit replay risks, but it does not replace event ID tracking. Keep processed event IDs for at least the provider’s retry window so a late redelivery cannot repeat the action.
Build and Test a Webhook Receiver
A receiver is a small HTTP handler, but it needs limits and a test path before it is safe to expose. Accept only the provider’s expected method and content type, and cap the request body size. To create webhooks, choose trigger events, register a public HTTPS URL, build the handler, validate signatures, and test delivery.
Create a receiver that accepts and queues events
The handler should accept the provider’s HTTP method and content type, then check the signature. Set a payload-size limit before reading untrusted data into memory. Avoid loading an unbounded unauthenticated body, since an attacker could use large requests to exhaust server memory.
Queue expensive work for a worker after the receiver accepts the request. The handler can save a valid event and return a response without waiting for reports, emails, or database-heavy tasks. A worker can process the saved event outside the request path.
An internet-reachable monetr deployment with Stripe webhooks enabled could face denial of service if it read an unauthenticated body into memory before signature validation. The issue was fixed in monetr version 1.12.4. This case shows why body limits and safe request handling matter before an endpoint goes live.
Test delivery and inspect failures
Test the endpoint before connecting it to a live workflow. A temporary public tunnel such as ngrok can expose a development server. Use curl or Postman to send test requests and inspect the receiver’s behavior.
- Confirm the route is reachable from outside your development network.
- Inspect the request headers and raw payload that arrive at the route.
- Test both valid and invalid signatures to check the response.
- Simulate a failure and confirm the logs show the response.
Keep test events separate from production actions so a trial request cannot change a real order. Record enough request details to trace a failed test, without storing secrets in logs. Set a payload-size limit before accepting untrusted request bodies into memory.
When Webhooks Fit and When They Do Not
Use a webhook when an application must react to a specific event without repeatedly checking for updates. Webhooks fit best when the source supports them, timely notice matters, and the receiver can stay reachable. They give the receiver an event-triggered update rather than a scheduled request.
Do not use a webhook when the source offers no webhook support or the receiver cannot accept inbound requests. A scheduled retrieval may suit a daily report or a large data pull better. For shipment workflows, a system may gather tracking updates at set times instead of reacting to every event.
Polling can be simpler for infrequent scheduled checks, especially when an app needs a report once each day. A persistent connection may suit ongoing two-way communication. A brokered system can help when messages must reach multiple subscribers.
A webhook is not a persistent two-way connection or a brokered multi-subscriber channel. It sends an event notification to a destination URL, and the receiver can choose a separate method for further exchange. Choose a scheduled pull when the source offers no webhook or when periodic retrieval is all the workflow needs.
CloudEvents and Consistent Event Data
Different services can describe similar events in different ways, making a shared event format useful across integrations. CloudEvents is a common specification for describing event data across services and platforms. A consistent event envelope can help an application handle events from systems that use different delivery methods.
CloudEvents is a graduated project of the Cloud Native Computing Foundation. Its shared structure can make event data easier to move between services and platforms. That can reduce custom handling when more than one system describes the same kind of change.
A common format does not guarantee delivery, event order, authentication, or provider retry behavior. Each service still needs its own rules for receiving and handling messages. Treat a common event format as a portability aid, not as a substitute for delivery and security controls.
Conclusion
A webhook integration is dependable only when the receiver can verify, acknowledge, and safely handle each delivery. Verify incoming events, plan for retries and duplicates, and move lengthy work out of the request path. A quick acknowledgment helps prevent slow tasks from holding up delivery.
Choose a low-risk event and register a test endpoint. Confirm the signature check and response behavior before connecting production workflows. Start with one test event and validate the complete delivery path before relying on it in production.
