Skip to content
Engineering

Webhook

Definition

A webhook is an automated HTTP request one application sends to another when an event happens, such as a payment succeeding, so the receiver learns about it in real time instead of repeatedly checking.

Diagram

Polling compared with a webhookWith polling, the store asks the payment provider every few seconds whether a payment succeeded; seven checks come back with no news before one finds it, a little after it happened. With a webhook, the provider sends one request to the store the moment the payment succeeds.payment succeedsPolling“Is it done yet?”nonononononoyesWebhook“I’ll call you”one request, right away
Webhooks save wasted requests and deliver news immediately, but the receiver must be reachable, check that each call really came from the sender, and cope with the same event arriving twice. Many systems poll occasionally as a backup in case a webhook is lost.

Worked example