Async Jobs
Cancel Task
Cancel a queued async task when the provider and model support cancellation
Overview
Use DELETE /v1/tasks/{id} to cancel an asynchronous task that has not started running yet. Use the same task ID from the create response or the returned poll_url.
Supported Tasks
Cancellation is available for queued Seedance tasks using seedance-1.5-pro, seedance-2.0, seedance-2.0-fast, or seedance-2.5 when that task supports cancellation. A task already running or in a terminal state cannot be cancelled. Status remains queryable while its public task record is retained.
Path Parameters
The async task ID returned by the create request or embedded in poll_url.
Response
Canonical async task identifier.
Async task identifier alias.
Preferred polling URL for the task. It remains valid after cancellation.
Task status. A successfully cancelled task is returned as failed with cancelled: true for compatibility with existing status values.
true when the task was cancelled before execution.
Cancellation marker. The value is cancelled when cancellation succeeds.
Cancellation reason or task failure message.
Error Behavior
400 unsupported_task_cancel means the task type, provider, or model does not support cancellation. 409 task_not_cancellable means the task is already processing, terminal, or otherwise no longer cancellable. 403 means the API key cannot access the task.
Example
Request
curl -X DELETE "https://api.tokenlab.sh/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-H "Authorization: Bearer sk-your-api-key"{
"id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"status": "failed",
"cancelled": true,
"cancellation_status": "cancelled",
"error": "Task cancelled before execution"
}{ "id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "status": "failed", "cancelled": true, "cancellation_status": "cancelled", "error": "Task cancelled before execution"}Authorization
BearerAuth API Key authentication. Create or manage API keys in Dashboard > API > API Keys.
In: header
Path Parameters
The async task ID returned by id / task_id, or embedded in poll_url
Response
application/json
application/json
application/json
application/json
application/json
application/json
application/json