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

# Cancel a job

> Cancel a queued or in-flight async job (e.g., inference generation). Use this to
stop a doomed batch instead of waiting for every unit to fail individually.

Behaviour:
- A queued or delayed job is removed from the queue and will never run.
- An in-flight job receives a cooperative-cancellation signal: the worker
  observes it at its next checkpoint and stops dispatching further work
  (for inference generation, this means no further sessions are created).
  Work already in progress when the signal is observed is NOT rolled back —
  sessions that have already been created remain. Subsequent reads of
  `GET /jobs/{jobId}/status` will surface the distinct `cancelled` state.
- The in-flight guarantee applies only to handlers that implement the
  cooperative-cancellation checkpoint. Today that is inference generation;
  other job types (e.g. trace imports) do not yet observe the cancel signal
  and will run to completion even though the cancel call returns 200 and the
  status read flips to `cancelled`. Trace imports are short, so this is a
  deliberate Phase-1 trade-off rather than a correctness issue.

Tenant isolation: only users in the dispatching user's organization may
cancel a job. Cross-tenant cancels return `404` (not `403`) to avoid leaking
the existence of jobs in other organizations — matching `GET /jobs/{jobId}/status`.




## OpenAPI

````yaml https://api.galtea.ai/openapi.json post /jobs/{jobId}/cancel
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /jobs/{jobId}/cancel:
    post:
      tags:
        - jobs
      summary: Cancel a job
      description: >
        Cancel a queued or in-flight async job (e.g., inference generation). Use
        this to

        stop a doomed batch instead of waiting for every unit to fail
        individually.


        Behaviour:

        - A queued or delayed job is removed from the queue and will never run.

        - An in-flight job receives a cooperative-cancellation signal: the
        worker
          observes it at its next checkpoint and stops dispatching further work
          (for inference generation, this means no further sessions are created).
          Work already in progress when the signal is observed is NOT rolled back —
          sessions that have already been created remain. Subsequent reads of
          `GET /jobs/{jobId}/status` will surface the distinct `cancelled` state.
        - The in-flight guarantee applies only to handlers that implement the
          cooperative-cancellation checkpoint. Today that is inference generation;
          other job types (e.g. trace imports) do not yet observe the cancel signal
          and will run to completion even though the cancel call returns 200 and the
          status read flips to `cancelled`. Trace imports are short, so this is a
          deliberate Phase-1 trade-off rather than a correctness issue.

        Tenant isolation: only users in the dispatching user's organization may

        cancel a job. Cross-tenant cancels return `404` (not `403`) to avoid
        leaking

        the existence of jobs in other organizations — matching `GET
        /jobs/{jobId}/status`.
      operationId: cancelJob
      parameters:
        - name: jobId
          in: path
          required: true
          schema:
            type: string
          description: The ID of the job to cancel
      responses:
        '200':
          description: >-
            Cancellation accepted. Either the job was queued and has been
            removed, or an in-flight job has been signalled to stop. Repeated
            cancels are idempotent and also return 200.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: The job ID
                  state:
                    type: string
                    description: Terminal state surfaced to the caller.
                    enum:
                      - cancelled
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            Job not found, or the job is owned by a different organization
            (intentionally indistinguishable to avoid leaking existence).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            The job is already in a terminal state (`completed` or `failed`) and
            cannot be cancelled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````