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

# Cancel run

> Cancel a running or pending generation job



## OpenAPI

````yaml POST /api/dataframer/runs/{run_id}/cancel/
openapi: 3.0.0
info:
  title: DataFramer API
  version: 0.1.0
  description: ''
  termsOfService: https://www.aimon.ai/docs/privacy-policy.pdf
  contact:
    name: DataFramer Support
    email: info@dataframer.ai
  license:
    name: Proprietary
  x-logo:
    url: https://dataframer.ai/logo.png
    altText: DataFramer AI
  x-stainless:
    package-name: aimon-dataframer
    namespace:
      - aimon
      - dataframer
servers:
  - url: https://df-api.dataframer.ai
    description: Production server
security:
  - BearerAuth: []
externalDocs:
  description: Complete API Guide
  url: https://docs.dataframer.ai/dataframer
paths:
  /api/dataframer/runs/{run_id}/cancel/:
    parameters:
      - name: run_id
        in: path
        required: true
        description: Unique identifier of the run to cancel
        schema:
          type: string
    post:
      summary: Cancel run
      description: >-
        Cancel a running generation job. Only PENDING or PROCESSING runs can be
        canceled.
      operationId: api_dataframer_runs_cancel
      responses:
        '204':
          description: >-
            Run canceled successfully. If any samples were already completed,
            they are preserved.
        '400':
          description: Bad Request - Job cannot be canceled (already completed/failed)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
              examples:
                not_cancelable:
                  value:
                    error: >-
                      Cannot cancel job. Only PROCESSING or PENDING jobs can be
                      canceled.
        '401':
          description: Unauthorized
        '404':
          description: Run not found
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from dataframer import Dataframer

            client = Dataframer(
                api_key=os.environ.get("DATAFRAMER_API_KEY"),  # This is the default and can be omitted
            )
            client.dataframer.runs.cancel(
                "run_id",
            )
        - lang: cURL
          source: >-
            curl
            https://df-api.dataframer.ai/api/dataframer/runs/$RUN_ID/cancel/ \
                -X POST \
                -H "Authorization: Bearer $DATAFRAMER_API_KEY"
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'API Key authentication. Format: "Bearer YOUR_API_KEY"'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.