Webhooks Explained

Event-driven HTTP callbacks that notify your application in real time when something happens in another service.

Webhook

A webhook is a callback mechanism where one system sends an HTTP POST request to a URL specified by another system when a specific event occurs. Unlike polling (repeatedly asking "has anything changed?"), webhooks push notifications in real time, enabling event-driven integrations between services.

Explanation

Consider a payment system like Stripe. After a customer pays, your application needs to know about it. Without webhooks, you would have to poll Stripe's API repeatedly — "any new payments? any new payments?" — wasting bandwidth and introducing delay. With a webhook, you register a URL with Stripe, and when a payment succeeds, Stripe sends an HTTP POST to that URL with the payment details. Your application processes the event immediately. Webhooks are the standard mechanism for real-time integrations between SaaS platforms. GitHub sends webhooks for push events, Slack for messages, Stripe for payment events, Twilio for SMS receipts. The receiving application must expose a publicly accessible HTTPS endpoint, validate the webhook signature (to prevent spoofed requests), process the event, and return a 200 response quickly (heavy processing should happen asynchronously). Reliability is the main challenge with webhooks. If your server is down when Stripe sends a webhook, the event is lost unless Stripe retries. Most webhook providers implement retry logic with exponential backoff, but your endpoint should be idempotent (safe to process the same event multiple times) because retries can deliver duplicate events. Webhook management platforms and message queues can add durability and ordering guarantees.

Bookuvai Implementation

Bookuvai projects use webhooks extensively for third-party integrations — payment notifications (Stripe), code push events (GitHub), communication events (Twilio, SendGrid), and more. Our standard webhook handler pattern includes signature verification, idempotent processing with deduplication keys, asynchronous processing via a job queue, and comprehensive logging for debugging. Webhook endpoints are included in the integration testing suite for each milestone.

Key Facts

  • Push-based (real-time) versus polling (periodic, wasteful)
  • Always verify webhook signatures to prevent spoofed requests
  • Webhook handlers must be idempotent — duplicate deliveries are common

Related Terms

Frequently Asked Questions

How do I secure a webhook endpoint?
Verify the webhook signature included in the request headers. Each provider (Stripe, GitHub, etc.) signs the payload with a shared secret. Your endpoint should compute the expected signature and reject requests that do not match. Also use HTTPS and restrict the endpoint to known IP ranges if possible.
What if my server is down when a webhook is sent?
Most providers retry failed webhooks with exponential backoff (e.g., 1 min, 5 min, 30 min, 2 hours). Ensure your handler is idempotent so retries do not cause duplicate processing. For critical events, consider a message queue as a buffer between the webhook endpoint and your processing logic.