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

# Cancel Job

> Cancel a running job.

Stops a running job and returns its final state snapshot.

Use cancellation when conditions or stream context change and the current run is no longer useful.

## Common Uses

* Stop stale jobs after client disconnects.
* Enforce custom business-time windows.
* Abort runs that are spending budget without value.

## Workflow

1. Find active jobs with [List Jobs](/api-reference/jobs-list).
2. Confirm details with [Get Job Details](/api-reference/jobs-get).
3. Issue `DELETE /jobs/{job_id}`.

## Notes

* Cancellation ends future monitoring activity for that job.
* Use [Get Job Details](/api-reference/jobs-get) after canceling if you need to verify terminal state in a separate call.

## Related

* Lifecycle overview: [Job Lifecycle](/core-concepts/job-lifecycle)
* Troubleshooting: [Debugging Playbook](/guides/debugging)


## OpenAPI

````yaml DELETE /jobs/{job_id}
openapi: 3.1.0
info:
  title: Trio API
  description: Reality as an API - Monitor YouTube Live streams with vision models
  version: 1.0.0
servers:
  - url: https://trio.machinefi.com/api
security: []
paths:
  /jobs/{job_id}:
    delete:
      tags:
        - Jobs
      summary: Cancel Job
      description: Cancel a running job.
      operationId: cancel_job_jobs__job_id__delete
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Job Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelJobResponse'
        '400':
          description: Job already stopped or invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/plain:
              example: Invalid HTTP request received.
        '404':
          description: Job not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CancelJobResponse:
      properties:
        job_id:
          type: string
          format: uuid
          title: Job Id
        status:
          $ref: '#/components/schemas/JobStatus'
        message:
          type: string
          title: Message
        final_stats:
          additionalProperties: true
          type: object
          title: Final Stats
          default: {}
      type: object
      required:
        - job_id
        - status
        - message
      title: CancelJobResponse
      description: Response for canceling a job.
    ErrorResponse:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      type: object
      required:
        - error
      title: ErrorResponse
      description: Wrapper for error responses.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    JobStatus:
      type: string
      enum:
        - pending
        - running
        - stopped
        - completed
        - failed
      title: JobStatus
      description: Job status enum.
    ErrorDetail:
      properties:
        code:
          type: string
          title: Code
        message:
          type: string
          title: Message
        remediation:
          type: string
          title: Remediation
      type: object
      required:
        - code
        - message
        - remediation
      title: ErrorDetail
      description: Standardized error response for better DX.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````