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

# Create a test version

> A new definition. Attempts already pinned to an earlier version keep it.



## OpenAPI

````yaml https://api.twinbay.ai/openapi.json post /tests/{test_id}/versions
openapi: 3.1.0
info:
  title: Twinbay
  description: Backend API
  version: 0.1.0
servers:
  - url: https://api.twinbay.ai
    description: Production
security: []
tags:
  - name: healthchecks
    description: Healthcheck endpoints
  - name: users
    description: >-
      The current user. Sign-up and sign-in happen in WorkOS AuthKit, which
      issues the access tokens this API accepts.
  - name: organizations
    description: >-
      Organizations the caller belongs to. Every authenticated request acts
      inside exactly one organization — the one its access token names — so
      these routes address it as `current`.
  - name: api-keys
    description: >-
      Long-lived credentials for callers that cannot hold an AuthKit session —
      agents, SDKs, CI. A key is accepted wherever an access token is, and acts
      with the role its creator holds when the request arrives.
  - name: environments
    description: >-
      Create and edit isolated provider environments. Each environment contains
      behavioural twins from the `twins` package.
  - name: twins
    description: Manage provisioned twins by their IDs.
  - name: catalog
    description: Browse the digital twins available for new environments.
  - name: scenarios
    description: Reusable starting setups of provider twins and optional seeds.
  - name: seeds
    description: >-
      Starting states for a twin. Describe the data you want in your own words,
      and a worker expands it into rows once; pass the seed's id when you create
      an environment to start a twin holding it.
  - name: tests
    description: >-
      Outcomes described in natural language, compiled once into request
      matchers, and evaluated deterministically against the traffic an attempt
      was served.
paths:
  /tests/{test_id}/versions:
    post:
      tags:
        - tests
      summary: Create a test version
      description: A new definition. Attempts already pinned to an earlier version keep it.
      operationId: create_test_version
      parameters:
        - name: test_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Test Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTestVersionRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestVersionResponse'
        '401':
          description: The credential is missing, malformed, expired, or not trusted
        '403':
          description: The credential does not act inside an organization
        '404':
          description: Test not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - Access token: []
        - Organization API key: []
components:
  schemas:
    CreateTestVersionRequest:
      properties:
        task_description:
          type: string
          maxLength: 2000
          minLength: 1
          title: Task Description
        outcomes:
          items:
            $ref: '#/components/schemas/OutcomeRequest'
          type: array
          maxItems: 50
          minItems: 1
          title: Outcomes
      additionalProperties: false
      type: object
      required:
        - task_description
        - outcomes
      title: CreateTestVersionRequest
    TestVersionResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        test_id:
          type: string
          format: uuid
          title: Test Id
        version:
          type: integer
          title: Version
        task_description:
          type: string
          title: Task Description
        outcomes:
          items:
            $ref: '#/components/schemas/OutcomeResponse'
          type: array
          title: Outcomes
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - test_id
        - version
        - task_description
        - outcomes
        - created_at
      title: TestVersionResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    OutcomeRequest:
      properties:
        key:
          type: string
          maxLength: 100
          minLength: 1
          pattern: ^[a-z0-9_-]+$
          title: Key
          description: >-
            Stable name of this outcome across versions. Keep it when a new
            version does not change what the outcome means.
        description:
          type: string
          maxLength: 2000
          minLength: 1
          title: Description
          description: What should or must not happen, e.g. "Never refund a charge."
        expectation:
          type: string
          enum:
            - required
            - forbidden
          title: Expectation
        timing:
          type: string
          enum:
            - at_end
            - throughout
          title: Timing
      additionalProperties: false
      type: object
      required:
        - key
        - description
        - expectation
        - timing
      title: OutcomeRequest
    OutcomeResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        key:
          type: string
          title: Key
        description:
          type: string
          title: Description
        expectation:
          type: string
          enum:
            - required
            - forbidden
          title: Expectation
        timing:
          type: string
          enum:
            - at_end
            - throughout
          title: Timing
      type: object
      required:
        - id
        - key
        - description
        - expectation
        - timing
      title: OutcomeResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    Access token:
      type: http
      description: Access token issued by WorkOS AuthKit.
      scheme: bearer
    Organization API key:
      type: apiKey
      description: >-
        An organization API key. Create one at
        https://console.twinbay.ai/api-keys
      in: header
      name: X-API-Key

````