Webhook Integration
Send your simulated events to any HTTP endpoint for custom integrations and real-time processing.
Overview
Webhook integration provides maximum flexibility for sending MockCDP events to any HTTP endpoint. This is perfect for custom integrations, internal systems, serverless functions, or any service that can receive HTTP POST requests. Configure multiple webhook destinations to fan out your simulated events across different systems.
Required Configuration
- Webhook URL: Your HTTP endpoint that will receive events
- HTTP Method: POST (recommended) or PUT
- Authentication: Optional headers, API keys, or basic auth
- Custom Headers: Additional headers for your endpoint
Setup Instructions
1. Prepare Your Endpoint
Your webhook endpoint should:
- Accept HTTP POST requests
- Handle JSON payloads (Content-Type: application/json)
- Return appropriate HTTP status codes (200-299 for success)
- Be accessible from the internet (unless using private network)
- Implement proper authentication if needed
2. Configure Authentication (Optional)
Common authentication methods:
- API Key Header:
Authorization: Bearer your-api-key
- Custom Header:
X-API-Key: your-api-key
- Basic Auth: Username and password encoding
- Signature Verification: HMAC signature in headers
3. Configure in MockCDP
- Navigate to Destinations in MockCDP
- Find Webhook in the list
- Toggle Enable to on
- Enter your Webhook URL
- Select HTTP Method (POST recommended)
- Add Authentication Headers if needed
- Add any Custom Headers
- Click Test Webhook to verify connection
- Click Save Configuration
Event Payload Format
MockCDP sends events in this standardized JSON format:
Standard Event Structure
{
"event_id": "uuid-v4-event-identifier",
"timestamp": "2024-01-15T10:30:00.000Z",
"event_type": "product_viewed",
"user_id": "user_12345",
"session_id": "session_67890",
"properties": {
"product_id": "SKU_001",
"product_name": "Wireless Headphones",
"price": 129.99,
"category": "Electronics"
},
"context": {
"ip": "192.168.1.100",
"user_agent": "Mozilla/5.0...",
"page_url": "https://example.com/products/headphones",
"referrer": "https://google.com"
},
"metadata": {
"source": "mockcdp",
"simulation_id": "sim_abc123",
"version": "1.0"
}
}
Event Types
Event Type | Description | Key Properties |
---|---|---|
page_viewed | User navigated to a page | page_name, page_url, referrer |
product_viewed | User viewed a product page | product_id, name, price, category |
product_added | User added item to cart | product_id, quantity, cart_total |
checkout_started | User initiated checkout | cart_id, cart_value, item_count |
order_completed | User completed purchase | order_id, total, payment_method |
user_signed_up | New user registration | email, signup_method, source |
Common Use Cases
Development & Testing
- Local Development: Test webhooks with ngrok or similar tunneling tools
- API Testing: Validate your API endpoints with realistic event data
- Integration Testing: Test event processing workflows end-to-end
- Load Testing: Stress test your webhook endpoints with high event volumes
Serverless Functions
- AWS Lambda: Process events through Lambda functions
- Vercel Functions: Handle events in edge functions
- Netlify Functions: Process webhooks in serverless environment
- Google Cloud Functions: Stream events to cloud functions
Custom Integrations
- Internal APIs: Send events to your internal systems
- Message Queues: Push events to Redis, RabbitMQ, or Kafka
- Data Pipelines: Stream events to data processing systems
- Real-time Processing: Trigger real-time calculations and updates
Error Handling & Reliability
Retry Logic
- Automatic retries for 5xx server errors and timeouts
- Exponential backoff with jitter to prevent thundering herd
- Maximum of 3 retry attempts per event
- Failed events are logged for debugging
Response Handling
- Success: 200-299 status codes (event delivered successfully)
- Client Error: 400-499 status codes (no retry, check configuration)
- Server Error: 500-599 status codes (will retry with backoff)
- Timeout: 30-second timeout limit (will retry)
Security Considerations
- Use HTTPS endpoints for sensitive data
- Implement proper authentication and authorization
- Validate webhook payloads on your end
- Consider rate limiting on your webhook endpoint
- Log webhook attempts for monitoring and debugging
Best Practices
- Idempotency: Handle duplicate events gracefully using event IDs
- Async Processing: Return 200 immediately and process events asynchronously
- Monitoring: Set up alerts for webhook failures and response times
- Testing: Use webhook testing tools like webhook.site for development
- Documentation: Document your webhook endpoint requirements and response format
Need Help?
Check our troubleshooting guide or contact support.