← Back to list
SW Engineering & Management
#웹훅#이벤트통합#HMAC서명#멱등성#폴링대체
Last updated · 2026-10-28

Webhooks: Event Integration with Reliability and Security Design

1. Overview

A. Definition

A Webhook is a reverse API integration method in which, when a particular event occurs in a system, the producer actively sends an HTTP(S) request (usually a POST) to a receiver's endpoint registered in advance, thereby delivering the event. The exact opposite of polling—where a receiver periodically asks for state—it is a callback model ("don't call us, we'll call you") and is therefore also called a Reverse API or HTTP Push API.

Webhooks have become the de facto standard for event delivery in today's SaaS and platform ecosystems, where distinct organizations and services must integrate in near real time while remaining loosely coupled. Traditional integration had consumers repeatedly call the provider's REST API to check for changes, but this structure caused both excessive calls and latency because of the fundamental limitation that "you never know when something changed." Webhooks invert this control: the producer—who learns of a state change first—notifies directly at the moment of change, simultaneously raising the immediacy and efficiency of integration.

B. Background and Necessity

The most direct reason webhooks became necessary is the structural inefficiency of polling. For example, if a merchant wanting to know the instant a payment state turns to "approved" calls the PG (payment gateway) API every second, tens of thousands of futile calls occur even though the actual change happens only a few times a day. Lengthening the polling interval reduces call volume but delays event awareness by the same amount, trapping the design in a latency-cost trade-off; from the provider's side, too, serving requests that are overwhelmingly "no change" wastes unnecessary server resources.

The second reason is the spread of event-driven architecture (EDA) and SaaS integration. To pull "events that occurred externally"—a GitHub code push, a Stripe payment success, a Slack message—into your own workflow, you need a standard means of propagating events across organizational boundaries. Webhooks make this integration possible with only HTTP and a URL, without an extra SDK or a persistent connection, so even organizations with different technology stacks can implement real-time linkage with the lowest barrier to entry.

The third reason is the rise of serverless and automation platforms. FaaS such as Lambda and Cloud Functions, and no-code automation tools such as Zapier and IFTTT, presuppose a trigger of "wake the function when an external event arrives," and webhooks are the most natural input signal that wakes them. Because a structure that consumes resources only at the moment an event occurs—without an always-on consumer process—becomes possible, webhooks have become the de facto entry point of event-driven computing.

C. Goals and Scope

The goals of adopting webhooks are, first, near-real-time propagation of state changes; second, resource savings on both sides by eliminating polling; and third, loosely coupled integration that crosses organizational and stack boundaries. Their scope spans nearly every boundary where "my system must immediately learn of an external event," such as payment/settlement (PG, simple pay), source control (CI/CD triggers), collaboration-tool linkage, IoT sensor alerts, and messenger bots. Conversely, for high-volume bidirectional streaming (real-time chat, games) or guaranteed inter-service messaging where delivery guarantees, ordering, and throughput requirements are high, WebSockets and message brokers are more suitable, and it is accurate to view webhooks as a complement to them.

2. How Webhooks Work and Their Components

A. Overall Structure

The overall structure of a webhook integration can be summarized as the flow of subscription registration → event occurrence → HTTP delivery → acknowledgment (ack). First, the consumer registers "which events to receive at which URL" through the provider's management console or API, and is issued a shared secret to be used for signature verification. Afterward, when the relevant event occurs on the provider's side, a dedicated delivery component sends a signed HTTP POST to the registered URL, and the receiver responds with 2xx immediately and then performs the actual processing asynchronously.

flowchart LR
    subgraph PROVIDER["Provider (event producer)"]
        EV["Event occurs (payment approved, etc.)"] --> DISP["Dispatcher"]
        SUB[("Subscription/endpoint store")] -.->|"look up target URL"| DISP
        DISP --> OUTQ[["Delivery queue (retry)"]]
    end
    OUTQ -->|"HTTP POST + signature"| EP["Receiving endpoint (HTTPS)"]
    subgraph CONSUMER["Consumer (event receiver)"]
        EP -->|"2xx after signature verify"| INQ[["Internal queue"]]
        INQ --> WORKER["Worker (actual processing)"]
    end
    EP -.->|"non-2xx / timeout"| OUTQ

The key point is placing an outbound delivery queue. Even when the receiver temporarily fails to respond, the provider must be able to retain and resend the event rather than discard it immediately, and the existence of this queue becomes the foundation of the reliability design discussed later.

B. Delivery Lifecycle and Components

The lifecycle from the creation of one webhook message to its final processing, viewed as a sequence, is as follows. Until the receiver returns 2xx, the provider does not regard the delivery as successful, and on failure it repeats resending with exponential backoff.

sequenceDiagram
    participant P as Provider dispatcher
    participant C as Receiving endpoint
    participant Q as Consumer internal queue
    participant W as Worker
    P->>C: "POST /webhook (event + HMAC signature + timestamp)"
    C->>C: "verify signature/timestamp, check duplicate ID"
    C->>Q: "enqueue if valid (idempotent)"
    C-->>P: "200 OK (immediate response)"
    Q->>W: "asynchronous consumption"
    W->>W: "business processing (idempotency guaranteed)"
    Note over P,C: "resend with exponential backoff on non-2xx / timeout"

There are four key components. A Subscription is registration information bundling an event type, a target URL, and a secret key; an event Payload is the delivered JSON body containing the event ID, type, occurrence time, and data. A Signature is an HMAC value computed from the body and the secret key, guaranteeing authenticity and integrity, and a Delivery Log records the attempt, response, and retry history of each transmission so operators can perform replay and debugging.

C. Payload and Event Design

The most important decision in payload design is which to choose between a thin/notification approach and a thick/full-state approach. The thin approach sends only an identifier and event type, such as "order 123 changed," and lets the receiver fetch the details back; the payload is small and exposes little sensitive information, but it induces additional API calls by the receiver. The thick approach carries the entire changed data to eliminate round trips, but the payload grows large and there is a risk that data goes stale in transit or that sensitive information is exposed, so in finance and personal-data domains the thin approach plus re-fetch tends to be preferred.

An event must always include a globally unique ID and an occurrence timestamp. This is because they become the basis on which the receiver filters out duplicate receipts of the same event (idempotent processing) and infers ordering. In addition, structuring event types with a namespace like payment.succeeded and specifying a schema version lets the receiver safely accept payloads while maintaining backward compatibility even as the provider evolves them.

3. Reliability Design Strategies

A. Retry, Backoff, and Idempotency

A webhook is one-way HTTP crossing the public internet, so delivery failure is routine. Therefore the provider must retry over minutes and hours with exponential backoff + jitter for non-2xx responses or timeouts—for example immediately → 1 min → 5 min → 30 min → several hours—widening the interval to buy the receiver recovery time. At the same time, retries inevitably produce duplicate deliveries, so the receiver must design idempotent processing keyed on the event ID so that "receiving the same event multiple times yields the same result as once."

B. Ordering, Duplication, and Delivery Guarantee Level

A webhook is inherently characterized by at-least-once delivery with no ordering guarantee. Because of parallel transmission and retries, an updated event may arrive before a created event, so the receiver should not depend on order but should adopt a last-write-wins strategy that compares event timestamps/versions and ignores older events. If strict ordering is truly required, reinforce the design by assigning per-resource sequence numbers, or by using the webhook only as a "wake signal" and re-reading the actual state via the API.

C. Asynchronous Processing and Fast Response on the Receiving Side

The iron rule of receiver design is "respond with 2xx the instant you receive, process later." Because the provider usually treats the absence of a response within a few seconds (e.g., 5–10s) as a timeout and resends, performing heavy work such as DB updates or external calls synchronously inside the receive handler falls into a vicious cycle of timeout → resend → duplication. Thus the standard is a receive-process separation structure in which the endpoint finishes only signature verification and duplicate checking, enqueues the message into an internal queue (SQS, Kafka, etc.), and immediately returns 200, while the actual business logic is processed asynchronously by a worker.

4. Security Design

A. Signature Verification (HMAC)

A webhook endpoint is open to the internet without authentication, so one must presume the threat that anyone can send forged requests. The standard technique to prevent this is HMAC signature verification: the provider computes an HMAC-SHA256 value from the body and the shared secret key and carries it in a header (e.g., X-Signature), and the receiver recomputes it with the same secret key to check for a match. Here one must use constant-time comparison to block timing attacks, and because signing is over the original bytes (raw body), verification must use the body before parsing the JSON.

B. Defending Against Replay, Man-in-the-Middle, and SSRF

Because a signature alone cannot stop a replay attack that intercepts a valid past request and resends it, include a timestamp in the signed data, reject if the difference from the receive time exceeds an allowed window (e.g., 5 minutes), and block already-processed event IDs with an idempotency store. Encrypt the transport leg with HTTPS (TLS) to prevent man-in-the-middle eavesdropping/tampering, and rotate the signing secret periodically while temporarily accepting multiple keys in parallel for zero downtime. Meanwhile, a platform that lets users register webhook URLs directly faces an SSRF risk whereby an attacker registers an internal address (169.254.169.254, etc.) to relay through the server, so private IPs and metadata endpoints must be blocked and outbound access restricted.

5. Comparison with Similar Communication Methods

To apply webhooks correctly, one must understand how they differ from similar real-time and integration methods from the perspective of "what you gain and what you give up." Webhooks are optimal for server-to-server event notification, but for persistent streaming to a browser or guaranteed internal messaging, other tools are better. The crux of the comparison below is the difference in connection persistence, directionality, and delivery guarantee level, and these three axes divide the applicable situations.

Category Webhook Polling WebSocket SSE Message broker (Kafka, etc.)
Direction server→server (push) consumer→provider (pull) bidirectional server→client publish/subscribe
Connection one-off HTTP per event periodic one-off persistent persistent (HTTP) via broker
Latency near real-time as much as the polling interval real-time real-time near real-time
Delivery guarantee at-least-once via retry on request weak (drops) weak (drops) strong (durable, ordered)
Suitable for SaaS/payment/CI linkage simple, low-frequency chat, collaboration feeds, progress core internal events

Compared with polling, webhooks are overwhelmingly more efficient "the rarer the change." If changes are frequent on the order of seconds, the overhead of a webhook that opens a new connection per change grows, so the always-on WebSocket/SSE is advantageous. Also, if delivery guarantees, ordering, and bulk processing matter within an organization, a broker such as Kafka fits, whereas webhooks shine most in the domain of loosely coupled integration crossing organizational boundaries. In practice, the combination of "putting events received via webhook into an internal broker immediately upon receipt" to take the strengths of both is common.

6. Deep Dive: Industry Applications and Recent Trends

A. Industry Cases — The Designs of GitHub and Stripe

GitHub provides dozens of event types—push, pull_request, etc.—via webhooks, guarantees integrity with an HMAC-SHA256 signature in the X-Hub-Signature-256 header, and supports idempotency/replay by assigning each transmission a unique X-GitHub-Delivery ID. Stripe signs payment events with the Stripe-Signature header but includes a timestamp in the signed data to block replay, and provides signature verification at the library level to help developers receive events safely. The common lesson of both cases is that the four elements of signature, unique ID, retry, and delivery log (dashboard) are the minimum requirements of a trustworthy webhook; particularly in the payment domain, a defensive design of thin notification followed by re-confirming the amount via API re-fetch is well established.

B. Standardization Trends — Standard Webhooks and CloudEvents

Webhooks long suffered a fragmentation problem whereby each provider's header names, signature methods, and payload structures differed, forcing consumers to write different code for each integration partner. Movements to mitigate this draw attention: the Standard Webhooks initiative, which aims to unify signature, header, and payload conventions, and the CNCF's CloudEvents specification, which defines a common format for event metadata (source, type, ID, time). Such standards are steering the ecosystem toward lowering the cost of integrating heterogeneous SaaS and converging common logic—such as signature verification and idempotent processing—into reusable libraries. (Detailed conventions are under continuous revision, so checking the latest specification upon adoption is necessary.)

C. Expected Exam Directions and Answer-Composition Strategy

From a professional-engineer perspective, webhooks may be set as a conceptual comparison of "efficiency versus polling," or expanded into an architecture-design problem of "designing external integration with reliability and security." An answer should not stop at a mere definition but unfold as a three-axis (reliability, security, performance) design that ① secures reliability with a delivery queue, retries, and idempotency; ② attains security with HMAC signatures, timestamps, HTTPS, and SSRF defense; and ③ guarantees performance via asynchronous processing after an immediate response. Presenting application-judgment criteria through comparison with polling, WebSocket, and brokers reveals the integrative perspective expected at the professional-engineer level.

7. Considerations and Implications

  • Co-design of delivery guarantee and idempotency: Because webhooks default to at-least-once delivery, one must presume "duplicates will surely come." The provider's retry policy and the receiver's idempotent processing must be designed as a pair; equipping only one side ends in loss or duplicate processing. Place an event-ID-based idempotency store as a mandatory component of the integration.
  • Security does not end with signatures: HMAC signatures prevent forgery, but one must also consider replay, SSRF, and secret-key leakage to secure genuine safety. Operate timestamp verification, private-network blocking, key rotation, and constant-time comparison as a checklist, and minimize exposure of sensitive information with the trade-off of thin payload plus re-fetch.
  • Observability and an operator-intervention path: Because delivery failure can occur at any time, a delivery log, a replay console, failure alerts, and a manual-reprocessing path must be included in the design from the start. On the consumer side as well, treat receive latency, signature failures, and queue buildup as observability metrics to detect anomalies early and secure operational stability.
  • Scope judgment and a hybrid strategy: Webhooks are not a cure-all. High-frequency streaming favors WebSocket/SSE, and guaranteed internal events favor a broker. A hybrid of "receive at the external boundary via webhook but process internally via a broker" is the optimum in many situations, and the engineering judgment of choosing a method based on delivery-guarantee, ordering, and throughput requirements is required.
  • Outlook — Evolution toward standardization and an event mesh: As standards such as Standard Webhooks and CloudEvents mature, the cost of heterogeneous integration will fall, and in the long run it will develop into an event-gateway/event-mesh layer that relays and transforms events across organizations, with webhooks expected to converge into the external interoperability standard of EDA.

References


In one line: A webhook is a reverse-callback integration method in which the provider sends HTTP directly to the receiver's URL when an event occurs, eliminating the inefficiency of polling to enable near-real-time linkage; only when it combines reliability through retries and idempotency, security through HMAC signatures, timestamps, and SSRF defense, and performance through asynchronous processing after an immediate response does it become complete as the standard means of EDA integration crossing organizational boundaries.