> ## Documentation Index
> Fetch the complete documentation index at: https://docs.freyavoice.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# List unit tests

> Returns the unit tests for an agent or workflow, plus the latest run per (test, version) pair.



## OpenAPI

````yaml https://staging-app.freyavoice.ai/api/openapi.json get /unit-tests
openapi: 3.1.0
info:
  title: Freyavoice API
  version: 2.0.0
  description: >-
    Production API for managing calls and campaigns.


    **Authentication**: All endpoints require a bearer token issued by
    Freyavoice.


    **Response Format**: All responses are wrapped in a standard envelope:

    ```json

    {
      "success": true,
      "data": {
        "message": "Success",
        "result": { /* endpoint-specific data */ }
      }
    }

    ```


    Error responses follow the same format with `success: false`:

    ```json

    {
      "success": false,
      "data": {
        "message": "Error description",
        "result": null
      }
    }

    ```
  contact:
    name: Freyavoice Support
    email: support@freyavoice.com
servers:
  - url: https://app.freyavoice.ai/api/v2
    description: Production
security: []
tags:
  - name: Agents
    description: Manage AI agents
  - name: Analytics
    description: Call analytics and metrics
  - name: API Keys
    description: API key management
  - name: Audio
    description: Audio transcription and speech synthesis
  - name: Calls
    description: Call management and history
  - name: Call Recordings
    description: Call recording management
  - name: Call Tags
    description: Call tagging and categorization
  - name: Campaigns
    description: Campaign management
  - name: Chat
    description: Stateful text chat with agents and workflows
  - name: Custom
    description: Custom convenience endpoints
  - name: Export
    description: Data export
  - name: Insights
    description: Structured data field definitions
  - name: Agent Insights
    description: Agent-to-field assignments
  - name: Integrations
    description: Third-party integrations
  - name: Personas
    description: Simulation personas for agent testing
  - name: Phone Numbers
    description: Phone number management
  - name: Phone Aliases
    description: Workspace phone book (phone-number to label mappings)
  - name: Suppression List
    description: Workspace do-not-call (DNC) list; numbers blocked from outbound dialing
  - name: Feedbacks
    description: Feedback tracking
  - name: Feedback Assignees
    description: Feedback assignment
  - name: Feedback Comments
    description: Feedback comments
  - name: Feedback References
    description: Feedback cross-references to other entities
  - name: Feedback Status Config
    description: Feedback status configuration
  - name: Reviews
    description: Call reviews
  - name: Review Assignees
    description: Review assignment
  - name: Simulations
    description: Agent simulation testing
  - name: Simulation Iterations
    description: Simulation iteration history
  - name: Unit Tests
    description: Behavioural unit tests for agents and workflows
  - name: Branches
    description: Branches (proposed changes) of an agent or workflow version line
  - name: Webhooks
    description: Webhook configuration
  - name: Versions
    description: Version history and rollback for agents and workflows
  - name: Workflows
    description: Workflow management
  - name: Workspaces
    description: Workspace management
  - name: Workspace Credits
    description: Workspace credit balance
  - name: Workspace Invitations
    description: Workspace invitations
  - name: Workspace Logs
    description: Workspace activity logs
  - name: Workspace Members
    description: Workspace member management
  - name: Workspace Roles
    description: Custom roles and permissions per workspace
  - name: Permissions
    description: Permission catalog (used by role + API-key UIs)
paths:
  /unit-tests:
    get:
      tags:
        - Unit Tests
      summary: List unit tests
      description: >-
        Returns the unit tests for an agent or workflow, plus the latest run per
        (test, version) pair.
      operationId: listUnitTests
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: workspaceId
          in: query
        - schema:
            type: string
            enum:
              - agent
              - workflow
          required: true
          name: entityType
          in: query
        - schema:
            type: string
            minLength: 1
          required: true
          name: entityId
          in: query
        - schema:
            anyOf:
              - type: boolean
              - type: string
                enum:
                  - 'true'
              - type: string
                enum:
                  - 'false'
          required: false
          name: includeArchived
          in: query
        - schema:
            type: string
            format: uuid
          required: false
          name: entityVersionId
          in: query
        - schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 200
          required: false
          name: limit
          in: query
        - schema:
            type:
              - integer
              - 'null'
            minimum: 0
          required: false
          name: offset
          in: query
      responses:
        '200':
          description: Unit test list with latest-run summaries
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                      result:
                        type: object
                        properties:
                          tests:
                            type: array
                            items:
                              type: object
                              properties:
                                id:
                                  type: string
                                  format: uuid
                                workspaceId:
                                  type: string
                                  format: uuid
                                entityType:
                                  type: string
                                  enum:
                                    - agent
                                    - workflow
                                entityId:
                                  type: string
                                name:
                                  type: string
                                expectation:
                                  type: string
                                assertions:
                                  type: array
                                  items:
                                    oneOf:
                                      - type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - routing
                                          signal:
                                            type: string
                                            enum:
                                              - node_entered
                                              - route_target
                                            default: node_entered
                                          target:
                                            type: string
                                            minLength: 1
                                          negate:
                                            type: boolean
                                            default: false
                                        required:
                                          - type
                                          - target
                                      - type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - extraction
                                          name:
                                            type: string
                                            minLength: 1
                                          match:
                                            type: string
                                            enum:
                                              - exists
                                              - equals
                                              - contains
                                              - regex
                                              - absent
                                            default: exists
                                          value: {}
                                          minConfidence:
                                            type: number
                                            minimum: 0
                                            maximum: 1
                                        required:
                                          - type
                                          - name
                                      - type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - tool_call
                                          tool:
                                            type: string
                                            minLength: 1
                                          args:
                                            type: object
                                            additionalProperties: {}
                                          argsMatch:
                                            type: string
                                            enum:
                                              - subset
                                              - exact
                                            default: subset
                                          negate:
                                            type: boolean
                                            default: false
                                        required:
                                          - type
                                          - tool
                                tags:
                                  type: array
                                  items:
                                    type: string
                                input:
                                  type: object
                                  properties:
                                    schemaVersion:
                                      type: number
                                      enum:
                                        - 1
                                    callType:
                                      type: string
                                      enum:
                                        - web
                                        - voice
                                    messages:
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          role:
                                            type: string
                                            minLength: 1
                                          message:
                                            type: string
                                          content:
                                            type: string
                                          messageId:
                                            type: string
                                          nodeId:
                                            type:
                                              - string
                                              - 'null'
                                          secondsFromStart:
                                            type: number
                                          duration:
                                            type: number
                                          timestamp:
                                            type: string
                                          endTime:
                                            type: number
                                          wasBlocked:
                                            type: boolean
                                          was_blocked:
                                            type: boolean
                                          blockedContent:
                                            type: string
                                          blocked_content:
                                            type: string
                                          workflowSnapshot: {}
                                        required:
                                          - role
                                        additionalProperties: {}
                                      minItems: 1
                                    customerVariables:
                                      type: object
                                      additionalProperties: {}
                                    authoredAgainstVersionId:
                                      type: string
                                      format: uuid
                                  required:
                                    - schemaVersion
                                    - callType
                                    - messages
                                judgeContext:
                                  type:
                                    - object
                                    - 'null'
                                  properties:
                                    includeRoutingEvents:
                                      type: boolean
                                    includeExtractionEvents:
                                      type: boolean
                                    includeToolCalls:
                                      type: boolean
                                    includeOtherEvents:
                                      type: boolean
                                seedCallId:
                                  type:
                                    - string
                                    - 'null'
                                  format: uuid
                                seedMessageId:
                                  type:
                                    - string
                                    - 'null'
                                ordinal:
                                  type: integer
                                isArchived:
                                  type: boolean
                                createdBy:
                                  type:
                                    - string
                                    - 'null'
                                  format: uuid
                                updatedBy:
                                  type:
                                    - string
                                    - 'null'
                                  format: uuid
                                createdAt:
                                  type: string
                                updatedAt:
                                  type: string
                              required:
                                - id
                                - workspaceId
                                - entityType
                                - entityId
                                - name
                                - expectation
                                - assertions
                                - tags
                                - input
                                - seedCallId
                                - seedMessageId
                                - ordinal
                                - isArchived
                                - createdBy
                                - updatedBy
                                - createdAt
                                - updatedAt
                          total:
                            type: integer
                            minimum: 0
                          aggregates:
                            type: array
                            items:
                              type: object
                              properties:
                                unitTestId:
                                  type: string
                                  format: uuid
                                entityVersionId:
                                  type: string
                                  format: uuid
                                passCount:
                                  type: integer
                                  minimum: 0
                                failCount:
                                  type: integer
                                  minimum: 0
                                errorCount:
                                  type: integer
                                  minimum: 0
                                runningCount:
                                  type: integer
                                  minimum: 0
                                latestRunId:
                                  type:
                                    - string
                                    - 'null'
                                  format: uuid
                                latestOutcome:
                                  type:
                                    - string
                                    - 'null'
                                  enum:
                                    - queued
                                    - running
                                    - pass
                                    - fail
                                    - error
                                    - null
                                latestVerdictReason:
                                  type:
                                    - string
                                    - 'null'
                                latestCompletedAt:
                                  type:
                                    - string
                                    - 'null'
                                latestJudgeModel:
                                  type:
                                    - string
                                    - 'null'
                              required:
                                - unitTestId
                                - entityVersionId
                                - passCount
                                - failCount
                                - errorCount
                                - runningCount
                                - latestRunId
                                - latestOutcome
                                - latestVerdictReason
                                - latestCompletedAt
                                - latestJudgeModel
                        required:
                          - tests
                          - aggregates
                    required:
                      - message
                      - result
                required:
                  - success
                  - data
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                      result: {}
                    required:
                      - message
                required:
                  - success
                  - data
        '401':
          description: Missing or invalid token
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                      result: {}
                    required:
                      - message
                required:
                  - success
                  - data
        '403':
          description: Workspace ID mismatch or insufficient permissions
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                      result: {}
                    required:
                      - message
                required:
                  - success
                  - data
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                      result: {}
                    required:
                      - message
                required:
                  - success
                  - data
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````