---
title: "Subsample Dataset"
method: POST
path: "/felix/data-editing/subsample"
tags: ["felix"]
---

# Subsample Dataset

`POST /felix/data-editing/subsample`

Create a subsample of the dataset using random or balanced sampling.

Creates a new dataset version with the subsampled data.

## Request body

- DataEditingSubsampleRequest — Request to subsample a dataset
  - `dataset_name` string, required — Dataset name
  - `version` string, nullable — Dataset version (latest if omitted)
  - `method` 'random' | 'balanced' | 'stratified' — Subsampling method
  - `n` integer, required — Target number of rows for the whole result, not per class. For balanced and stratified methods the sample reaches this total whenever the class sizes allow; when they do not, the response carries a warning and the per-class counts achieved.
  - `label_column` string, nullable — Column for balanced/stratified sampling
  - `seed` integer, nullable — Random seed for reproducibility
  - `new_dataset_name` string, nullable — Name for the new subsampled dataset (auto-generated if omitted)

## Response `200`

Successful Response

- DataEditingSubsampleResponse — Response after subsampling
  - `success` boolean, required
  - `dataset_name` string, required
  - `dataset_version` string, required
  - `new_dataset_name` string, required
  - `new_dataset_version` string, required
  - `original_rows` integer, required
  - `new_rows` integer, required
  - `method` string, required
  - `message` string, required
  - `rows_per_class` object, nullable — Rows actually drawn per class label, for the balanced and stratified methods. Null for random sampling, which has no class dimension.
  - `warning` string, nullable — Set when the result could not match the request — for example a class too small to supply its share. A subsample that under-delivers must say so here rather than returning success with an unchanged dataset.

## Other responses

- `422` — Validation Error

## Changes

- **2026-09-24** `1cffaad2a921` — 1 warning, 3 info
  - removed the optional property `detail` from the response with the `422` status
  - added the optional property `rows_per_class` to the response with the `200` status
  - added the optional property `warning` to the response with the `200` status
  - added the required property `error` to the response with the `422` status

[Change history](https://skmtc.dev/pioneer/apis/brain-api/changes/felix/data-editing/subsample/post.md)

---

[API](https://skmtc.dev/pioneer/apis/brain-api.md) · [All operations](https://skmtc.dev/pioneer/apis/brain-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pioneer/apis/brain-api/revisions/1cffaad2a921?raw)
