callback_url to receive webhook notifications when the task completes or fails. This avoids polling and lets you integrate with your backend asynchronously.
Enabling Callbacks
Passcallback_url at the top level of your request (outside the input object):
string
Optional webhook URL. When provided, the API sends a POST request to this URL when the task completes or fails.
Webhook Payload Format
The API sends a POST request to yourcallback_url with a JSON body. The payload structure depends on whether the task succeeded or failed.
Success Payload
When the task completes successfully:data object contains the output URL(s) based on the task type:
Some models may return additional fields. For example, multi-output models might include
image_urls or audio_urls as arrays.
Failure Payload
When the task fails:Request Details
- Method: POST
- Content-Type:
application/json - Body: JSON payload as shown above
Best Practices
- Respond quickly — Return a 2xx status code within a few seconds to acknowledge receipt. Process the payload asynchronously if needed.
- Verify webhook origin — Use HTTPS and consider validating requests (e.g., via a shared secret or signature if supported in the future).
- Handle duplicates — The same webhook may be delivered more than once; use
task_idto deduplicate. - Validate URLs — Ensure your callback URL is publicly accessible and accepts POST requests.
