Webhook

Definition
A webhook is a way for one service to notify another the instant something happens, by sending a message to a URL it controls.

Why it matters

Webhooks make connections between tools feel instant and cheap. A payment provider tells your database about a new subscription the second it happens. A failed charge can trigger a follow-up email immediately, instead of being noticed days later. There is no wasteful repeated checking.

The catch is reliability. A webhook can arrive twice, arrive out of order, or be retried after a timeout. Anyone building one, including with an AI tool, needs to design for that.

How to apply it

  • Check whether an event has already been processed before acting. Store each event's id and skip repeats.
  • Verify the sender's signature on every message. Without this, anyone who finds the address can send fake events.
  • Cope with out-of-order events, for example a "cancelled" notice arriving before "created".
  • Reply quickly with a success code and do the heavy work afterwards, so the sender does not retry needlessly.
  • Log every event received, so a missing update can be traced to a webhook that failed or never arrived.

What it is

A webhook reverses the usual direction of a request. Normally your software asks another service "has anything changed?". With a webhook, you give the other service a web address in advance, and it sends a message to that address the instant an event occurs: a payment succeeds, a form is submitted, a deal changes stage. The receiving code then reacts. This is sometimes called a push, in contrast to polling, where you ask again and again.

Worked example

A subscription business used to check its payment provider every few minutes for new charges, so a failed payment could sit unnoticed. It switched to a webhook that fires when a charge succeeds or fails, updating the customer record and sending a recovery email on failure. A stored list of processed event ids means a retried message never sends the email twice.

  1. Article

    API

    The wider interface a webhook usually forms one small part of.

  2. Article

    API integration

    The pattern webhooks often power.

  3. Article

    Trigger

    The event that starts an automation.

  4. Article

    Workflow automation

    What a webhook commonly kicks off.