Callbacks

Using Callbacks

If you want the system to proactively notify you of the result once a task completes, pass callback_url when creating the task. If callback_url is not provided, please actively fetch the task status via the query endpoint.

Callback URL Requirements

ItemRequirement
ProtocolMust use HTTP or HTTPS
LengthUp to 500 characters
AccessibilityMust be reachable by the Bach server
Request MethodBach sends callbacks using POST
Content-Typeapplication/json
Success ResponseAny 2xx status code returned by your service is treated as successfully received

Video Task Success Callback

After a video is generated successfully, the system sends the following JSON to callback_url:

json
Copy
{
  "task_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "TASK_SUCCEEDED",
  "video_url": "https://example.com/result.mp4"
}
FieldTypeDescription
task_idstringTask ID
statusstringTask status
video_urlstringVideo result URL

Failure Callback

After a task fails, the system sends the following JSON to callback_url:

json
Copy
{
  "task_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "TASK_FAILED",
  "error": {
    "code": 1001,
    "message": "Contains sensitive information."
  },
  "timestamp": 1778313600000
}
FieldTypeDescription
task_idstringTask ID
statusstringTask status
error.codestringError code
error.messagestringError description
timestampnumberCallback send time, Unix timestamp in milliseconds

Callback Notes

  • If your service returns a 2xx status code, the system treats this callback as successfully received.
  • If your service does not return a 2xx status code, the system records this callback as failed; a failed callback does not affect the task's own status.
  • To see more complete task status and timing information, call the corresponding query endpoint for details.
Previous
General
Next
Error Codes
On this page
Callbacks | bach.art | bach.art