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

# Cancel batch

> Interactive playground for POST /v1/batches/{batch_id}/cancel.

Request cancellation while a batch is `in_progress` or `validating`. Terminal batches return `409`.

Poll status on [Retrieve batch](/api-reference/retrieve-batch). Full reference: [Batches API](/docs/batch/objects).


## OpenAPI

````yaml api-reference/openapi/batch.openapi.json POST /v1/batches/{batch_id}/cancel
openapi: 3.1.0
info:
  title: ZeroGPU Batch & Files API
  version: '1.0'
  description: >-
    JSONL file storage (`/v1/files`) and asynchronous batch inference
    (`/v1/batches`). Wire-compatible with OpenAI's files and batch APIs. Auth:
    `x-api-key` on every request; `x-project-id` is optional.
servers:
  - url: https://api.zerogpu.ai
    description: Production
security:
  - ApiKey: []
paths:
  /v1/batches/{batch_id}/cancel:
    post:
      tags:
        - Batches
      summary: Cancel a batch
      description: Request cancellation while `status` is `in_progress` or `validating`.
      operationId: cancelBatch
      parameters:
        - name: x-project-id
          in: header
          required: false
          schema:
            type: string
          description: >-
            Optional project identifier. Scopes the request to a specific
            project when provided.
        - name: batch_id
          in: path
          required: true
          schema:
            type: string
          example: batch_01HZX...
      responses:
        '200':
          description: Batch cancellation requested
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Batch'
        '404':
          description: Batch not found
        '409':
          description: Batch already terminal
components:
  schemas:
    Batch:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - batch
        endpoint:
          type: string
        status:
          type: string
          enum:
            - validating
            - in_progress
            - finalizing
            - completed
            - failed
            - expired
            - cancelling
            - cancelled
        input_file_id:
          type: string
        output_file_id:
          type: string
          nullable: true
        error_file_id:
          type: string
          nullable: true
        completion_window:
          type: string
        created_at:
          type: integer
        expires_at:
          type: integer
        request_counts:
          type: object
          properties:
            total:
              type: integer
            completed:
              type: integer
            failed:
              type: integer
        metadata:
          type: object
          additionalProperties: true
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: x-api-key

````