Overview
Callbacks provide an efficient way to receive notifications when your Runway Alpeh video generation tasks complete. Instead of repeatedly polling the API, your application can receive instant notifications via webhooks when videos are ready.Callbacks are the recommended approach for production applications as they reduce API calls, improve response times, and provide immediate notification of task completion.
How Callbacks Work
1
Submit Generation Request
Include a
callBackUrl
parameter in your video generation request:2
Receive Task ID
The API immediately returns a task ID while processing begins:
3
Process Callback
When generation completes, our system sends a POST request to your callback URL with the results.
Callback Payload
When video generation completes, you’ll receive a POST request with the following payload:Success Callback
Status code indicating the result
200
: Video generated successfully400
: Generation failed due to content policy or technical issues
Human-readable message describing the result
Video generation results
The original task ID from your generation request
Error Callback
Implementing Callback Endpoints
Node.js/Express Example
Python/Flask Example
PHP Example
Security Best Practices
Validate Callback Source
Validate Callback Source
Verify Request Origin:
- Check the
User-Agent
header for requests from kie.ai - Consider implementing IP whitelist for additional security
- Validate the callback payload structure before processing
Handle Duplicate Callbacks
Handle Duplicate Callbacks
Implement Idempotency:
- Track processed task IDs to avoid duplicate processing
- Use database constraints or caching to prevent race conditions
Error Handling and Retry Logic
Error Handling and Retry Logic
Robust Error Handling:
- Always return HTTP 200 for successful callback receipt
- Log errors for debugging but don’t expose internal details
- Implement retry logic for critical operations
Testing Callbacks
Local Development
For local testing, use tools like ngrok to expose your local server:Webhook Testing Tools
Webhook.site
Generate temporary URLs to test callback payloads
RequestBin
Inspect and debug webhook requests
Troubleshooting
Callbacks Not Received
Callbacks Not Received
Common Issues:
- Callback URL is not publicly accessible
- Server is returning non-200 status codes
- Firewall blocking incoming requests
- SSL certificate issues with HTTPS URLs
- Test your callback URL with tools like curl or Postman
- Ensure your server responds with HTTP 200 status
- Check server logs for incoming requests
- Verify SSL certificate is valid
Duplicate or Missing Callbacks
Duplicate or Missing Callbacks
Callback Delivery:
- Our system retries failed callbacks up to 3 times
- Callbacks are sent only once per task completion
- If your server is down, callbacks may be lost
- Implement idempotency to handle potential duplicates
- Use polling as a backup for critical tasks
- Monitor callback receipt and alert on missing notifications
Callback Payload Issues
Callback Payload Issues
Data Validation:
- Always validate the callback payload structure
- Handle missing or unexpected fields gracefully
- Log payload contents for debugging
Related Documentation
Generate Aleph Video
Learn how to create video generation requests with callbacks
Get Task Details
Alternative polling method for checking task status
Need Help? Contact our support team at support@kie.ai for assistance with callback implementation.