Managing Webhooks

1. Configuring Webhook Endpoints

PropertyRecommendation
URLHTTPS only, public reachable
MethodPOST
BodyJSON event payload
Response2xx within 5s = ack
IdempotencyProcess by event_id

2. Implementing Webhook Signatures

Example: HMAC signature header

POST /webhooks HTTP/1.1
X-Webhook-Id: evt_abc123
X-Webhook-Timestamp: 1716000000
X-Webhook-Signature: sha256=hex(hmac_sha256(secret, timestamp + "." + body))

{"type": "payment.succeeded", "data": {...}}
CheckRequired
Constant-time compareAvoid timing attacks
Timestamp window± 5 min skew
Replay cacheReject duplicate event_id
Secret rotationSupport multiple active secrets

3. Implementing Webhook Authentication

MethodDetail
HMAC signaturePreferred (shared secret)
mTLSStrong, requires cert mgmt
Bearer tokenStatic or short-lived JWT
Basic authSimple, HTTPS only
IP allowlistDefense in depth

4. Setting Retry Policies for Webhooks

ProviderRetry Schedule
Stripe3d exponential
GitHub8h up to 8 retries
Recommended1m, 5m, 30m, 2h, 12h, 24h, 48h, 72h
Retry on5xx, timeouts, connection errors
Stop on410 Gone, 401 invalid signature

5. Configuring Webhook Timeouts

TimeoutTypical
Connect3s
Read (response)5-10s
Total deadline15s
After: treat as failureSchedule retry

6. Using Webhook Event Filtering

Example: Subscribe to specific events

{
  "url": "https://app.example.com/hook",
  "secret": "whsec_...",
  "events": ["payment.succeeded", "payment.failed", "refund.created"],
  "api_version": "2026-05-15"
}

7. Implementing Webhook Delivery Logs

FieldPurpose
event_idIdentify event
endpoint_urlDestination
attempt_numberRetry tracking
status_codeReceiver response
latency_msPerformance
next_retry_atSchedule
request/response bodyDebug

8. Setting Up Webhook Testing

ToolUse
CLI stripe triggerSend test events
ngrok/Cloudflare TunnelExpose localhost
webhook.siteInspect payloads
Replay endpointRe-deliver past events

9. Configuring Webhook Rate Limiting

LimitReason
Per-endpoint concurrencyAvoid overwhelming receiver
Per-account RPSFair share
Burst allowanceHandle event bursts
Back off on 429Honor Retry-After

10. Using Webhook Payload Transformation

TransformationUse Case
Field renamingMatch receiver schema
Field strippingRemove PII per receiver
Format conversionJSON → XML for legacy
Template injectionCustomer-specific wrapping