---
title: "Create a simulation unit test"
method: POST
path: "/v1/{organization}/simulation/unit_test/"
tags: ["Simulation"]
---

# Create a simulation unit test

`POST /v1/{organization}/simulation/unit_test/`

Create a new simulation unit test.

#### Permissions
This endpoint requires the following permissions:
* `Simulation:CreateSimulationUnitTest` for the unit test to create.

## Path parameters

- `organization` string, required

## Headers

- `x-mongo-cluster-name` string, nullable — The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.
- `Sec-WebSocket-Protocol` string[]

## Request body

- SrcAppEndpointsSimulationCreateSimulationUnitTestRequest
  - `name` string, required
  - `description` string, required
  - `service_id` string, required — The service that the unit test runs on.
  - `service_version_set_name` string, required — The version set of the service that the unit test runs on.
  - `persona_id` string, required — The persona that unit test uses.
  - `scenario_id` string, required — The scenario that the unit test uses.
  - `max_interactions` integer, required — The max number of interactions after which the unit test fails.
  - `success_criterions` SrcAppEndpointsSimulationCreateSimulationUnitTestRequestSuccessCriterion[], required — The success criterions for the unit test.
    - `name` string, required
    - `metric_id` string, required
    - `criterion` union, required
      - NumericalMetricSuccessCriterion
        - `type` 'numerical', required
        - `verb` '==' | '!=' | '<=' | '<' | '>=' | '>', required
        - `threshold` number, required
      - BooleanMetricSuccessCriterion
        - `type` 'boolean', required
        - `expected_value` boolean, required
      - CategoricalMetricSuccessCriterionInput
        - `type` 'categorical', required
        - `expected_values` AmigoLibPydanticBaseModelStrippedNonemptyString1[], required
  - `tags` object, required — The tags of the simulation persona.

## Response `201`

Succeeded.

- SrcAppEndpointsSimulationCreateSimulationUnitTestResponse
  - `simulation_unit_test_id` string, required — The ID of the created simulation unit test.

## Other responses

- `400` — The metric type of the success criterion does not match the metric type of the metric.
- `401` — Invalid authorization credentials.
- `403` — Missing required permissions.
- `404` — The specified organization, service, persona, scenario, metric, or service version set was not found.
- `409` — A unit test with this name already exists.
- `422` — Invalid request path parameter or request body failed validation.
- `429` — The user has exceeded the rate limit of 500 requests per minute for this endpoint.
- `503` — The service is going through temporary maintenance.

---

[API](https://skmtc.net/amigo/apis/amigo-api.md) · [All operations](https://skmtc.net/amigo/apis/amigo-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/amigo/amigo-api/revisions/f0f28319e448/schema)
