$npx -y skills add hookdeck/webhook-skills --skill webhook-handler-patternsBest practices for webhook handlers. Use when implementing the handler sequence (verify first, parse second, handle idempotently), idempotency, error handling, retry logic, or framework-specific issues with Express, Next.js, or FastAPI.
| 1 | # Webhook Handler Patterns |
| 2 | |
| 3 | ## When to Use This Skill |
| 4 | |
| 5 | - Following the correct webhook handler order (verify → parse → handle idempotently) |
| 6 | - Implementing idempotent webhook handlers |
| 7 | - Handling errors and configuring retry behavior |
| 8 | - Understanding framework-specific gotchas (raw body, middleware order) |
| 9 | - Building production-ready webhook infrastructure |
| 10 | |
| 11 | ## Resources |
| 12 | |
| 13 | ### Handler Sequence |
| 14 | |
| 15 | - [references/handler-sequence.md](references/handler-sequence.md) - Verify first, parse second, handle idempotently third |
| 16 | |
| 17 | ### Best Practices |
| 18 | |
| 19 | - [references/idempotency.md](references/idempotency.md) - Prevent duplicate processing |
| 20 | - [references/error-handling.md](references/error-handling.md) - Return codes, logging, dead letter queues |
| 21 | - [references/retry-logic.md](references/retry-logic.md) - Provider retry schedules, backoff patterns |
| 22 | |
| 23 | ### Framework Guides |
| 24 | |
| 25 | - [references/frameworks/express.md](references/frameworks/express.md) - Express.js patterns and gotchas |
| 26 | - [references/frameworks/nextjs.md](references/frameworks/nextjs.md) - Next.js App Router patterns |
| 27 | - [references/frameworks/fastapi.md](references/frameworks/fastapi.md) - FastAPI/Python patterns |
| 28 | |
| 29 | ## Quick Reference |
| 30 | |
| 31 | ### Handler Sequence |
| 32 | |
| 33 | 1. **Verify signature first** — Use raw body; reject invalid requests with 4xx. |
| 34 | 2. **Parse payload second** — After verification, parse or construct the event. |
| 35 | 3. **Handle idempotently third** — Check event ID, then process; return 2xx for duplicates. |
| 36 | |
| 37 | See [references/handler-sequence.md](references/handler-sequence.md) for details and links to provider verification and idempotency patterns. |
| 38 | |
| 39 | ### Response Codes |
| 40 | |
| 41 | | Code | Meaning | Provider Behavior | |
| 42 | |------|---------|-------------------| |
| 43 | | `2xx` | Success | No retry | |
| 44 | | `4xx` | Client error | Usually no retry (except 429) | |
| 45 | | `5xx` | Server error | Retry with backoff | |
| 46 | | `429` | Rate limited | Retry after delay | |
| 47 | |
| 48 | ### Idempotency Checklist |
| 49 | |
| 50 | 1. Extract unique event ID from payload |
| 51 | 2. Check if event was already processed |
| 52 | 3. Process event within transaction |
| 53 | 4. Store event ID after successful processing |
| 54 | 5. Return success for duplicate events |
| 55 | |
| 56 | ## Related Skills |
| 57 | |
| 58 | - [stripe-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/stripe-webhooks) - Stripe payment webhook handling |
| 59 | - [shopify-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/shopify-webhooks) - Shopify e-commerce webhook handling |
| 60 | - [github-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/github-webhooks) - GitHub repository webhook handling |
| 61 | - [resend-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/resend-webhooks) - Resend email webhook handling |
| 62 | - [chargebee-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/chargebee-webhooks) - Chargebee billing webhook handling |
| 63 | - [clerk-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/clerk-webhooks) - Clerk auth webhook handling |
| 64 | - [elevenlabs-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/elevenlabs-webhooks) - ElevenLabs webhook handling |
| 65 | - [openai-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/openai-webhooks) - OpenAI webhook handling |
| 66 | - [paddle-webhooks](https://github.com/hookdeck/webhook-skills/tree/main/skills/paddle-webhooks) - Paddle billing webhook handling |
| 67 | - [hookdeck-event-gateway](https://github.com/hookdeck/webhook-skills/tree/main/skills/hookdeck-event-gateway) - Webhook infrastructure that replaces your queue — guaranteed delivery, automatic retries, replay, rate limiting, and observability for your webhook handlers |