Webhooks Guide
Webhooks Guide
Connect Synap to any external system
Overview
Webhooks enable real-time event delivery from your Synap data pod to external systems. When any event occurs, Synap can POST it to your configured webhook URL immediately.
Use Cases:
- ✅ Notify Slack when tasks are completed
- ✅ Trigger n8n workflows on entity creation
- ✅ Sync data to external databases
- ✅ Build custom integrations with any HTTP endpoint
- ✅ Chain multiple systems together
How Webhooks Work
Flow
Event Delivery Guarantee
- Automatic retries: 3 attempts with exponential backoff
- Retry schedule: 1s, 4s, 16s
- Dead letter queue: Failed events logged for manual review
- At-least-once delivery: Events may be delivered multiple times (idempotency recommended)
Creating a Webhook
1. Set Up Endpoint
Your webhook endpoint must:
- Accept HTTP POST requests
- Return 2xx status code for success
- Respond within 30 seconds
- Handle duplicate deliveries idempotently
Example (Express.js):
2. Subscribe via API
Using tRPC:
Using HTTP:
3. Configure Event Filtering
Subscribe to specific event types:
Webhook Payload
Structure
Headers
Security
HMAC Signature Validation
Synap signs every webhook with HMAC-SHA256:
Python:
Best Practices
- ✅ Always validate signatures - Prevent spoofed webhooks
- ✅ Use HTTPS - Encrypt data in transit
- ✅ Rotate secrets - Every 90 days
- ✅ Implement idempotency - Handle duplicate deliveries
- ✅ Log webhook IDs - Track received events
Retry Policy
Automatic Retries
| Attempt | Delay | Total Wait |
|---|---|---|
| 1 | 0s | 0s |
| 2 | 1s | 1s |
| 3 | 4s | 5s |
| 4 (final) | 16s | 21s |
Failure Handling
Common Integration Patterns
Pattern 1: Slack Notifications
Goal: Post to Slack when task completed
Pattern 2: n8n Workflow Trigger
Goal: Trigger n8n workflow on entity creation
See n8n Integration Guide for complete examples.
Pattern 3: External Database Sync
Goal: Sync Synap entities to external Postgres
Pattern 4: Multi-System Chaining
Goal: Chain Synap → Slack → Jira
Managing Webhooks
List Subscriptions
Update Subscription
Pause/Resume
Delete Subscription
Monitoring & Debugging
Check Delivery Status
Test Webhook
Rate Limits
| Operation | Limit |
|---|---|
| Webhooks per user | 100 |
| Deliveries per second | 100 |
| Payload size | 1MB |
| Timeout | 30s |
Troubleshooting
Webhook Not Receiving Events
Check:
- URL is publicly accessible
- Returns 2xx status code
- Event type matches subscription
- Webhook is active (
active: true) - No firewall blocking Synap IPs
Signature Validation Failing
Check:
- Secret matches exactly (no extra spaces)
- Using raw request body (not parsed JSON)
- Comparing hex strings correctly
- Signature header present
Debug:
High Failure Rate
Solutions:
- Increase timeout (ensure <30s response)
- Process async (return 200 immediately, process in background)
- Check server logs for errors
- Verify network stability
Best Practices
1. Idempotency
2. Async Processing
3. Error Handling
Next Steps
- n8n Integration - Complete n8n workflow examples
- Event catalog - All available events
- Event sourcing explained - Understanding events
- API reference - Procedure reference
