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

# Cancel Job

> Cancel a submitted or running job.

Use this tool to stop work the caller no longer wants, for example a run
submitted against the wrong device or with the wrong shot count. Cancelling
takes effect immediately from the caller's point of view; the worker
container is stopped in the background.

When to Use:
    - Call this when the user asks to stop, abort, or kill a job.
    - Call this before resubmitting a corrected job, so the superseded one
      stops consuming quota.

Constraints:
    - Cancelling an already finished job is a no-op that reports the existing
      terminal status rather than an error.
    - Cancellation is not reversible. Use ``restart_job`` to run the same job
      again afterwards.

Notes:
    - This is a billable-work control, so confirm the job identity with the
      user before calling it when more than one job is in flight.

Args:
    job_id: Job identifier returned by a prior MCP submission or listing
        tool.
    user: Authenticated user resolved from the API key.
    db: Active database session.

Returns:
    The job identifier, its status after the call, and a summary of what
    changed.

Raises:
    HTTPException: Raised with ``404`` when the job is not available to the
        caller.



## OpenAPI

````yaml https://api.haiqu.ai/openapi.json post /ai/jobs/{job_id}/cancel
openapi: 3.1.0
info:
  title: Haiqu API
  summary: Haiqu RESTful API service.
  description: Cloud service providing the access to Haiqu cloud runtime
  contact:
    name: Haiqu Inc.
    url: https://haiqu.ai/
    email: info@haiqu.ai
  version: 1.5.0
servers: []
security: []
paths:
  /ai/jobs/{job_id}/cancel:
    post:
      summary: Cancel Job
      description: >-
        Cancel a submitted or running job.


        Use this tool to stop work the caller no longer wants, for example a run

        submitted against the wrong device or with the wrong shot count.
        Cancelling

        takes effect immediately from the caller's point of view; the worker

        container is stopped in the background.


        When to Use:
            - Call this when the user asks to stop, abort, or kill a job.
            - Call this before resubmitting a corrected job, so the superseded one
              stops consuming quota.

        Constraints:
            - Cancelling an already finished job is a no-op that reports the existing
              terminal status rather than an error.
            - Cancellation is not reversible. Use ``restart_job`` to run the same job
              again afterwards.

        Notes:
            - This is a billable-work control, so confirm the job identity with the
              user before calling it when more than one job is in flight.

        Args:
            job_id: Job identifier returned by a prior MCP submission or listing
                tool.
            user: Authenticated user resolved from the API key.
            db: Active database session.

        Returns:
            The job identifier, its status after the call, and a summary of what
            changed.

        Raises:
            HTTPException: Raised with ``404`` when the job is not available to the
                caller.
      operationId: cancel_job
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
            title: Job Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContextJobActionModel'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyQuery: []
        - APIKeyHeader: []
components:
  schemas:
    ContextJobActionModel:
      properties:
        job_id:
          type: string
          title: Job Id
        status:
          type: string
          title: Status
        context:
          type: string
          title: Context
      type: object
      required:
        - job_id
        - status
        - context
      title: ContextJobActionModel
      description: >-
        Represent the outcome of a job lifecycle action such as cancel or
        restart.


        Attributes:
            job_id: Identifier of the affected job.
            status: Job status after the action was applied.
            context: Summary of what changed and the recommended next step.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyQuery:
      type: apiKey
      in: query
      name: HAIQU_API_KEY
    APIKeyHeader:
      type: apiKey
      in: header
      name: authorization

````