The Challenge of Testing SendGrid Webhooks Locally
SendGrid webhooks are powerful—they let you track email opens, bounces, clicks, and delivery status in real time. But testing them locally is frustrating. Your webhook endpoint lives at localhost:3000, which SendGrid can't reach from the internet. You're left juggling ngrok tunnels, managing temporary URLs, or pushing code to staging just to verify that a bounce event triggers the right database update.
The core problem: test SendGrid webhooks locally without exposing your machine, and without losing the ability to inspect and replay payloads when something breaks. This article walks through three production-ready approaches—from manual tunneling to local webhook relaying—so you can debug with confidence.
Prerequisites
SendGrid account with API key (free tier works)
Node.js 16+ and npm or yarn installed
Express.js or similar HTTP server running locally (we'll use Express in examples)
Understanding of HMAC-SHA256 verification (SendGrid signs all webhooks; you must validate the signature)
curl or Postman for manual testing
Testing SendGrid Event Webhooks Locally: Three Approaches
Approach 1: Manual Tunnel with ngrok (Quick, Temporary)
If you need to test right now and don't mind a temporary URL:
# Terminal 1: Start ngrok tunnel
ngrok http 3000
# Copy the forwarding URL, e.g., https://abc123.ngrok.io
Then in SendGrid dashboard:
- Go Settings → Event Webhooks
- Paste
https://abc123.ngrok.io/webhooks/sendgridas the endpoint - Enable event types (Bounce, Click, Open, etc.)
- Click Test Your Integration
Your local Express server will receive the test event. But ngrok URLs regenerate on restart, and managing multiple test sessions gets tedious. to explore the free tier or Pro features like signature verification helpers and synthetic events.
SOCIAL SHARE CARD GENERATOR