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)
Use ngrok or webhook.site for local development and testing. Production webhooks require HTTPS.

Step 1: Create Your Webhook Endpoint

Node.js/Express Example

Python/Flask Example

Critical: Always respond with a 2xx status code within 5 seconds, even if event processing takes longer. Process events asynchronously.

Step 2: Register Your Webhook

Register your webhook endpoint with the Bluma API:
Response:
IMPORTANT: The secret is shown only once. Save it securely - you’ll need it to verify webhook signatures.

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:
The signature is sent in the 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

  1. Go to webhook.site
  2. Copy your unique URL
  3. Register it as your webhook:
  1. Generate a test video
  2. View the webhook payload in real-time at webhook.site
webhook.site is perfect for inspecting payloads, but won’t verify signatures. Use ngrok for full integration testing.

Step 7: Monitor Webhook Deliveries

Check webhook delivery status and debug failures:
Response:

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

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
Test:
Common issues:
  • Using parsed JSON instead of raw body
  • Wrong webhook secret (check environment variable)
  • Secret was regenerated
Fix:
This is expected behavior. Implement idempotency:
Cause: 10 consecutive delivery failuresFix:
  1. Check delivery logs to identify the issue
  2. Fix your endpoint
  3. 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

Congratulations! 🎉

You’ve successfully set up webhooks for real-time event notifications. Your application will now receive instant updates when videos complete, eliminating the need for polling.