Skip to the guide

Webhooks

IntermediateConcept3 pages

A webhook is an HTTP request that one company's server sends to another's when something happens: a payment succeeded, a parcel was delivered, code was pushed. Instead of you asking a provider "anything new?" every few seconds, the provider calls a URL you registered. Interviewers ask about webhooks from both sides: how you receive them safely, and, in questions like "design a payments platform", how you'd build the system that sends them.

Leave your number with the garage

You leave your car at a garage. You could phone every hour to ask whether it's ready. Or you leave your number, and they call you when it is. If you don't pick up, they try again later, and again. Before you go and pay, you'd want to be sure it really was the garage calling. And if the receptionist rings twice by mistake, you still collect one car.

  • leaving your number → registering a webhook URL with the provider
  • phoning every hour → polling the provider's API
  • the receptionist making the calls → the provider's delivery workers
  • their call → the webhook: an HTTP POST with an event in the body
  • trying again later → retries with backoff until your server answers 2xx
  • making sure it's the garage → checking the signature
  • ringing twice → duplicate deliveries, which you must handle