> ## 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.

# Create dataset

> Creates a new empty dataset. Dataset creation is a two-step process:

**Step 1 — Create the dataset (this endpoint)**

Returns a `datasetUploadInfo` object containing a signed `uploadUrl` and required `extraHeaders`.

**Step 2 — Upload your CSV via the signed URL**

PUT your labelled CSV file directly to the `uploadUrl`. The `extraHeaders` field contains
additional headers required for the request (e.g. `X-Goog-Content-Length-Range`).
The signed URL is valid for **1 hour**. Maximum file size: **500 MB**.

```bash
curl -X PUT \
  -H "Content-Type: text/csv" \
  -H "X-Goog-Content-Length-Range: 10,534773760" \
  --data-binary @/path/to/dataset.csv \
  "{uploadUrl}"
```

After the PUT completes, the dataset moves to `PROCESSING` automatically.
Poll `GET /api/v1/datasets/{datasetKey}` until status is `COMPLETED`.




## OpenAPI

````yaml POST /api/v1/datasets
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/datasets:
    post:
      tags:
        - Datasets
      summary: Create dataset
      description: >
        Creates a new empty dataset. Dataset creation is a two-step process:


        **Step 1 — Create the dataset (this endpoint)**


        Returns a `datasetUploadInfo` object containing a signed `uploadUrl` and
        required `extraHeaders`.


        **Step 2 — Upload your CSV via the signed URL**


        PUT your labelled CSV file directly to the `uploadUrl`. The
        `extraHeaders` field contains

        additional headers required for the request (e.g.
        `X-Goog-Content-Length-Range`).

        The signed URL is valid for **1 hour**. Maximum file size: **500 MB**.


        ```bash

        curl -X PUT \
          -H "Content-Type: text/csv" \
          -H "X-Goog-Content-Length-Range: 10,534773760" \
          --data-binary @/path/to/dataset.csv \
          "{uploadUrl}"
        ```


        After the PUT completes, the dataset moves to `PROCESSING`
        automatically.

        Poll `GET /api/v1/datasets/{datasetKey}` until status is `COMPLETED`.
      operationId: createDataset
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DatasetCreationRequest'
            examples:
              Create dataset:
                summary: Create a dataset with 10 buckets
                value:
                  datasetName: Example Dataset
                  numberOfBuckets: 10
      responses:
        '201':
          description: Dataset created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatasetCreationOutput'
              examples:
                Dataset created:
                  value:
                    datasetKey: bbb4d0fb-7287-44b0-860d-d81bea692648
                    numberOfBuckets: 10
                    status: PENDING
                    datasetCreationProgressUrl: >-
                      https://api.mathfi.ai/api/v1/datasets/bbb4d0fb-7287-44b0-860d-d81bea692648
                    datasetUploadInfo:
                      uploadUrl: https://storage.googleapis.com/...
                      extraHeaders: X-Goog-Content-Length-Range:10,534773760
        '400':
          description: Invalid dataset name or numberOfBuckets
        '500':
          description: Internal server error
components:
  schemas:
    DatasetCreationRequest:
      required:
        - datasetName
      type: object
      properties:
        datasetName:
          type: string
          minLength: 3
          maxLength: 30
          description: Unique name for the dataset
          example: My Training Dataset
        description:
          type: string
          minLength: 3
          maxLength: 150
          nullable: true
          description: Optional plain-text description
        numberOfBuckets:
          type: integer
          minimum: 4
          maximum: 1000
          description: >
            Controls data granularity for Cellular Balanced Learning.

            Start with 10–20. Higher values capture more detail but require more
            training time.

            See the [Hyperparameter Tuning guide](/guides/hyperparameter-tuning)
            for guidance.
          example: 10
    DatasetCreationOutput:
      required:
        - datasetKey
        - status
        - datasetCreationProgressUrl
        - datasetUploadInfo
      type: object
      properties:
        datasetKey:
          type: string
          format: uuid
          example: 2b0a9a83-d549-4f25-b7ed-8174e0c955cd
        numberOfBuckets:
          type: integer
        status:
          $ref: '#/components/schemas/DatasetCreationStatus'
        datasetCreationProgressUrl:
          type: string
          description: URL to poll for dataset processing status
        datasetUploadInfo:
          $ref: '#/components/schemas/UploadMetadata'
    DatasetCreationStatus:
      type: string
      description: |
        Processing status of a dataset:

        | Status | Description |
        |---|---|
        | `PENDING` | Created, awaiting data upload |
        | `PROCESSING` | Data uploaded, preparation in progress |
        | `COMPLETED` | Ready for training |
        | `FAILED` | Processing failed |
      enum:
        - PENDING
        - PROCESSING
        - COMPLETED
        - FAILED
    UploadMetadata:
      description: >
        Present when the dataset was created with a large-file upload path.

        Use the `uploadUrl` to PUT your CSV file directly for files over 32 MB
        (up to 500 MB).
      type: object
      properties:
        uploadUrl:
          type: string
          description: Signed GCS URL for direct CSV upload via PUT. Valid for 1 hour.
        extraHeaders:
          type: string
          description: >
            Additional headers required for the PUT request, formatted as

            `headerName1:headerValue1;headerName2:headerValue2`.

            Currently includes `X-Goog-Content-Length-Range` to enforce the file
            size limit.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Obtain a token from `POST /api/login`. Valid for 1 hour.

````