What are Webhooks?
Webhooks allow you to receive real-time notifications when your video generation or export jobs complete. Instead of polling the status endpoint repeatedly, Hoox will send an HTTP POST request to your specified URL when the job finishes.Benefits
Real-time Updates
Get notified immediately when jobs complete, no need to poll
Reduced API Calls
Save on rate limits by eliminating status polling
Better UX
Provide instant feedback to your users
Automation
Trigger downstream processes automatically
How Webhooks Work
Webhook Payload
All webhooks include atask field to identify the type of operation. This helps you route and process webhooks correctly.
Payload Structure by Task Type
| Field | video_generate | video_export | avatar_create | avatar_edit |
|---|---|---|---|---|
task | ✅ | ✅ | ✅ | ✅ |
job_id | ✅ | ✅ | ❌ | ❌ |
avatar_id | ❌ | ❌ | ✅ | ✅ |
look_id | ❌ | ❌ | ✅ | ✅ |
status | ✅ | ✅ | ✅ | ✅ |
result | ✅ | ✅ | ✅ | ✅ |
error | ✅ (on failure) | ✅ (on failure) | ✅ (on failure) | ✅ (on failure) |
Key differences:
- Video operations use
job_id(the Trigger.dev run ID) - Avatar operations use
avatar_idandlook_idinstead - Always check the
taskfield to determine how to process the webhook
Setting Up Webhooks
1. Create an Endpoint
Your webhook endpoint should:- Accept POST requests
- Respond with 200 status code
- Process the payload asynchronously if needed
2. Use in API Calls
Include your webhook URL when starting jobs:Security Considerations
1. Validate Requests
Verify that webhook requests are coming from Hoox:2. Use HTTPS
Always use HTTPS URLs for your webhook endpoints to ensure data is encrypted in transit.3. Implement Idempotency
Handle duplicate webhook deliveries gracefully:Retry Behavior
Hoox will retry webhook deliveries if your endpoint:- Returns a non-2xx status code
- Times out (after 10 seconds)
- Is unreachable
- 1st retry: After 1 second
- 2nd retry: After 2 seconds
- 3rd retry: After 4 seconds
- Maximum: 3 retry attempts
Testing Webhooks
1. Use ngrok for Local Development
2. Webhook Testing Tools
- RequestBin: Create temporary endpoints to inspect payloads
- Webhook.site: Test and debug webhook deliveries
- Postman: Mock webhook requests for testing
3. Test Endpoint
Create a simple test endpoint to verify webhook delivery:Best Practices
Task-Based Routing
Task-Based Routing
- Always check the
taskfield first to route webhooks correctly - Use different handlers for different task types
- Validate that required fields exist based on task type
- For avatars: use
avatar_idandlook_id - For videos: use
job_id
Response Time
Response Time
- Respond with 200 status as quickly as possible
- Process heavy operations asynchronously
- Use queues for complex workflows
Error Handling
Error Handling
- Log all webhook deliveries for debugging
- Handle malformed payloads gracefully
- Implement monitoring and alerting
- Check for required fields based on task type
Scalability
Scalability
- Use load balancers for high-volume webhooks
- Implement rate limiting on your endpoint
- Consider using message queues for processing
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| Webhooks not received | Endpoint unreachable | Check URL and firewall settings |
| Duplicate processing | No idempotency check | Implement unique ID tracking (job_id or avatar_id:look_id) |
| Slow processing | Heavy operations in handler | Move to background jobs |
| Missing webhooks | Endpoint returning errors | Fix endpoint logic and status codes |
| Wrong task routing | Not checking task field | Always check the task field first |
| Missing IDs | Accessing wrong fields | Use job_id for videos, avatar_id/look_id for avatars |

