---
title: "Classify sample for the given set of variants"
method: POST
path: "/api/{projectId}/classify/v2/{sampleId}/variants"
tags: ["Classify"]
---

# Classify sample for the given set of variants

`POST /api/{projectId}/classify/v2/{sampleId}/variants`

## Request

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

Classify a complete file against the current impulse, for all given variants.
Depending on the size of your file and whether the sample is resampled, you may get a job ID in
the response.

## Path parameters

- `projectId` integer, required
- `sampleId` integer, required

## Query parameters

- `includeDebugInfo` boolean
- `variants` string, required
- `impulseId` integer
- `truncateStructuredLabels` boolean

## Response `200`

OK

- union
  - ClassifySampleResponseMultipleVariants
    - `success` boolean, required: Whether the operation succeeded
    - `error` string: Optional error description (set if 'success' was false)
    - `results` ClassifySampleResponseVariantResults[]
      - `variant` 'int8' | 'float32' | 'akida', required
      - `classifications` ClassifySampleResponseClassification[], required
        - `learnBlock` ImpulseLearnBlock, required
          - `id` integer, required: Identifier for this block. Make sure to up this number when creating a new block via `getNewBlockId`, and don't re-use identifiers. If the block hasn't changed, keep the ID as-is. ID must be unique across the project and greather than zero (>0).
          - `type` 'anomaly' | 'anomaly-gmm' | 'keras' | 'keras-transfer-image' | 'keras-transfer-kws' | 'keras-object-detection' | 'keras-regression' | 'keras-akida' | 'keras-akida-transfer-image' | 'keras-akida-object-detection' | 'keras-visual-anomaly' | 'keras-freeform' | 'keras-self-contained-freeform' | 'keras-anomaly' | 'vlm', required: The type of learning block (anomaly, keras, keras-transfer-image, ...). Each behaves differently.
          - `name` string, required: Block name, will be used in menus. If a block has a baseBlockId, this field is ignored and the base block's name is used instead.
          - `dsp` integer[], required: DSP dependencies, identified by DSP block ID
          - `title` string, required: Block title, used in the impulse UI
          - `createdBy` string: The system component that created the block version (createImpulse | clone | tuner). Cannot be set via API.
          - `createdAt` string, date-time: The datetime that the block version was created. Cannot be set via API.
          - `trainingProcessor` 'cpu' | 'gpu': Training processor selection for an impulse.
        - `result` object[], required: Classification result, one item per window.
        - `anomalyResult` AnomalyResult[]: Anomaly scores and computed metrics for visual anomaly detection, one item per window.
          - `boxes` BoundingBoxWithScore[]: For visual anomaly detection. An array of bounding box objects, (x, y, width, height, score, label), one per detection in the image. Filtered by the minimum confidence rating of the learn block.
            - `label` string, required
            - `x` number, required
            - `y` number, required
            - `width` number, required
            - `height` number, required
            - `score` number, required
          - `scores` array[]: 2D array of shape (n, n) with raw anomaly scores for visual anomaly detection, where n can be calculated as ((1/8 of image input size)/2 - 1). The scores corresponds to each grid cell in the image's spatial matrix.
            - number[]
          - `meanScore` number: Mean value of the scores.
          - `maxScore` number: Maximum value of the scores.
        - `structuredResult` StructuredClassifyResult[]: Results of inferencing that returns structured data, such as object detection
          - `boxes` array[], required: For object detection. An array of bounding box arrays, (x, y, width, height), one per detection in the image.
            - number[]
          - `labels` string[]: For object detection. An array of labels, one per detection in the image.
          - `scores` number[], required: For object detection. An array of probability scores, one per detection in the image.
          - `mAP` number, required: For object detection. A score that indicates accuracy compared to the ground truth, if available.
          - `f1` number, required: For FOMO. A score that combines the precision and recall of a classifier into a single metric, if available.
          - `precision` number, required: A measure of how many of the positive predictions made are correct (true positives).
          - `recall` number, required: A measure of how many of the positive cases the classifier correctly predicted, over all the positive cases.
          - `debugInfoJson` string: Debug info in JSON format
        - `minimumConfidenceRating` number, required: DEPRECATED, see "thresholds" instead. The minimum confidence rating for this block. For regression, this is the absolute error (which can be larger than 1).
        - `details` ClassifySampleResponseClassificationDetails[]: Structured outputs and computed metrics for some model types (e.g. object detection), one item per window.
          - `boxes` array[]: Bounding boxes predicted by localization model
            - number[]
          - `labels` number[]: Labels predicted by localization model
          - `scores` number[]: Scores predicted by localization model
          - `mAP` number: For object detection, the COCO mAP computed for the predictions on this image
          - `f1` number: For FOMO, the F1 score computed for the predictions on this image
        - `objectDetectionLastLayer` 'mobilenet-ssd' | 'fomo' | 'yolov2-akida' | 'yolov5' | 'yolov5v5-drpai' | 'yolox' | 'yolov7' | 'yolo-pro' | 'tao-retinanet' | 'tao-ssd' | 'tao-yolov3' | 'tao-yolov4' | 'yolov11' | 'yolov11-abs' | 'paddleocr-detector' | 'qc-face-det-lite' | 'qc-yolox'
        - `expectedLabels` StructuredLabel[], required: An array with an expected label per window.
          - `startIndex` integer, required: Start index of the label (e.g. 0)
          - `endIndex` integer, required: End index of the label (e.g. 3). This value is inclusive, so { startIndex: 0, endIndex: 3 } covers 0, 1, 2, 3.
          - `label` string, required: The label for this section.
          - `labelMap` SampleLabelMapLabels
            - `type` 'key-values', required
            - `labels` object, required
        - `expectedAnomalyOutcome` StructuredLabel[]: An array with the expected anomaly outcome for each window — either “anomaly” or “no anomaly”. The outcome is determined by which labels are marked as anomalous in the project setup, or by the sample label if no such configuration is defined.
          - `startIndex` integer, required: Start index of the label (e.g. 0)
          - `endIndex` integer, required: End index of the label (e.g. 3). This value is inclusive, so { startIndex: 0, endIndex: 3 } covers 0, 1, 2, 3.
          - `label` string, required: The label for this section.
          - `labelMap` SampleLabelMapLabels
            - `type` 'key-values', required
            - `labels` object, required
        - `thresholds` BlockThreshold[], required: List of configurable thresholds for this block.
          - `key` string, required: Identifier to reference the threshold. You'll need to refer to the threshold by this key when you set the threshold).
          - `description` string, required: User-friendly description of the threshold.
          - `helpText` string, required: Additional help text (shown in the UI under a "?" icon)
          - `suggestedValue` number: If the threshold has a suggested value, e.g. a max. absolute error for regression projects; or the min. anomaly score for visual anomaly detection, then this is the numeric value of that threshold.
          - `suggestedValueText` string: If the threshold has a suggested value, e.g. a max. absolute error for regression projects; or the min. anomaly score for visual anomaly detection, then this is the stringified value of that threshold.
          - `value` union, required: Current value of the threshold
            - number
            - string
          - `dropdownOptions` object[]: Optional list of options, will be shown in a dropdown.
            - `description` string, required: Full description of the value
            - `value` string, required: Value, maps back to "BlockThreshold#value"
        - `isMultiLabel` boolean
        - `intervalMs` number, required: Interval between two windows in "expectedLabels" (1000 / frequency).
        - `frequencyHz` number, required: Frequency of the windows in "expectedLabels"
        - `labelMapResult` object[]: Structured classification results, one item per window
        - `labelMapScores` object[]: Structured classification scores, one item per window
        - `resultCount` integer, required: Number of classification result windows for this block. For structured outputs this can be greater than the length of "result".
    - `sample` RawSampleDataWithDataStreamPayloads, required
      - `sample` Sample, required
        - `id` integer, required
        - `filename` string, required
        - `signatureValidate` boolean, required: Whether signature validation passed
        - `signatureMethod` string
        - `signatureKey` string: Either the shared key or the public key that was used to validate the sample
        - `created` string, date-time, required: Timestamp when the sample was created on device, or if no accurate time was known on device, the time that the file was processed by the ingestion service.
        - `lastModified` string, date-time, required: Timestamp when the sample was last modified.
        - `category` 'training' | 'testing' | 'validation' | 'post-processing', required
        - `coldstorageFilename` string, required
        - `label` string, required
        - `intervalMs` number, required: Interval between two windows (1000 / frequency). NOTE: Previously this value could change depending on whether the sample was resampled. This behavior has been removed.
        - `frequency` number, required: Frequency of the sample. NOTE: Previously this value could change depending on whether the sample was resampled. This behavior has been removed.
        - `originalIntervalMs` number, required: DEPRECATED. See "intervalMs".
        - `originalFrequency` number, required: DEPRECATED. See "frequency".
        - `deviceName` string
        - `deviceType` string, required
        - `sensors` Sensor[], required
          - `index` integer, required: Index of the sensor (globally, so you can refer back to it in e.g. getSampleAsAudio)
          - `name` string, required: Name of the axis
          - `units` string, required: Type of data on this axis. Needs to comply to SenML units (see https://www.iana.org/assignments/senml/senml.xhtml).
        - `valuesCount` integer, required: Number of readings in this file. If you have multiple datastreams, this is the value count from the datastream with the highest frequency.
        - `totalLengthMs` number: Total length (in ms.) of this file
        - `added` string, date-time, required: Timestamp when the sample was added to the current acquisition bucket.
        - `boundingBoxes` BoundingBox[], required
          - `label` string, required
          - `x` integer, required
          - `y` integer, required
          - `width` integer, required
          - `height` integer, required
        - `boundingBoxesType` 'object_detection' | 'constrained_object_detection', required
        - `chartType` 'chart' | 'image' | 'video' | 'table', required
        - `thumbnailVideo` string
        - `thumbnailVideoFull` string
        - `isDisabled` boolean, required: True if the current sample is excluded from use
        - `isProcessing` boolean, required: True if the current sample is still processing (e.g. for video)
        - `processingJobId` integer: Set when sample is processing and a job has picked up the request
        - `processingError` boolean, required: Set when processing this sample failed
        - `processingErrorString` string: Error (only set when processing this sample failed)
        - `isCropped` boolean, required: Whether the sample is cropped from another sample (and has crop start / end info)
        - `metadata` object: Sample free form associated metadata
        - `projectId` integer, required: Unique identifier of the project this sample belongs to
        - `projectOwnerName` string: Name of the owner of the project this sample belongs to
        - `projectName` string: Name of the project this sample belongs to
        - `projectLabelingMethod` 'single_label' | 'object_detection' | 'label_map'
        - `sha256Hash` string, required: Data sample SHA 256 hash (including CBOR envelope if applicable)
        - `structuredLabels` StructuredLabel[]
          - `startIndex` integer, required: Start index of the label (e.g. 0)
          - `endIndex` integer, required: End index of the label (e.g. 3). This value is inclusive, so { startIndex: 0, endIndex: 3 } covers 0, 1, 2, 3.
          - `label` string, required: The label for this section.
          - `labelMap` SampleLabelMapLabels
            - `type` 'key-values', required
            - `labels` object, required
        - `structuredLabelsList` string[]
        - `createdBySyntheticDataJobId` integer: If this sample was created by a synthetic data job, it's referenced here.
        - `imageDimensions` object
          - `width` integer, required
          - `height` integer, required
        - `videoUrl` string: Video link, cropped and in original resolution.
        - `videoUrlFull` string: Video link in original resolution.
        - `labelMap` SampleLabelMapLabels
          - `type` 'key-values', required
          - `labels` object, required
        - `lastUpdatedBy` union: Information about the entity that last updated a sample. This can be a user, a project API key, an OAuth client, or a dataset version restore operation.
          - LastUpdatedByUser: The user who last updated a sample.
            - `type` 'user', required
            - `id` integer, required: The ID of the user that last updated the sample.
          - LastUpdatedByProjectApiKey: The project API key that last updated a sample.
            - `type` 'projectApiKey', required
            - `id` integer, required: The ID of the project API key that last updated the sample.
          - LastUpdatedByOAuthClient: The OAuth client that last updated a sample, and the user it is acting on behalf of.
            - `type` 'oauthClient', required
            - `oauthClientId` string, required: The ID of the OAuth client that last updated the sample.
            - `userId` integer: The user ID the OAuth client is acting on behalf of.
          - LastUpdatedByDatasetVersionRestore: The dataset restore that last updated a sample.
            - `type` 'datasetVersionRestore', required
            - `datasetVersionId` integer, required: The ID of the dataset version that last updated the sample.
            - `groupKey` string, required: A random grouping ID to keep restore snapshots isolated.
            - `actor` union: The actor that started the dataset restore operation.
              - …
        - `datastreams` SampleDatastream[], required
          - `index` integer, required
          - `chartType` 'chart' | 'image' | 'video' | 'table', required
          - `intervalMs` number, required: Interval between two windows (1000 / frequency).
          - `frequencyHz` number, required: Frequency of the datastream
          - `sensors` Sensor[], required
            - `index` integer, required: Index of the sensor (globally, so you can refer back to it in e.g. getSampleAsAudio)
            - `name` string, required: Name of the axis
            - `units` string, required: Type of data on this axis. Needs to comply to SenML units (see https://www.iana.org/assignments/senml/senml.xhtml).
          - `valuesCount` integer, required: Number of readings in this datastream.
          - `imageDimensions` object
            - `width` integer, required
            - `height` integer, required
          - `totalLengthMs` number, required: Total length (in ms.) of the datastream
      - `payload` RawSamplePayload, required: Sensor readings and metadata
        - `device_name` string: Unique identifier for this device. **Only** set this when the device has a globally unique identifier (e.g. MAC address).
        - `device_type` string, required: Device type, for example the exact model of the device. Should be the same for all similar devices.
        - `sensors` Sensor[], required: Array with sensor axes
          - `index` integer, required: Index of the sensor (globally, so you can refer back to it in e.g. getSampleAsAudio)
          - `name` string, required: Name of the axis
          - `units` string, required: Type of data on this axis. Needs to comply to SenML units (see https://www.iana.org/assignments/senml/senml.xhtml).
        - `values` array[], required: Array of sensor values. One array item per interval, and as many items in this array as there are sensor axes. This type is returned if there are multiple axes.
          - number[]
        - `cropStart` integer: New start index of the cropped sample
        - `cropEnd` integer: New end index of the cropped sample
        - `intervalMs` number, required: Interval between two windows (1000 / frequency). If the data was resampled, then this lists the resampled interval for this payload.
        - `frequencyHz` number, required: Frequency of the sample. If the data was resampled, then this lists the resampled frequency for this payload.
      - `totalPayloadLength` integer, required: Total number of payload values
      - `datastreamPayloads` object[], required
        - `index` integer, required: Index of the datastream in the sample (datastreams that are not in the impulse are filtered out here, so you can still find them back).
        - `payload` RawSamplePayload, required: Sensor readings and metadata
          - `device_name` string: Unique identifier for this device. **Only** set this when the device has a globally unique identifier (e.g. MAC address).
          - `device_type` string, required: Device type, for example the exact model of the device. Should be the same for all similar devices.
          - `sensors` Sensor[], required: Array with sensor axes
            - `index` integer, required: Index of the sensor (globally, so you can refer back to it in e.g. getSampleAsAudio)
            - `name` string, required: Name of the axis
            - `units` string, required: Type of data on this axis. Needs to comply to SenML units (see https://www.iana.org/assignments/senml/senml.xhtml).
          - `values` array[], required: Array of sensor values. One array item per interval, and as many items in this array as there are sensor axes. This type is returned if there are multiple axes.
            - number[]
          - `cropStart` integer: New start index of the cropped sample
          - `cropEnd` integer: New end index of the cropped sample
          - `intervalMs` number, required: Interval between two windows (1000 / frequency). If the data was resampled, then this lists the resampled interval for this payload.
          - `frequencyHz` number, required: Frequency of the sample. If the data was resampled, then this lists the resampled frequency for this payload.
        - `totalPayloadLength` integer, required: Total number of payload values
    - `windowSizeMs` integer, required: Size of the sliding window (as set by the impulse) in milliseconds.
    - `windowIncreaseMs` integer, required: Number of milliseconds that the sliding window increased with (as set by the impulse)
    - `alreadyInDatabase` boolean, required: Whether this sample is already in the training database
  - 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)
