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.

Common mistakes

  • Trusting every message. Without signature checks anyone who finds the address can send a fake "payment succeeded" event.
  • Assuming each event arrives once. Retries are normal, so processing the same event twice must be harmless.
  • Assuming events arrive in order. Handle "cancelled" before "created" without breaking.
  • Doing slow work before replying. If the response takes too long, the sender retries and the work runs twice.
  • Not logging what arrived. When a customer says they paid and the account is not active, you need the event history to see what happened.
  • Having no way to replay. Keep a way to re-run missed events, because the sender stops retrying eventually.
Worked example

Suppose a small training business takes course payments through its online checkout. When a payment succeeds, the provider sends a webhook to a Pipedream endpoint, which checks the sender's signature before doing anything else. The workflow stores the event id in Supabase, skips the event if it has already been handled, and then grants course access. In this example the provider retries a message on one afternoon, and the second copy is ignored rather than granting access twice. A "cancelled" notice that arrives before its "created" notice is logged and handled in the right order. Every event lands in a table, so a student with missing access can be traced in minutes.

Tools in the example

Some links are affiliate links: we may earn a commission at no cost to you. It never decides a ranking. How we work with partners

  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.