---
title: "Split dataset"
method: POST
path: "/api/{projectId}/split"
tags: ["Raw data"]
---

# Split dataset

`POST /api/{projectId}/split`

## Request

- Base URL: `https://studio.edgeimpulse.com/v1`
- URL: `https://studio.edgeimpulse.com/v1/api/{projectId}/split`
- Auth: one of:
  - API key in header `x-api-key`
  - API key in cookie `jwt`
  - API key in header `x-jwt-token`
  - OAuth 2
    - Authorization code: `/v1/oauth/authorize`
    - Client credentials
    - Implicit: `/v1/oauth/authorize`
    - Password
    - Token URL: `/v1/oauth/token`
- TypeScript: <https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/docs/api/:projectId/split/post.ts> (a function with typed inputs; its response is checked against the schema)

Performs a deterministic, in-place split of the project's dataset into "training", "testing", and optional "validation" sets. Split balancing can use the label, one or more metadata keys, or both as a composite grouping signal. Related samples can also be kept together across splits by metadata key. This is a deterministic process based on the hash of the name of the data. Returns immediately on small datasets, or starts a job on larger datasets.
For example:
    { "trainingSplitRatio": 0.8, "testingSplitRatio": 0.1, "validationSplitRatio": 0.1, "excludeDisabledSamples": false, "stratifyBy": { "label": true, "metadataKeys": ["site", "scanner"] }, "keepTogetherMetadataKeys": ["capture_group"] }
    With these options, label/site/scanner are used to balance the split, while samples sharing the same capture_group value stay in the same split bucket.

## Path parameters

- `projectId` integer, required

## Request body

- DatasetSplitOptions
  - `trainingSplitRatio` number, required: Proportion of the dataset to use for training.
  - `testingSplitRatio` number, required: Proportion of the dataset to use for testing.
  - `validationSplitRatio` number: Proportion of the dataset to use for validation.
  - `excludeDisabledSamples` boolean: Whether to exclude samples that are marked as disabled.
  - `stratifyBy` object: Optional balancing targets for the split.
    - `label` boolean: Whether to stratify by label.
    - `metadataKeys` string[]: Metadata keys to use as balancing targets. If more than one is selected, they are combined into composite assignment buckets.
  - `keepTogetherMetadataKeys` string[]: List of metadata keys whose matching values must stay together in a single split. This is useful for leakage prevention across train, validation, and test.

## Response `200`

OK

- union
  - GenericApiResponse
    - `success` boolean, required: Whether the operation succeeded
    - `error` string: Optional error description (set if 'success' was false)
  - StartJobResponse
    - `success` boolean, required: Whether the operation succeeded
    - `error` string: Optional error description (set if 'success' was false)
    - `id` integer, required: Job identifier. Status updates will include this identifier.

---

[API](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api.md) - [All operations](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/llms.txt) - [OpenAPI document](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/revisions/e2a976d38427?raw)
