Webhook Integration (Legacy)
Legacy Version - This documentation covers the legacy webhook system. For new integrations, please use the v1 Webhooks which include Svix integration for improved reliability and security.
Webhook Structure
MDB sends webhooks with the following JSON structure:Delivery Rules
Understanding when and how webhooks are delivered:- One webhook per identified session - You receive exactly one webhook when a session with an identified visitor completes
 - Session-bound - Sessions are tied to both the website domain and tracking ID
 - Multiple sites - If you have pixels on multiple sites and the same person visits both, you’ll receive separate webhooks for each site
 
Session Definition
A session in MDB is defined as:- A continuous string of events with no more than 20 minutes between them
 - Maximum duration of 24 hours
 - Bound to both website and tracking ID
 
Webhook Scenarios
Single Site Visit
Single Site Visit
Scenario: User visits 
site-a.com with your pixelResult: One webhook sent when the identified session completesMultiple Sites
Multiple Sites
Scenario: User visits both 
site-a.com and site-b.com (both with your pixels)Result: Two separate webhooks sent, one for each site’s sessionSession Timeout
Session Timeout
Scenario: User is active on your site, then inactive for 20+ minutesResult: Current session ends, new session starts with next activity
Extended Visit
Extended Visit
Scenario: User stays active on your site for over 24 hoursResult: Session automatically ends at 24 hours, new session begins
Implementation Guide
Setting Up Your Webhook Endpoint
- Create an HTTPS endpoint that can receive POST requests
 - Configure the URL in your MDB dashboard
 - Implement proper request handling for the webhook payload
 - Return appropriate HTTP status codes
 
Example Webhook Handler
Best Practices
Always validate webhook payloads and implement proper error handling to ensure reliable data processing.
Security
- Use HTTPS - Always use secure endpoints for webhook URLs
 - Validate payloads - Check that incoming data matches expected structure
 - Implement authentication - Consider implementing your own signature validation
 
Reliability
- Return 2xx status codes - Any 2xx status code (200, 201, 204, etc.) indicates successful receipt
 - Non-2xx triggers retries - Any status code outside 2xx range will trigger the retry mechanism
 - Handle errors gracefully - Implement retry logic for failed processing on your end
 - Monitor webhook health - Track successful vs failed webhook deliveries
 
Retry Policy
MDB implements automatic retry logic for failed webhook deliveries:- Success criteria - Webhooks are considered successfully received on any 2xx HTTP status code
 - Failure criteria - Any non-2xx status code (3xx, 4xx, 5xx) triggers the retry mechanism
 - Exponential backoff - Retries with increasing delays between attempts
 - Maximum retry window - Retries continue for up to 5 minutes
 - Final status - After 5 minutes, the webhook is marked as completed even if failed
 
Retry Schedule Example
Design your webhook endpoint to be idempotent since the same webhook may be delivered multiple times during retry attempts.
Data Processing
- Process asynchronously - Don’t block webhook response with heavy processing
 - Store data safely - Ensure person-level data is handled according to privacy requirements
 - Use options data - Leverage the options object for routing and categorization
 - Extract tenant context - Use 
tenant_idand other identifiers for multi-tenant routing and attribution 
Troubleshooting
Common Issues
- Webhook not received - Check your endpoint URL and ensure it’s accessible
 - Invalid JSON - Verify your endpoint can handle JSON POST requests
 - Timeout errors - Ensure your endpoint responds quickly (< 30 seconds)
 
Testing
- Use development URLs - Test with development webhook endpoints first
 - Monitor logs - Check both MDB dashboard and your server logs
 - Validate data structure - Ensure your code handles the webhook structure correctly
 
Migration to v1 Webhooks
We recommend migrating to v1 Webhooks for improved reliability and security:Key Improvements in v1
| Feature | Legacy Webhooks | v1 Webhooks | 
|---|---|---|
| Delivery Service | Direct | Svix-powered | 
| Signature Verification | Manual | Built-in with Svix | 
| Monitoring Dashboard | Limited | Full Svix Dashboard | 
| Event Replay | No | Yes | 
| Delivery Logs | Basic | Comprehensive | 
Migration Steps
- Update to v1 pixel - First migrate to the v1 Pixel
 - Get Svix webhook secret - Find it in your MDB dashboard
 - Implement signature verification - Add Svix verification to your endpoint
 - Test thoroughly - Verify webhooks are received and verified correctly
 - Monitor in Svix Dashboard - Use the enhanced monitoring capabilities
 
Next Steps
- Consider migrating to v1 - Get improved reliability with Svix integration
 - Implement data processing - Build your logic for handling identified visitor data
 - Monitor performance - Track webhook delivery success rates