Why Use Webhooks?
Webhooks eliminate the need to continuously poll the API for status updates. Instead, Bluma notifies your server immediately when events occur, reducing API calls and providing instant updates. Benefits:- ⚡ Real-time notifications
- 🔽 Reduced API usage
- 💰 Lower rate limit consumption
- 🎯 Event-driven architecture
Prerequisites
Before setting up webhooks, you need:- ✅ A publicly accessible HTTPS endpoint
- ✅ A server that can receive POST requests
- ✅ A Bluma API key (get one here)
Step 1: Create Your Webhook Endpoint
Node.js/Express Example
Python/Flask Example
Step 2: Register Your Webhook
Register your webhook endpoint with the Bluma API:Step 3: Verify Webhook Signatures
Always verify signatures to ensure webhooks are genuinely from Bluma and haven’t been tampered with.How Signature Verification Works
Bluma signs each webhook with HMAC-SHA256:X-Bluma-Signature header as sha256=<hex_digest>.
Node.js Verification
Python Verification
Always use constant-time comparison functions (
crypto.timingSafeEqual in Node.js, hmac.compare_digest in Python) to prevent timing attacks.Step 4: Handle Events
Process different event types appropriately:Complete Event Handler
Step 5: Implement Idempotency
Webhooks may be delivered multiple times. Handle duplicates gracefully:Using a Processed Events Cache
Using Database
Step 6: Testing Locally
Option 1: Using ngrok
Option 2: Using webhook.site
- Go to webhook.site
- Copy your unique URL
- Register it as your webhook:
- Generate a test video
- View the webhook payload in real-time at webhook.site
Step 7: Monitor Webhook Deliveries
Check webhook delivery status and debug failures:Production Best Practices
Respond Quickly
Return 200 status within 5 seconds. Queue events for async processing.
Verify Signatures
Always validate HMAC signatures before processing.
Handle Duplicates
Use event IDs for idempotency (database or cache).
Log Everything
Log all webhook deliveries for debugging and audit trails.
Use HTTPS
Production webhooks require HTTPS endpoints.
Monitor Failures
Set up alerts for delivery failures to prevent auto-disable.
Asynchronous Processing Pattern
Troubleshooting
Webhooks not being received
Webhooks not being received
Check:
- Is your endpoint publicly accessible via HTTPS?
- Is your firewall blocking Bluma’s servers?
- Are you returning a 2xx status code?
- Check delivery logs for error messages
Signature verification failing
Signature verification failing
Common issues:
- Using parsed JSON instead of raw body
- Wrong webhook secret (check environment variable)
- Secret was regenerated
Receiving duplicate events
Receiving duplicate events
This is expected behavior. Implement idempotency:
Webhook was auto-disabled
Webhook was auto-disabled
Cause: 10 consecutive delivery failuresFix:
- Check delivery logs to identify the issue
- Fix your endpoint
- Delete and recreate the webhook
Complete Working Example
Here’s a production-ready webhook server:Next Steps
Webhook API Reference
View complete webhooks API documentation
Webhook Concepts
Learn about event types and payloads
Error Handling
Handle webhook delivery failures
Best Practices
Build production-ready integrations