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

# Create test suite

> Creates a reusable suite of persona scenarios for the Test Runner. `agent_id` is optional — a suite is a workspace-level object and the agent to test is chosen at run time; when provided it is validated against the workspace. A scenario's persona may be left blank while drafting and is required only at run time. Scope `sessions:write`.



## OpenAPI

````yaml /api-reference/openapi.json post /agent-test-suites
openapi: 3.1.0
info:
  title: Lehar API
  version: v0
  description: >-
    Customer-facing REST API for the Lehar voice-AI platform. Platform-admin
    endpoints are intentionally excluded from this reference. Regenerate with
    `npm run sync:openapi`.
servers:
  - url: https://api.lehar.ai/ca/api/v0
security:
  - ApiKeyAuth: []
  - BearerAuth: []
paths:
  /agent-test-suites:
    post:
      tags:
        - Agent Testing
      summary: Create test suite
      description: >-
        Creates a reusable suite of persona scenarios for the Test Runner.
        `agent_id` is optional — a suite is a workspace-level object and the
        agent to test is chosen at run time; when provided it is validated
        against the workspace. A scenario's persona may be left blank while
        drafting and is required only at run time. Scope `sessions:write`.
      operationId: create_suite_ca_api_v0_agent_test_suites_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                  maxLength: 200
                  description: Suite name, unique within the workspace (max 200 chars).
                agent_id:
                  type: string
                  description: >-
                    Optional agent to associate as an origin hint. Validated
                    against the workspace when set.
                scenarios:
                  type: array
                  maxItems: 100
                  description: >-
                    Persona scenarios (max 100). Most fields are passed through
                    to the Test Runner; only `runs`, `max_turns`, and
                    `variables` are validated here.
                  items:
                    type: object
                    properties:
                      label:
                        type: string
                        description: >-
                          Display label; becomes the result's `scenario_label`
                          (defaults to `scenario N`).
                      instructions:
                        type: string
                        description: >-
                          Persona / instructions that drive the simulated user
                          (alias: `persona`). A non-empty `instructions` or
                          `persona` is required to run the suite.
                      persona:
                        type: string
                        description: Alias for `instructions`.
                      agent_expectations:
                        type: string
                        description: What the agent is expected to do, for the judges.
                      judges:
                        type: array
                        items:
                          type: string
                        description: >-
                          Judge criteria for this scenario (overrides the suite
                          `config.judges`).
                      tool_mocks:
                        type: object
                        description: >-
                          Mocked tool responses, passed opaquely to the Test
                          Runner.
                      runs:
                        type: integer
                        minimum: 1
                        maximum: 5
                        default: 1
                        description: How many times to repeat this scenario (1-5).
                      max_turns:
                        type: integer
                        minimum: 1
                        maximum: 20
                        default: 8
                        description: Max conversation turns per run (1-20).
                      simulator_model:
                        type: string
                        description: >-
                          Model driving the simulated user (e.g.
                          `gemini:gemini-2.5-flash`).
                      judge_model:
                        type: string
                        description: Model used to judge the conversation.
                      variables:
                        type: object
                        description: >-
                          Per-scenario `{{variable}}` values. Flat map of scalar
                          values (string/number/boolean/null); at most 64 keys
                          and 30000 serialized bytes. Overrides suite
                          `config.variables`.
                config:
                  type: object
                  description: >-
                    Suite-level defaults. `variables` (validated) seeds
                    `{{variable}}` values for every scenario; `judges`, `runs`,
                    `max_turns`, `simulator_model`, `judge_model` act as
                    defaults a scenario can override; `max_parallel` (1-8,
                    default 3) bounds scenario fan-out.
                  properties:
                    variables:
                      type: object
                      description: >-
                        Default `{{variable}}` values. Same shape and caps as a
                        scenario's `variables`.
                    judges:
                      type: array
                      items:
                        type: string
                    max_parallel:
                      type: integer
                      minimum: 1
                      maximum: 8
                      default: 3
            example:
              name: Renewal objections
              agent_id: agent_sales_hi
              scenarios:
                - label: Price objection
                  instructions: >-
                    You are a budget-conscious customer who thinks the renewal
                    price is too high. Push back on cost before agreeing to
                    anything.
                  runs: 2
                  max_turns: 8
              config:
                judges:
                  - task_completion
                  - safety
                variables:
                  company: Acme
      responses:
        '201':
          description: Created test suite
          content:
            application/json:
              example:
                id: test_suite_01hzy8x2m4q7r8s9t0v1w2x3y4
                agent_id: agent_sales_hi
                name: Renewal objections
                scenarios:
                  - label: Price objection
                    instructions: >-
                      You are a budget-conscious customer who thinks the renewal
                      price is too high. Push back on cost before agreeing to
                      anything.
                    runs: 2
                    max_turns: 8
                config:
                  judges:
                    - task_completion
                    - safety
                  variables:
                    company: Acme
                created_by_user_id: user_01EXAMPLE
                created_at: '2026-05-22T10:00:00Z'
                updated_at: '2026-05-22T10:00:00Z'
        '400':
          description: >-
            Validation failed — e.g. missing/oversized `name`, `scenarios` not a
            list or over 100, a scenario `runs`/`max_turns` out of range,
            invalid `variables`, `config` not an object, or `agent_id` not in
            the workspace.
          content:
            application/json:
              example:
                error:
                  code: invalid_request
                  message: name is required
        '401':
          description: Missing or invalid credentials (code `unauthorized`).
        '403':
          description: >-
            The credential is missing the required `sessions:write` scope (code
            `forbidden`).
        '409':
          description: A suite with this name already exists in the workspace.
          content:
            application/json:
              example:
                error:
                  code: conflict
                  message: >-
                    A test suite named 'Renewal objections' already exists in
                    this workspace
        '500':
          description: Unexpected server error (code `internal_error`).
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    BearerAuth:
      type: http
      scheme: bearer

````