Skip to main content

SendGrid Webhook Integration

SendGrid Event Webhooks provide real-time notifications about email events including deliveries, bounces, opens, clicks, and more. Monitor your email campaigns and transactional emails with detailed engagement tracking.

Quick Start

  1. Get your Unhook URL: https://unhook.sh/wh_YOUR_ID
  2. Configure in SendGrid: app.sendgrid.com/settings/mail_settings/webhook
  3. Start receiving events locally: unhook listen

Configuration Steps

1. Access SendGrid Event Webhook Settings

Navigate to SendGrid Settings:

2. Configure Event Webhook

  1. Toggle Event Webhook Status to Enabled
  2. Enter your HTTP Post URL:
  3. Select Actions to be POSTed

3. Select Event Types

Choose the events you want to receive:

Engagement Events

  • Processed - Message accepted by SendGrid
  • Dropped - Message dropped (bounced address, unsubscribed, etc.)
  • Delivered - Message delivered to recipient server
  • Deferred - Temporary delivery failure
  • Bounce - Permanent delivery failure
  • Open - Recipient opened email
  • Click - Recipient clicked a link
  • Unsubscribe - Recipient unsubscribed
  • Spam Report - Marked as spam
  • Group Unsubscribe - Unsubscribed from suppression group
  • Group Resubscribe - Resubscribed to suppression group

4. Additional Configuration

Security Settings

  1. Enable Signed Event Webhook:
    • Toggle Signed Event Webhook Requests to ON
    • Copy the Verification Key for signature validation
    • This key is used to verify webhooks are from SendGrid
  2. OAuth 2.0 (Optional):
    • Enable if you need OAuth authentication
    • Configure client credentials

Advanced Options

  • Test Your Integration - Send a test POST
  • Unique Arguments - Include custom data in events
  • Categories - Filter events by category

5. Save Configuration

Click Save to activate your webhook endpoint.

Event Payload Examples

Email Delivered

Email Opened

Email Bounced

Webhook Security

Verify Event Webhook Signatures

SendGrid signs webhooks using ECDSA. Verify them:

Best Practices

1. Handle Batch Events

SendGrid sends events in batches:

2. Process Events Asynchronously

Don’t block the webhook response:

3. Handle Duplicate Events

Use sg_event_id for deduplication:

4. Store Raw Events

Keep raw event data for debugging:

Testing Webhooks

Using SendGrid UI

  1. Go to Event Webhook settings
  2. Click Test Your Integration
  3. Select event types to test
  4. Click Send Test

Using cURL

Common Event Patterns

Track Email Journey

Monitor Bounce Rates

Environment Variables

Common Issues

Missing Events

  • Ensure all desired event types are selected
  • Check that webhook is enabled
  • Verify URL is accessible

Signature Verification Failures

  • Use the exact public key from SendGrid
  • Ensure you’re using the raw request body
  • Include proper newlines in the public key

Delayed Events

  • Open and click events may be delayed
  • Implement retry logic for critical operations
  • Some events (like bounces) may take time to process

Large Payloads

  • SendGrid batches up to 1,000 events
  • Implement proper timeout handling
  • Consider streaming large payloads

Support

Need help with SendGrid webhooks?