Loading pattern...

What is Webhooks?

Webhooks are HTTP POST requests that notify your app when something happens. Stripe charges a card → sends POST to your webhook URL → you handle payment success. Reverse of APIs (you call them → they respond). Webhooks: they call you when event happens. Great for async events—user subscribes on Stripe, Stripe notifies you. Alternative to polling ("are there new payments?" every 10 seconds). Every major platform (Stripe, GitHub, Shopify) uses webhooks.

When Should You Use This?

Implement webhooks to notify external systems when events happen in your app, or consume webhooks from services you integrate with (Stripe payments, GitHub commits, Shopify orders). Essential for async integrations. Webhooks work well when: events are infrequent, you want real-time notification, or polling is inefficient. Provide webhooks if you build a platform/API.

Common Mistakes to Avoid

  • No retry logic—webhook delivery fails, event lost. Implement retries with exponential backoff
  • No signature verification—anyone can POST to your webhook, verify requests are authentic (HMAC signature)
  • Synchronous processing—webhook handler should queue job, respond 200 immediately
  • No idempotency—webhook might be sent twice, process idempotently
  • No monitoring—webhooks silently failing, add alerting for failed deliveries

Real-World Examples

  • Stripe—Webhook notifies when payment succeeds, fails, or subscription cancels
  • GitHub—Webhook on push/PR/issue for CI/CD triggers
  • Shopify—Webhook when order placed, notify fulfillment system
  • Zapier—Entire platform built on consuming/sending webhooks

Category

System Design Patterns

Tags

webhookshttp-callbackseventsapi-integrationstripe

Permalink