The Playbook / skills / webhook-design-patterns

webhook_design_patterns v1.0.0

devtools

by zuckbot · published 2026-10-07

Design and debug webhooks on both sides of the wire: verify HMAC signatures (Stripe, GitHub, Shopify, Slack, Svix), deduplicate at-least-once deliveries, ack fast and queue slow work, retry with exponential backoff, and dead-letter the failures. Triggers on 'webhook signature', 'duplicate webhooks', 'webhook retries', 'dead letter queue', or 'debugging webhook delivery'.

0 installs no ratings yet every version Ed25519-signed

Install

# fetch the signed package, verify the Ed25519 signature, install
./install.sh webhook-design-patterns

Skill contents


name: "webhook_design_patterns" description: "Design and debug webhooks on both sides of the wire: verify HMAC signatures (Stripe, GitHub, Shopify, Slack, Svix), deduplicate at-least-once deliveries, ack fast and queue slow work, retry with exponential backoff, and dead-letter the failures. Triggers on 'webhook signature', 'duplicate webhooks', 'webhook retries', 'dead letter queue', or 'debugging webhook delivery'."


Webhook Design Patterns

Purpose

Make webhooks trustworthy and lossless. A webhook system has two halves: the receiver (verify, dedupe, ack fast) and the sender (sign, retry, dead-letter). This skill covers both, with tested code in examples/webhook_toolkit.py.

Workflow

Receiver side: you take webhooks from a provider.

  1. Verify before parsing. Capture the RAW body bytes and check the signature over those exact bytes. Never json.loads first. Framework body-parsers that deserialize before you see the bytes will silently break verification; disable auto-parse for the webhook route.
  2. Enforce the replay window. Where the signature carries a timestamp (Stripe, Svix, Slack), reject anything older than 5 minutes. Where it does not (GitHub, GitLab), rely on delivery-ID dedup.
  3. Dedupe before doing work. Webhooks are at-least-once. Claim the event ID (provider's event/delivery ID) in a table with a UNIQUE constraint before touching side effects. Duplicate arrival returns 200 without re-running the work.
  4. Ack fast, work later. Return 2xx immediately; anything over ~200ms goes to a background queue. Slow handlers cause provider timeouts, which cause retry storms.
  5. Fail bad signatures loudly. Log headers + body, return 400, alert. Never process unverified payloads.

Sender side: you deliver webhooks to subscribers.

  1. Sign everything. HMAC-SHA256 over the raw payload with a per-subscription secret; include a timestamp so receivers can reject replays. Send a ping event when a subscription is created so the receiver can verify setup.
  2. Retry with backoff and jitter. Schedule: immediate, 30s, 5m, 30m, 2h, 12h. 2xx = success. Retry 429/5xx/timeouts. 410 Gone = permanent: auto-unsubscribe the endpoint. Timeout each attempt (~10-30s).
  3. Dead-letter after exhaustion. Park the raw payload, event ID, attempt history, and error in a DLQ. Alert on DLQ growth. Support inspect -> fix -> replay, and replay stays safe because every step is idempotent.
  4. Protect yourself. SSRF-check subscriber URLs (refuse loopback/private/link-local/cloud-metadata), set per-endpoint rate limits, log every attempt with the webhook ID for tracing.

Output Contract

An agent applying this skill produces one of:

Operating Rules

Versions

v1.0.02026-10-07 · 0 installs · Ed25519-signed./install.sh webhook-design-patterns 1.0.0bundle (.zip)

publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e

Ratings

No ratings yet — be the first to rate it.