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/download
2

Start your local server

# Start your development server
npm run dev
# Your webhook endpoint: http://localhost:3000/api/webhooks/regen
3

Expose with ngrok

ngrok http 3000

# Output:
# Forwarding: https://abc123.ngrok.io -> http://localhost:3000
4

Register the webhook URL

Use the ngrok URL as your webhook endpoint in the Regen Therapy dashboard:

https://abc123.ngrok.io/api/webhooks/regen
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"
}
Pre-Production Testing Checklist
1
Signature verification is implemented and working
2
Timestamp validation prevents replay attacks (5-minute window)
3
Endpoint returns 200 status within 30 seconds
4
Handler is idempotent (same event twice = same result)
5
Delivery ID is stored to detect duplicates
6
Error responses include useful debugging info
7
Endpoint handles all subscribed event types
8
Logging captures event details for debugging
9
Alerting is set up for repeated failures
10
Endpoint is accessible from the internet (not localhost)