---
title: "Start sampling"
method: POST
path: "/api/{projectId}/device/{deviceId}/start-sampling"
tags: ["Devices"]
---

# Start sampling

`POST /api/{projectId}/device/{deviceId}/start-sampling`

## Request

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

Start sampling on a device. This function returns immediately. Updates are streamed through the websocket API.

## Path parameters

- `projectId` integer, required
- `deviceId` string, required

## Request body

- StartSamplingRequest
  - `label` string, required: Label to be used during sampling.
  - `lengthMs` integer, required: Requested length of the sample (in ms).
  - `category` 'training' | 'testing' | 'validation' | 'post-processing', required
  - `intervalMs` number, required: Interval between samples (can be calculated like `1/hz * 1000`)
  - `sensor` string: The sensor to sample from.
  - `labelColor` string: Text color of label displayed on supported clients. Value can be any supported CSS color value
  - `collectedSampleCount` number: A hint to supported clients to show the number of samples currently collected
  - `targetSampleCount` number: A hint to supported clients to show the desired number of samples to be collected

## Response `200`

OK

- StartSamplingResponse
  - `success` boolean, required: Whether the operation succeeded
  - `error` string: Optional error description (set if 'success' was false)
  - `id` integer, required

---

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