Webhook

A webhook is a message that one service sends to a URL on your server the moment something happens, so you do not have to keep asking.

Checked 27/11/2026 against 3 sources. Next review 27/05/2027.

A webhook lets you subscribe to events in another software system and automatically receive a delivery of data at your server whenever those events happen [1]. You give the service a URL. When something occurs, such as a customer's bank confirming a payment, the service sends the details to that URL over HTTPS as a JSON payload [2]. It is the opposite direction to an API call, where your code asks first. GitHub contrasts webhooks with polling, which means calling an API at intervals to see whether anything new is there [1].

Why use a webhook instead of checking the API every minute?

GitHub's docs list the advantages of webhooks over polling: they need less effort and fewer resources than polling, they scale better, and they give near real-time updates because they fire when the event happens [1].

Scale matters when you watch many items. GitHub notes that calling an API once per resource can use up your rate limit quickly, while subscribing to webhook events means you hear only when something changes [1].

What events would a Singapore shop actually listen for?

Stripe says webhooks help you respond to asynchronous events, such as a customer's bank confirming a payment, a customer disputing a charge or a recurring payment succeeding [2]. A payment gateway can finish a payment seconds or minutes after the customer left your page.

A late-paying order

Say a customer places a S$80 order and pays later. Your site marks the order "waiting for payment". When the provider confirms the money, its webhook hits your URL. Your server finds the order, marks it paid and sends the confirmation email. Nobody on your team did anything.

What does the code on my end look like?

A webhook receiver is a normal URL on your server. Stripe says the endpoint should handle POST requests with a JSON payload and quickly return a successful 2xx status code before any complex logic that might cause a timeout [2]. Do the heavy work after you have replied.

app.post('/hooks/payment', express.raw({ type: 'application/json' }), (req, res) => {
  // check the signature first (see your provider's docs)
  res.sendStatus(200);          // reply fast
  queueOrderUpdate(req.body);   // then do the slow part
});

Stripe also needs the raw, unchanged request body to verify its signature, so do not reshape it before checking [2]. Stripe says this check verifies that the request was generated by Stripe [2].

What if my server is down when the webhook arrives?

Providers retry. Stripe tries to deliver an event for up to three days in live mode, with exponential backoff, which means the gaps between tries grow [3]. Stripe retries sandbox deliveries three times over a few hours instead [3]. It also does not guarantee that events arrive in the order they were generated [3]. Other providers set their own rules, so read yours. Stripe says an endpoint might occasionally receive the same event more than once, and suggests logging the event IDs you have processed so you skip repeats [2].

Questions people ask

What is the difference between a webhook and an API?

With an API call, your code asks the other service for data. With a webhook, the other service sends data to your URL when an event happens [1]. Many providers offer both.

Does a webhook URL have to use HTTPS?

Stripe's docs describe creating an HTTPS webhook endpoint and sending events to it over HTTPS [2]. Use HTTPS for any endpoint that receives order or customer data.

What does a webhook payload contain?

It holds details of the event. Stripe sends a JSON payload that includes event information [2]. The exact fields depend on the provider, so check its event reference.

See also

  • API An API is a set of rules that lets one piece of software ask another piece of software to do something, without a person clicking anything.
  • HTTP status codes HTTP status codes are three-digit numbers a server sends back with every page or file to say whether the request worked.
  • Payment gateway A payment gateway is the tool that lets a business safely accept payments online, passing the customer's details to the bank side for approval.
  • Stripe Stripe is an online payments company whose platform lets a business take card and other payments on a website or app and receive the money in its bank account.
  • HTTPS HTTPS is the secure version of HTTP, the language browsers and websites speak, with everything sent between them encrypted.

References

  1. About webhooks, GitHub Docs. Read 27/11/2026.Webhooks are used to receive data as it happens, as opposed to polling an API (calling an API intermittently) to see if data is available.
  2. Receive Stripe events in your webhook endpoint, Stripe Docs. Read 27/11/2026.After you register a webhook endpoint, Stripe pushes real-time data to it when events happen in your Stripe account.
  3. Receive Stripe events in your webhook endpoint (automatic retries), Stripe Docs. Read 27/11/2026.Stripe attempts to deliver events to your destination for up to three days with an exponential backoff in live mode.