Testing Webhooks
Tools and techniques for testing webhooks during development and debugging in production.
Local Development
Use ngrok or similar tools to expose your local server to receive webhooks.
Test Events
Send test events from the dashboard to verify your endpoint is working.
Replay Events
Replay failed webhook deliveries to debug and fix issues.
Local Development with ngrok
Expose your local webhook endpoint to the internet for testing
1
Install ngrok
# macOS
brew install ngrok
# Windows
choco install ngrok
# Or download from https://ngrok.com/download2
Start your local server
# Start your development server
npm run dev
# Your webhook endpoint: http://localhost:3000/api/webhooks/regen3
Expose with ngrok
ngrok http 3000
# Output:
# Forwarding: https://abc123.ngrok.io -> http://localhost:30004
Register the webhook URL
Use the ngrok URL as your webhook endpoint in the Regen Therapy dashboard:
https://abc123.ngrok.io/api/webhooks/regenDevelopment Only
ngrok URLs change each time you restart. For production, use a permanent URL. Consider ngrok paid plans for static URLs during development.
Sending Test Events via API
Programmatically send test webhook events to verify your endpoint
curl -X POST https://gateway.regentherapy.com/api/v1/webhooks/test \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"webhook_id": "wh_abc123",
"event_type": "order.created"
}'Available Test Event Types
order.createdorder.updatedorder.shippedorder.deliveredinventory.low_stockcommission.created
Viewing Webhook Delivery Logs
Monitor webhook deliveries and debug failures
Every webhook delivery is logged with detailed information including:
Request Details
- • Full request payload
- • Headers sent
- • Timestamp
- • Event type
Response Details
- • HTTP status code
- • Response body (first 1KB)
- • Response time
- • Error messages (if any)
# List recent webhook deliveries
curl https://gateway.regentherapy.com/api/v1/webhooks/wh_abc123/deliveries \
-H "Authorization: Bearer YOUR_API_KEY"
# Response
{
"deliveries": [
{
"id": "del_xyz789",
"event_type": "order.created",
"status": "success",
"http_status": 200,
"response_time_ms": 145,
"created_at": "2024-01-15T10:30:00Z",
"attempts": 1
},
{
"id": "del_abc456",
"event_type": "order.shipped",
"status": "failed",
"http_status": 500,
"error": "Internal server error",
"response_time_ms": 2340,
"created_at": "2024-01-15T09:15:00Z",
"attempts": 3
}
]
}Replaying Failed Webhooks
Retry failed webhook deliveries after fixing issues
If a webhook delivery fails, you can replay it once you've fixed the issue on your end. This is useful for recovering from temporary outages or bugs.
# Replay a specific delivery
curl -X POST https://gateway.regentherapy.com/api/v1/webhooks/deliveries/del_abc456/replay \
-H "Authorization: Bearer YOUR_API_KEY"
# Response
{
"delivery_id": "del_new789",
"status": "pending",
"message": "Webhook replay queued"
}Idempotency Warning
Ensure your webhook handler is idempotent. Use the
X-Regen-Delivery-ID header to detect and handle duplicate deliveries.Pre-Production Testing Checklist
1
Signature verification is implemented and working2
Timestamp validation prevents replay attacks (5-minute window)3
Endpoint returns 200 status within 30 seconds4
Handler is idempotent (same event twice = same result)5
Delivery ID is stored to detect duplicates6
Error responses include useful debugging info7
Endpoint handles all subscribed event types8
Logging captures event details for debugging9
Alerting is set up for repeated failures10
Endpoint is accessible from the internet (not localhost)