Skip to main content
Web DevAPIs & NetworkingDiagramBeginner

Webhook

KO: 웹훅 (Webhook)·EN: Webhook·JA: Webhook(ウェブフック)

An event-driven reverse API pattern where a provider automatically sends an HTTP POST payload to a registered callback URL whenever an event occurs

Table of Contents

Structure Diagram

Webhook Delivery, Signature Verification & Retry Cycle
WEBHOOK1. Provider …2. Signed HT…3. Verify & …4. Backoff R…
2/42. Signed HTTP POST
HMAC Sig + Event ID
Quick Answer

What is Webhook?

An event-driven reverse API pattern where a provider automatically sends an HTTP POST payload to a registered callback URL whenever an event occurs. It is a core concept in APIs & Networking within Web Dev.

Core Principles

A Webhook is often called a "reverse API." Instead of your server polling an external service every few seconds to ask if something changed, you register an HTTPS callback URL and the provider automatically sends an HTTP POST payload the moment an event happens.

This eliminates wasteful polling traffic and powers near-real-time automation across SaaS platforms.

Practical Takeaways

  • Always verify HMAC signatures and timestamps: Because webhook URLs are publicly reachable, validate the provider's cryptographic signature header against the exact raw request body using constant-time comparison, and reject stale timestamps to block replay attacks.
  • Acknowledge fast, process asynchronously: Providers enforce tight timeouts (often 3–5 seconds) before retrying. Verify the signature, push the event onto a queue, return 200 OK immediately, and run heavy database or email work in background workers.
  • Handle duplicates idempotently: Webhooks guarantee at-least-once delivery. Store processed event_id values so retries never double-credit an account or send duplicate invoices.

Notable Examples

  • Stripe & payment gateways: Confirming asynchronous payment captures, refunds, and subscription renewals reliably even if the user closes the browser.
  • GitHub & Headless CMS: Triggering CI builds on push events or calling Next.js ISR revalidation hooks on content publish.