---
title: "Rebalance dataset"
method: POST
path: "/api/{projectId}/v2/rebalance"
tags: ["Raw data"]
---

# Rebalance dataset

`POST /api/{projectId}/v2/rebalance`

## Request

- Base URL: `https://studio.edgeimpulse.com/v1`
- URL: `https://studio.edgeimpulse.com/v1/api/{projectId}/v2/rebalance`
- 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/v2/rebalance/post.ts> (a function with typed inputs; its response is checked against the schema)

Rebalances the dataset over training / testing categories. This resets the category for all data and splits it 80%/20% between training and testing. 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. To get the dataset ratio (as returned by the v1 endpoint), use getDatasetRatio. For richer, more powerful dataset splitting with configurable ratios, stratification, and grouping, use splitDataset (`/v1/api/{projectId}/split`).

## Path parameters

- `projectId` integer, required

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