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

# Cancel training job

> Cancels a training job that is in `PENDING` or `RUNNING` status.



## OpenAPI

````yaml PATCH /api/v1/training/{trainingJobKey}/cancel
openapi: 3.0.1
info:
  title: MathFi.ai API
  description: >
    The MathFi.ai REST API lets you build predictive AI applications
    programmatically.


    Upload labelled CSV data, train a model, and run predictions — all in
    minutes.

    The API supports binary and multi-class classification on tabular data using

    Cellular Balanced Learning (CBL), running entirely on commodity CPUs.


    ## Base URL


    ```

    https://api.mathfi.ai

    ```


    ## Authentication


    All `/api/v1/*` endpoints require a Bearer token obtained from `POST
    /api/login`.

    Tokens are valid for **1 hour**. Re-authenticate when you receive a `401`.


    ```

    Authorization: Bearer <token>

    ```
  contact:
    name: MathFi.ai
    url: https://mathfi.ai
    email: support@mathfi.ai
  license:
    name: Mathficast Limited
    url: https://mathfi.ai
  version: 1.0.0
servers:
  - url: https://api.mathfi.ai
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Authentication
    description: Obtain a Bearer token to authenticate API requests
  - name: Datasets
    description: Create and manage labelled training data in CSV format
  - name: Training
    description: Train models from datasets using a small set of hyperparameters
  - name: Models
    description: Inspect trained models and their performance metrics
  - name: Predictions
    description: Run inference on unseen data using trained models
paths:
  /api/v1/training/{trainingJobKey}/cancel:
    patch:
      tags:
        - Training
      summary: Cancel training job
      description: Cancels a training job that is in `PENDING` or `RUNNING` status.
      operationId: cancelTrainingJob
      parameters:
        - name: trainingJobKey
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Training job cancelled successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrainingJobProgressOutput'
              examples:
                Cancelled:
                  value:
                    status: CANCELLED
        '400':
          description: Invalid training job key
        '404':
          description: Training job not found
        '500':
          description: Internal server error
components:
  schemas:
    TrainingJobProgressOutput:
      required:
        - status
      type: object
      properties:
        status:
          $ref: '#/components/schemas/TrainingJobStatus'
        targetPerformance:
          type: number
          format: double
        jobs:
          type: array
          items:
            $ref: '#/components/schemas/TrainingJobProgressItem'
    TrainingJobStatus:
      type: string
      description: >
        Status of a training job:


        | Status | Description |

        |---|---|

        | `PENDING` | Queued, not yet started |

        | `RUNNING` | Algorithms competing in parallel |

        | `COMPLETED` | Target performance reached. Champion model created. |

        | `TIMED_OUT` | Did not reach target performance within the time limit |

        | `NOT_COMPLETED` | Stalled — no progress detected for a sustained
        period |

        | `CANCELLED` | Cancelled by the user |

        | `FAILED` | Failed due to an internal error |
      enum:
        - PENDING
        - RUNNING
        - COMPLETED
        - TIMED_OUT
        - NOT_COMPLETED
        - CANCELLED
        - FAILED
    TrainingJobProgressItem:
      type: object
      properties:
        trainingJobKey:
          type: string
          format: uuid
        algorithm:
          type: string
          example: BSEV02
        status:
          $ref: '#/components/schemas/TrainingJobStatus'
        latestPerformance:
          type: number
          format: double
        recentPerformances:
          type: array
          items:
            type: number
            format: double
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Obtain a token from `POST /api/login`. Valid for 1 hour.

````