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

# Update a test

> Omitted fields keep their current values. Content changes create an immutable version and require expectedVersionId from the last read. Name and description changes keep the content version. Existing simulations retain their original evidence.



## OpenAPI

````yaml openapi.json PATCH /v1/tests/{testId}
openapi: 3.1.0
info:
  title: Egma Platform API
  version: 1.0.0
  description: >-
    The customer-facing HTTP interface used by Egma's web app, CLI, and outside
    clients.
servers:
  - url: https://app.egma.ai
security: []
paths:
  /v1/tests/{testId}:
    patch:
      tags:
        - Tests
      summary: Update a test
      description: >-
        Omitted fields keep their current values. Content changes create an
        immutable version and require expectedVersionId from the last read. Name
        and description changes keep the content version. Existing simulations
        retain their original evidence.
      operationId: updateTest
      parameters:
        - name: testId
          in: path
          required: true
          schema:
            type: string
            minLength: 1
        - name: projectId
          in: query
          required: false
          schema:
            type: string
            minLength: 1
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  anyOf:
                    - type: string
                    - type: 'null'
                scenario:
                  type: string
                  description: The situation and goal the synthetic caller acts out.
                expectedBehaviors:
                  type: array
                  items:
                    type: string
                  description: >-
                    Statements checked independently against the completed
                    conversation. Include at least one non-empty statement.
                personas:
                  type: array
                  items:
                    type: string
                  description: >-
                    At least one available persona ID or unambiguous current
                    name. Each selected persona creates one simulation for this
                    test in a run.
                mockTools:
                  type: array
                  items:
                    description: >-
                      One named tool's fixed response for this test. Supply
                      exactly one of answer or error. Tools without a mock run
                      normally.
                    oneOf:
                      - type: object
                        properties:
                          tool:
                            type: string
                          answer: {}
                          error:
                            not: {}
                        required:
                          - tool
                          - answer
                        additionalProperties: false
                      - type: object
                        properties:
                          tool:
                            type: string
                          answer:
                            not: {}
                          error:
                            type: string
                        required:
                          - tool
                          - error
                        additionalProperties: false
                  description: >-
                    Test-owned tool answers. Use an empty array to remove
                    existing mocks on update. Applying mocks requires a
                    supported connection and, for LiveKit, tool instrumentation.
                env:
                  anyOf:
                    - type: object
                      properties:
                        retell_dynamic_variables:
                          type: object
                          description: >-
                            String values supplied to the Retell agent before
                            the conversation. Variable names beginning with
                            egma_ are reserved.
                          additionalProperties:
                            type: string
                        job_dispatch_metadata:
                          type: object
                          description: >-
                            Context delivered to the LiveKit worker in
                            ctx.job.metadata.
                          additionalProperties: true
                      additionalProperties: false
                    - type: 'null'
                  description: >-
                    Non-secret startup context for the agent's provider. Omit to
                    keep existing context on update, or send null to clear it.
                expectedVersionId:
                  type: string
                  minLength: 1
                  description: >-
                    The versionId returned by the test read. Required when
                    changing scenario, expectedBehaviors, personas, mockTools,
                    or env; a stale value returns 409.
                expectedRevision:
                  type: string
                  minLength: 1
                  description: >-
                    The revision returned by the test read. Supply it to reject
                    an update if the test's live identity changed since that
                    read.
              additionalProperties: false
      responses:
        '200':
          description: The updated test.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    minLength: 1
                  projectId:
                    type: string
                    minLength: 1
                  suiteId:
                    type: string
                    minLength: 1
                  name:
                    type: string
                  description:
                    anyOf:
                      - type: string
                      - type: 'null'
                  version:
                    type: integer
                    minimum: 1
                  versionId:
                    type: string
                    minLength: 1
                  scenario:
                    type: string
                  expectedBehaviors:
                    type: array
                    items:
                      type: string
                  personas:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          minLength: 1
                        name:
                          type: string
                        archivedAt:
                          anyOf:
                            - type: string
                              format: date-time
                            - type: 'null'
                      required:
                        - id
                        - name
                        - archivedAt
                      additionalProperties: false
                  mockTools:
                    type: array
                    items:
                      description: >-
                        One named tool's fixed response for this test. Supply
                        exactly one of answer or error. Tools without a mock run
                        normally.
                      oneOf:
                        - type: object
                          properties:
                            tool:
                              type: string
                            answer: {}
                            error:
                              not: {}
                          required:
                            - tool
                            - answer
                          additionalProperties: false
                        - type: object
                          properties:
                            tool:
                              type: string
                            answer:
                              not: {}
                            error:
                              type: string
                          required:
                            - tool
                            - error
                          additionalProperties: false
                  env:
                    anyOf:
                      - type: object
                        properties:
                          retell_dynamic_variables:
                            type: object
                            description: >-
                              String values supplied to the Retell agent before
                              the conversation. Variable names beginning with
                              egma_ are reserved.
                            additionalProperties:
                              type: string
                          job_dispatch_metadata:
                            type: object
                            description: >-
                              Context delivered to the LiveKit worker in
                              ctx.job.metadata.
                            additionalProperties: true
                        additionalProperties: false
                      - type: 'null'
                  revision:
                    type: string
                    minLength: 1
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                required:
                  - id
                  - projectId
                  - suiteId
                  - name
                  - description
                  - version
                  - versionId
                  - scenario
                  - expectedBehaviors
                  - personas
                  - mockTools
                  - env
                  - revision
                  - createdAt
                  - updatedAt
                additionalProperties: false
        '400':
          description: The request was refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refusal'
        '401':
          description: The request was refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refusal'
        '403':
          description: The request was refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refusal'
        '404':
          description: The request was refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refusal'
        '409':
          description: The test content or identity moved after the write was based on it.
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      error:
                        const: version_conflict
                      message:
                        type: string
                      test:
                        type: object
                        properties:
                          id:
                            type: string
                            minLength: 1
                          name:
                            type: string
                        required:
                          - id
                          - name
                        additionalProperties: false
                      expectedVersionId:
                        type: string
                        minLength: 1
                      currentVersionId:
                        type: string
                        minLength: 1
                    required:
                      - error
                      - message
                      - test
                      - expectedVersionId
                      - currentVersionId
                    additionalProperties: false
                  - $ref: '#/components/schemas/Refusal'
        '422':
          description: The request was refused.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refusal'
        '429':
          description: The request rate limit was reached.
          headers:
            Retry-After:
              description: Seconds to wait before trying again.
              schema:
                type: integer
                minimum: 1
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refusal'
      security:
        - bearerAuth: []
        - sessionCookie: []
components:
  schemas:
    Refusal:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        details:
          type: object
          additionalProperties: true
      required:
        - error
        - message
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: An Egma API key.
    sessionCookie:
      type: apiKey
      in: cookie
      name: egma.session_token
      description: >-
        The browser session cookie issued by Egma. HTTPS deployments add the
        standard __Secure- prefix.

````