StarModel 邀请活动
← 返回 Skill 列表
extension
分类: 开发与工程API Key 暂未确认

webhook-handler-patterns

关于webhook处理器的最佳实践。在实现处理程序序列(首先验证,其次解析,以幂等方式处理)、幂等性、错误处理、重试逻辑或使用Express、Next.js或FastAPI框架时遇到的特定问题时,请参考这些最佳实践。

person作者: jakexiaohubgithub

Webhook Handler Patterns

When to Use This Skill

  • Following the correct webhook handler order (verify → parse → handle idempotently)
  • Implementing idempotent webhook handlers
  • Handling errors and configuring retry behavior
  • Handling events that arrive out of order or are replayed after an outage
  • Understanding framework-specific gotchas (raw body, middleware order)
  • Building production-ready webhook infrastructure

Resources

Handler Sequence

Best Practices

Framework Guides

Quick Reference

Handler Sequence

  1. Verify signature first — Use raw body; reject invalid requests with 4xx.
  2. Parse payload second — After verification, parse or construct the event.
  3. Handle idempotently third — Check event ID, then process; return 2xx for duplicates.

See references/handler-sequence.md for details and links to provider verification and idempotency patterns.

Response Codes

| Code | Meaning | Provider Behavior | |------|---------|-------------------| | 2xx | Success | No retry | | 4xx | Client error | Usually no retry (except 429) | | 5xx | Server error | Retry with backoff | | 429 | Rate limited | Retry after delay |

Idempotency Checklist

  1. Extract unique event ID from payload
  2. Check if event was already processed
  3. Process event within transaction
  4. Store event ID after successful processing
  5. Return success for duplicate events

Related Skills