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

# Cancel Fine-tuning Job

> Stop a running job at /v1/fine_tuning/jobs/{job_id}/cancel

## Overview

Cancels a queued or running job. Jobs already in a terminal state are unaffected.


## OpenAPI

````yaml POST /v1/fine_tuning/jobs/{job_id}/cancel
openapi: 3.1.0
info:
  title: Morph API
  version: 1.1.0
  description: >-
    The Morph public API at api.morphllm.com: OpenAI- and Anthropic-compatible
    inference (chat completions, messages), Fast Apply code editing, Compact
    context compression, Reflex classification, and fine-tuning. Model ids,
    prices, and context windows are served live at
    https://www.morphllm.com/api/models/json.
  contact:
    name: Morph
    url: https://morphllm.com
    email: info@morphllm.com
  license:
    name: Proprietary
    url: https://morphllm.com/privacy/tos
servers:
  - url: https://api.morphllm.com
    description: Production
security: []
tags:
  - name: chat
    description: >-
      OpenAI- and Anthropic-compatible chat inference, including Fast Apply and
      WarpGrep models.
  - name: compact
    description: Context compression for long agent conversations.
  - name: reflex
    description: 'Per-turn classifiers: realtime prediction and batches.'
  - name: fine-tuning
    description: Reflex fine-tuning job lifecycle.
  - name: models
    description: Model listing and management.
  - name: telemetry
    description: Usage reporting hooks.
paths:
  /v1/fine_tuning/jobs/{job_id}/cancel:
    post:
      tags:
        - fine-tuning
      summary: Cancel a job
      description: Stop a queued or running job. `status` becomes `cancelled`.
      operationId: cancelFineTuningJob
      parameters:
        - schema:
            type: string
            description: The `ftjob-` prefixed id of a queued or running job.
            example: ftjob-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d
          required: true
          description: Identifies the job to stop.
          name: job_id
          in: path
      responses:
        '200':
          description: The cancelled job.
          content:
            application/json:
              example:
                id: ftjob-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d
                object: fine_tuning.job
                model: guardrail
                created_at: 1780107000
                finished_at: 1780107148
                fine_tuned_model: null
                status: cancelled
                labels:
                  - billing
                  - bug
                trained_examples: 10
                hyperparameters:
                  n_epochs: 3
                  batch_size: auto
                  learning_rate_multiplier: auto
                result:
                  accuracy: 0.95
                  f1_score: 0.94
                error: null
                suffix: support-classifier
              schema:
                $ref: '#/components/schemas/FineTuningJob'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - bearerAuth: []
components:
  schemas:
    FineTuningJob:
      type: object
      properties:
        id:
          type: string
          description: Job id, prefixed `ftjob-`.
          example: ftjob-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d
        object:
          type: string
          description: Always `fine_tuning.job`.
          example: fine_tuning.job
        model:
          type: string
          description: >-
            What the job trained from: the reflex you warm-started from, or the
            from-scratch base for a cold start.
          example: guardrail
        created_at:
          type: integer
          description: Unix timestamp (seconds) at creation.
          example: 1780107000
        finished_at:
          type:
            - integer
            - 'null'
          description: Unix timestamp at a terminal state, else null.
          example: 1780107148
        fine_tuned_model:
          type:
            - string
            - 'null'
          description: >-
            Served model name once `succeeded` (the `suffix`, or the job id if
            none).
          example: support-classifier
        status:
          type: string
          enum:
            - queued
            - validating_files
            - running
            - succeeded
            - failed
            - cancelled
          description: >-
            `validating_files` is the data-prep phase for
            `generate`/`label_data` jobs.
          example: succeeded
        labels:
          type: array
          items:
            type: string
            description: One class the model predicts.
            example: billing
          description: The classes this job trained on.
          example:
            - billing
            - bug
        trained_examples:
          type: integer
          description: Number of training examples.
          example: 10
        hyperparameters:
          type: object
          properties:
            n_epochs:
              type: integer
              description: Passes over the training set.
              example: 3
            batch_size:
              type: string
              description: Batch size, always `auto`.
              example: auto
            learning_rate_multiplier:
              type: string
              description: Learning-rate multiplier, always `auto`.
              example: auto
          required:
            - n_epochs
            - batch_size
            - learning_rate_multiplier
          description: Fully managed.
          example:
            n_epochs: 3
            batch_size: auto
            learning_rate_multiplier: auto
        result:
          type:
            - object
            - 'null'
          properties:
            accuracy:
              type:
                - number
                - 'null'
              description: Held-out accuracy of the trained model.
              example: 0.95
            f1_score:
              type:
                - number
                - 'null'
              description: Held-out macro F1 of the trained model.
              example: 0.94
          required:
            - accuracy
            - f1_score
          description: >-
            `{accuracy, f1_score}` when `succeeded`, else null. Each value may
            be null.
          example:
            accuracy: 0.95
            f1_score: 0.94
        error:
          type:
            - object
            - 'null'
          properties:
            code:
              type:
                - string
                - 'null'
              description: Machine-readable failure code.
              example: invalid_training_data
            message:
              type:
                - string
                - 'null'
              description: Human-readable reason the training job failed.
              example: Every label needs at least 5 examples.
            param:
              type:
                - string
                - 'null'
              description: The request field that caused the failure.
              example: training_data
          required:
            - code
            - message
            - param
          description: '`{code, message, param}` when `failed`, else null.'
          example:
            code: invalid_training_data
            message: Every label needs at least 5 examples.
            param: training_data
        suffix:
          type:
            - string
            - 'null'
          description: The suffix supplied at creation, else null.
          example: support-classifier
      required:
        - id
        - object
        - model
        - created_at
        - finished_at
        - fine_tuned_model
        - status
        - labels
        - trained_examples
        - hyperparameters
        - result
        - error
        - suffix
      description: >-
        An OpenAI-compatible `fine_tuning.job`, with additive Reflex fields
        (`labels`, `trained_examples`, `result`, `suffix`).
      example:
        id: ftjob-a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d
        object: fine_tuning.job
        model: guardrail
        created_at: 1780107000
        finished_at: 1780107148
        fine_tuned_model: support-classifier
        status: succeeded
        labels:
          - billing
          - bug
        trained_examples: 10
        hyperparameters:
          n_epochs: 3
          batch_size: auto
          learning_rate_multiplier: auto
        result:
          accuracy: 0.95
          f1_score: 0.94
        error: null
        suffix: support-classifier
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: invalid_request_error
              description: Machine-readable error code.
            message:
              type: string
              example: The request body is missing the `model` field.
              description: Human-readable explanation of the failure.
          required:
            - code
            - message
      required:
        - error
      description: Standard error envelope returned by every non-2xx response.
      example:
        error:
          code: invalid_request_error
          message: The request body is missing the `model` field.
  responses:
    BadRequest:
      description: Malformed request — missing or invalid fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_request_error
              message: The request body is missing the `model` field.
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Invalid API key provided.
    NotFound:
      description: The requested resource does not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: not_found
              message: No fine-tuning job found with id ftjob-8f2k1.
    RateLimited:
      description: Rate limited — retry after the interval in the Retry-After header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: rate_limited
              message: Too many requests. Retry in 12 seconds.
    InternalError:
      description: Internal error — safe to retry with backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: internal_error
              message: Something went wrong on our side.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: opaque
      description: >-
        Morph API key, passed as `Authorization: Bearer sk-...`. Create keys at
        https://www.morphllm.com/dashboard/api-keys.

````