TokenLab

Async Jobs

Cancel Task

Cancel a queued async task when its model supports cancellation

DELETE
/v1/tasks/{id}

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-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. A cancelled task is not charged. Status remains queryable while its public task record is retained.

To cancel a task created through the Volc-compatible Seedance endpoint, see Cancel Task (Volc Compatible).

Path Parameters

idstringpathrequired

The async task ID returned by the create request or embedded in poll_url.

Response

idstring

Canonical async task identifier.

task_idstring

Async task identifier alias.

poll_urlstring

Status URL for the task. It remains valid after cancellation. Poll GET /v1/tasks/{id} with id.

statusstring

Task status. A successfully cancelled task is returned as failed with cancelled: true for compatibility with existing status values.

cancelledboolean

true when the task was cancelled before execution.

cancellation_statusstring

Cancellation marker. The value is cancelled when cancellation succeeds.

errorstring

Cancellation reason or task failure message.

Error Behavior

HTTPCodeMeaning
400missing_task_id, invalid_task_idThe task ID is missing or not a valid task ID
400unsupported_task_cancelThe task type or model does not support cancellation
403task_not_ownedThe task does not belong to the workspace of this API key
404async_task_not_foundThe task has expired or is not available
409task_not_cancellableThe task is already processing, finished, or otherwise no longer cancellable. current_status gives its state
503async_task_owner_unavailableThe task cannot be read right now. Retry

Example

Request

cURL
curl -X DELETE "https://api.tokenlab.sh/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
  -H "Authorization: Bearer sk-your-api-key"

Response

Response
{
  "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
AuthorizationBearer <token>

API Key authentication. Create or manage API keys in Dashboard > API > API Keys.

In: header

Path Parameters

id*string

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