> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.twelvelabs.io/v1.3/api-reference/analyze-videos/cancel-an-async-analysis-task/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.twelvelabs.io/_mcp/server. # Cancel an async analysis task POST https://api.twelvelabs.io/v1.3/analyze/tasks/{task_id}/cancel Use this method to cancel an asynchronous analysis task in your account. To cancel a task created as part of a batch, use the [`POST`](/v1.3/api-reference/analyze-videos/batch-analysis/cancel-batch) method of the `/analyze/batches/{batch_id}/cancel` endpoint. You can cancel a task with the `queued`, `pending`, or `processing` status. This action cannot be undone. Processing that has already started can continue briefly after cancellation. When you cancel a task, the platform can send an `analyze.task.canceled` webhook. Delivery is best-effort: a `200` response is not a delivery guarantee. When you receive the event, retrieve the task for its current state. Reference: https://docs.twelvelabs.io/api-reference/analyze-videos/cancel-an-async-analysis-task ## Authentication - `x-api-key` header (required) — Your API key. You can find your API key on the API Keys page. ## Request ### Path parameters - `task_id` (string, required) — The unique identifier of the analysis task you want to cancel. ## Response ### 200 The task is canceled. This response is also returned when the task was canceled by a previous request. - `task_id` (string, required) — The unique identifier of the analysis task. - `status` (enum, required) — The final status of the task. - Allowed values: `canceled` ## Errors ### 400 Bad Request Error The identifier of the task is invalid. - `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details. - `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface. ### 401 Unauthorized Error The API key is invalid or expired. - `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details. - `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface. ### 403 Forbidden Error Cancellation is not enabled for your account, or the API is unavailable in your region. The platform checks whether cancellation is enabled before it validates the task identifier. If cancellation is disabled for your account, the API returns `api_not_allowed` even when the task identifier is invalid. - `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details. - `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface. ### 404 Not Found Error The task does not exist or is not accessible with your API key. The API returns the same response in both cases. - `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details. - `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface. ### 409 Conflict Error The task cannot be canceled because it was created as part of a batch, has completed, or has failed. * `task_owned_by_batch`: The task was created as part of a batch. Use the [`POST`](/v1.3/api-reference/analyze-videos/batch-analysis/cancel-batch) method of the `/analyze/batches/{batch_id}/cancel` endpoint instead. * `task_completed`: The task has completed. * `task_failed`: The task has failed. - `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details. - `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface. ### 500 Internal Server Error An unexpected server error occurred. - `code` (string, required) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details. - `message` (string, required) — A human-readable string describing the error, intended to be suitable for display in a user interface. ## Examples **Response** ```json { "task_id": "64f8d2c7e4a1b37f8a9c5d12", "status": "canceled" } ``` **SDK Code** ```python analyzeAsync_tasks_cancel_example import requests url = "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel" headers = {"x-api-key": ""} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript analyzeAsync_tasks_cancel_example const url = 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel'; const options = {method: 'POST', headers: {'x-api-key': ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go analyzeAsync_tasks_cancel_example package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("x-api-key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby analyzeAsync_tasks_cancel_example require 'uri' require 'net/http' url = URI("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-api-key"] = '' response = http.request(request) puts response.read_body ``` ```java analyzeAsync_tasks_cancel_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel") .header("x-api-key", "") .asString(); ``` ```php analyzeAsync_tasks_cancel_example request('POST', 'https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel', [ 'headers' => [ 'x-api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp analyzeAsync_tasks_cancel_example using RestSharp; var client = new RestClient("https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel"); var request = new RestRequest(Method.POST); request.AddHeader("x-api-key", ""); IRestResponse response = client.Execute(request); ``` ```swift analyzeAsync_tasks_cancel_example import Foundation let headers = ["x-api-key": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/analyze/tasks/64f8d2c7e4a1b37f8a9c5d12/cancel")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```