---
title: "Run Call Unit Tests Endpoint"
method: POST
path: "/testing/call-unit/run"
---

# Run Call Unit Tests Endpoint

`POST /testing/call-unit/run`

Run call unit tests for a specific agent.

This endpoint:
1. Fetches the agent's current configuration
2. Retrieves test cases from db-svc (conversation contexts marked as unit tests)
3. Runs each test case against the agent's current settings
4. Calculates similarity scores using LLM-as-judge
5. Saves results to db-svc
6. Returns the test results

Args:
    request: RunCallUnitTestsRequest with agent_id, optional test_ids, and similarity_threshold

Returns:
    RunCallUnitTestsResponse with all test run results

## Headers

- `authorization` string, required

## Request body

- RunCallUnitTestsRequest — Request to run call unit tests for an agent
  - `agent_id` string, required — Agent ID to run tests for
  - `test_ids` string[], nullable — Specific test IDs to run, None = run all
  - `similarity_threshold` integer — Percentage needed to pass (0-100)

## Response `200`

Successful Response

- RunCallUnitTestsResponse — Response from running call unit tests
  - `result_id` string, required — ID of the saved test result
  - `test_runs` CallUnitTestRunResult[], required — List of individual test run results
    - `test_run_id` string, required — Unique ID for this test run
    - `test_case_id` string, required — The conversation_context request_id
    - `messages_context` object[], nullable — Conversation messages used for this run
    - `block_name` string, nullable — Readable block name for cur_action
    - `expected_response` string, nullable — Expected response
    - `actual_response` string, nullable — Actual LLM-generated response
    - `expected_state` string, nullable — Expected state
    - `actual_state` string, nullable — Actual LLM-determined state
    - `expected_state_name` string, nullable — Readable expected state name
    - `actual_state_name` string, nullable — Readable actual state name
    - `instructions` string, nullable — Action instructions used during the run
    - `similarity_score` integer, required — Similarity score (0-100)
    - `passed` boolean, required — Whether the test passed
    - `workflow_version` WorkflowVersionSnapshot — Snapshot of workflow version info
      - `workflow_id` string, required — Workflow ID
      - `version_id` string, required — publishedVersionId from t_workflows
      - `version_number` integer, required — versionNumber from t_workflow_versions
      - `version_name` string, nullable — versionName from t_workflow_versions
    - `status` 'pending' | 'in_progress' | 'completed' | 'failed' — Status of a single call unit test run
  - `passed_tests` integer, required — Number of tests that passed
  - `total_tests` integer, required — Total number of tests run
  - `agent_config` AgentConfigSnapshot, required — Snapshot of agent configuration at test time
    - `voice_llm_model` string, nullable — advancedSettings.voiceLLMModel
    - `flow_architecture` string, nullable — "Phonely 1.0" or "Phonely 2.0" (mapped from stateDeterminationMode)
    - `conversation_style` string, nullable — agent.conversationStyle
    - `state_determination_mode` string, nullable — Raw stateDeterminationMode value
    - `prompt_version` string, nullable — advancedSettings.promptVersion
  - `status` 'in_progress' | 'completed' | 'failed', required — Status of a call unit test result batch

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/phonely/apis/fastapi.md) · [All operations](https://skmtc.net/phonely/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/phonely/fastapi/versions/9bfd5599d479/schema)
