---
title: "Cancel a batch"
method: POST
path: "/analyze/batches/{batch_id}/cancel"
tags: ["analyzeAsync > batches"]
---

# Cancel a batch

`POST /analyze/batches/{batch_id}/cancel`

Use this method to request cancellation for a batch with the `pending` or `processing` status.

When you invoke this method, the platform performs the following steps:
- Cancels the items in the `queued` status.
- Finishes the analysis for the items in the `processing` status.

The batch status changes to `canceling` immediately, and to `canceled` after every item reaches `ready`, `failed`, or `canceled`. You are not billed for canceled or failed items.

## Path parameters

- `batch_id` string, required

## Headers

- `x-api-key` string, required

## Response `202`

The platform accepted the cancellation request. Items already in the `processing` status continue until processing finishes. The batch status is `canceling` until every item reaches `ready`, `failed`, or `canceled`, then becomes `canceled`. The response shows the batch state at the time of the request. To confirm the batch is fully canceled, use the [`GET`](/v1.3/api-reference/analyze-videos/batch-analysis/retrieve-batch-status) method of the `/analyze/batches/{batch_id}` endpoint.

- AnalyzeBatchStatusResponse — A batch object that includes item counts for each item status.
  - `batch_id` string, required — The unique identifier of the batch. Use this value to retrieve the batch status or results.
  - `analysis_mode` 'general' | 'time_based_metadata', required — The analysis mode applied to every item in this batch.
  - `model_name` string, required — The model used for every item in this batch.
  - `status` 'pending' | 'processing' | 'canceling' | 'canceled' | 'completed' | 'expired', required — The status of a batch. For the meaning of each value, see the [Batch statuses](/v1.3/api-reference/analyze-videos/batch-analysis/the-batch-object#batch-statuses) section on the **The batch object** page.
  - `total_items` integer, required — The number of items submitted in the batch.
  - `created_at` string, date-time, required — The date and time, in the RFC 3339 format, when the batch was created.
  - `expires_at` string, date-time, required — The date and time, in the RFC 3339 format, when the batch expires (the `created_at` field value plus 24 hours). Unfinished items at expiration are canceled. Items that finished before then remain retrievable for 30 days after creation, when the batch and its results are deleted.
  - `completed_at` string, date-time — The date and time, in the RFC 3339 format, when the batch status became `completed`. Present only when the status is `completed`.
  - `canceled_at` string, date-time — The date and time, in the RFC 3339 format, when the batch status became `canceled`. Present only when the status is `canceled`.
  - `expired_at` string, date-time — The date and time, in the RFC 3339 format, when the batch status became `expired`. Present only when the status is `expired`.
  - `queued_items` integer, required — The number of items in the `queued` status.
  - `processing_items` integer, required — The number of items in the `processing` status.
  - `ready_items` integer, required — The number of items that completed successfully.
  - `failed_items` integer, required — The number of items that failed.
  - `canceled_items` integer, required — The number of items that were canceled, either because the batch was canceled while the item was in the `queued` status, or because the batch expired before the item finished processing.
  - `webhooks` AnalyzeTaskWebhookInfo[] — The delivery status of each webhook endpoint for the batch completion notification. Present only after the platform sends the webhook notifications. To register webhooks, see the [Webhooks](/v1.3/docs/advanced/webhooks) page.
    - `url` string, uri, required — The URL of the webhook endpoint that received the delivery.
    - `delivered` boolean, required — Indicates whether the platform successfully delivered the webhook.
    - `attempts` integer, required — The total number of delivery attempts for this URL.
    - `last_error` string — The error message from the last failed delivery attempt. This field appears only when `delivered` is `false`.

## Other responses

- `404` — Batch not found.
- `409` — The batch already reached a terminal state and cannot be canceled. The error code indicates which terminal state: `batch_completed` (status `completed`), `batch_canceled` (status `canceled`), or `batch_expired` (status `expired`).

---

[API](https://skmtc.net/twelvelabs/apis/twelvelabs-api.md) · [All operations](https://skmtc.net/twelvelabs/apis/twelvelabs-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/twelvelabs/twelvelabs-api/revisions/fd9d80e384a8/schema)
