> ## Documentation Index
> Fetch the complete documentation index at: https://inference-docs.cerebras.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel batch

<Callout icon="lock" color="#b2b1b1ff" iconType="regular">
  This feature is in [Private Preview](/support/preview-releases). For access or more information, [contact us](https://www.cerebras.ai/contact) or reach out to your account representative.
</Callout>

Cancels a batch job that is currently queued or running. Completed requests remain saved in the results and can be retrieved through the retrieve batch endpoint.

## Path Parameters

<ParamField path="batch_id" type="string" required="true">
  The ID of the batch job to cancel.
</ParamField>

## Response

<ResponseField name="id" type="string">
  A unique identifier for the batch job.
</ResponseField>

<ResponseField name="object" type="string">
  The object type, which is always `batch`.
</ResponseField>

<ResponseField name="endpoint" type="string">
  The API endpoint used for batch processing.
</ResponseField>

<ResponseField name="errors" type="object | null">
  Information about any errors that occurred during batch processing.
</ResponseField>

<ResponseField name="input_file_id" type="string">
  The ID of the input file containing batch requests.
</ResponseField>

<ResponseField name="completion_window" type="string">
  The time window for batch completion. Always `24h`.
</ResponseField>

<ResponseField name="status" type="string">
  The status of the batch job. Will be `cancelling` immediately after calling cancel. Once cancellation is complete (up to 10 minutes), the status changes to `cancelled`.
</ResponseField>

<ResponseField name="output_file_id" type="string | null">
  The ID of the file containing batch results with any completed requests.
</ResponseField>

<ResponseField name="error_file_id" type="string | null">
  The ID of the file containing errors (if any errors occurred).
</ResponseField>

<ResponseField name="created_at" type="integer">
  The Unix timestamp (in seconds) of when the batch job was created.
</ResponseField>

<ResponseField name="in_progress_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job started processing.
</ResponseField>

<ResponseField name="expires_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job will expire.
</ResponseField>

<ResponseField name="finalizing_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job started finalizing.
</ResponseField>

<ResponseField name="completed_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job completed.
</ResponseField>

<ResponseField name="failed_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job failed.
</ResponseField>

<ResponseField name="expired_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job expired.
</ResponseField>

<ResponseField name="cancelling_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job started cancelling.
</ResponseField>

<ResponseField name="cancelled_at" type="integer | null">
  The Unix timestamp (in seconds) of when the batch job was cancelled.
</ResponseField>

<ResponseField name="request_counts" type="object | null">
  Statistics about the requests in the batch (if available).
</ResponseField>

<ResponseField name="metadata" type="object | null">
  Custom metadata associated with the batch job.
</ResponseField>

<Note>
  When you cancel an in-progress batch, it will be in `cancelling` status for up to 10 minutes before changing to `cancelled`, where it will have partial results (if any) available in the output file.
</Note>

<RequestExample>
  ```python Python theme={null}
  from cerebras.cloud.sdk import Cerebras
  import os

  client = Cerebras(
      api_key=os.environ.get("CEREBRAS_API_KEY"),
  )

  batch = client.batches.cancel("batch_abc123")

  print(batch)
  ```

  ```javascript Node.js theme={null}
  import Cerebras from '@cerebras/cerebras_cloud_sdk';

  const client = new Cerebras({
    apiKey: process.env['CEREBRAS_API_KEY'],
  });

  async function main() {
    const batch = await client.batches.cancel("batch_abc123");

    console.log(batch);
  }

  main();
  ```

  ```bash cURL theme={null}
  curl --location --request DELETE 'https://api.cerebras.ai/v1/batches/batch_abc123' \
  --header "Authorization: Bearer ${CEREBRAS_API_KEY}"
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
      "id": "batch_abc123",
      "object": "batch",
      "endpoint": "/v1/chat/completions",
      "errors": null,
      "input_file_id": "file-abc123",
      "completion_window": "24h",
      "status": "calling",
      "output_file_id": null,
      "error_file_id": null,
      "created_at": 1765492780,
      "in_progress_at": null,
      "expires_at": null,
      "finalizing_at": null,
      "completed_at": 1765493188,
      "failed_at": null,
      "expired_at": null,
      "cancelling_at": 1765492797,
      "cancelled_at":null,
      "request_counts": null,
      "metadata": null
  }
  ```
</ResponseExample>
