Prompt
How do I test webhooks locally before deploying?
Latest observation
Testing webhooks locally is usually done by making your local server reachable from the internet, or by simulating the sender. Common options:
1. Use a tunnel service
These expose your localhost to a public URL.
-
ngrok: very popular
ngrok http 3000It gives you a temporary public URL like
https://abcd.ngrok.iothat forwards tolocalhost:3000. -
Cloudflare Tunnel:
cloudflared tunnel --url http://localhost:3000 -
LocalTunnel:
npx localtunnel --port 3000
Then configure the webhook provider to send events to that public URL, e.g.:
https://abcd.ngrok.io/webhook
2. Use webhook testing tools
These help inspect incoming requests and replay them.
- Webhook.site
- Pipedream Webhook Inspector
- RequestBin-style tools
Great for checking payload shape and headers.
3. Mock the webhook sender
If you know the expected payload, you can send test requests directly with curl or Postman:
curl -X POST http://localhost:3000/webhook \
-H "Content-Type: application/json" \
-d '{"event":"payment_succeeded","id":"evt_123"}'
This is useful for testing your handler logic without involving the real provider.
4. Use the provider’s test/sandbox mode
Many services let you:
- send test events
- use sandbox accounts
- configure development webhooks
Examples:
- Stripe test mode
- GitHub webhook delivery testing
- Shopify dev store webhooks
5. Record and replay real payloads
Capture a real webhook payload in production or staging, save it, and replay it locally against your endpoint. This helps test edge cases.
Good local workflow
- Run your app locally.
- Start a tunnel to expose the webhook endpoint.
- Point the provider to the tunnel URL.
- Log requests and verify signature validation.
- Use test events to iterate quickly.
Important things to verify
- Raw request body handling for signature verification
- Correct headers and content type
- Idempotency handling for retries
- Response status codes and timeouts
If you want, I can show you a concrete setup for Stripe, GitHub, or Shopify webhooks locally.