Why Use Webhooks?
Instead of repeatedly calling the API to check if your video is done (polling), webhooks notify you instantly when processing completes.Polling (Inefficient)
Webhooks (Efficient)
- Real-time: Get notified instantly when processing completes
- Efficient: No repeated API calls or bandwidth waste
- Scalable: Process multiple videos without constant polling
- ✅ Use webhooks for production apps, automation, background processing
- ⚠️ Use polling for quick scripts, testing, or if you can’t receive HTTP requests
How VideoBGRemover Webhooks Work
When you start a job with awebhook_url, our system:
- Validates your webhook URL (HTTPS required in production)
- Stores the URL with your job
- Triggers 3 events during processing:
job.started- Processing beginsjob.completed- Video ready (includes output URLs)job.failed- Processing failed (includes error message)
- Sends POST request to your URL with JSON payload
- Retries up to 3 times (10 seconds apart) if delivery fails
- Waits for BOTH background removal AND export to complete before final webhook
The system waits for your complete video (with composition/export) before sending the
job.completed webhook. This prevents premature notifications.Quick Setup
Your webhook endpoint must:- Accept
POSTrequests withContent-Type: application/json - Return a
2xxstatus code quickly (< 5 seconds) - Use HTTPS (production only - HTTP allowed for testing)
Using Webhooks via cURL
Addwebhook_url to your job start request:
Using Webhooks via API Client (Low-Level)
Use theVideoBGRemoverClient class for direct API control:
Using Webhooks via SDK (High-Level)
Use theVideo class for simpler workflows:
Webhook support for the high-level
video.removeBackground() SDK method is coming soon. For now, use the low-level client.startJob() API shown above for webhook functionality.Webhook Events & Payloads
Your webhook endpoint will receive POST requests with these payloads:job.started
Fires when processing begins.job.completed
Fires when BOTH background removal AND export complete.To download the processed video, call the status endpoint:
GET /v1/jobs/{id}/status which returns the processed_video_url field with the download URL.job.failed
Fires when processing or export fails.HTTP Headers
Webhooks include these headers:Checking Delivery History
View webhook delivery attempts and results:API Endpoint
SDK Methods
Best Practices
Return 200 Immediately
Process webhooks asynchronously to avoid timeouts:Handle Retries
Useattempt_number to detect retries:
Validate Events
Check event type before processing:Use HTTPS
Production webhooks require HTTPS for security.Common Issues
Webhook Not Received
- Check delivery history using the API or SDK
- Verify HTTPS (required in production)
- Check firewall - ensure your server is publicly accessible
- Test with webhook.site to verify our system is sending correctly
Duplicate Webhooks
This is expected during retries. Implement idempotency:Timeout Errors
- Optimize your webhook endpoint to respond in < 5 seconds
- Return 200 immediately, process asynchronously
- Check delivery history to see timeout errors
Next Steps
- API Reference - Complete API documentation
- Examples - Webhook server code examples
- SDK Reference - Full SDK documentation
