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

# Associate agents with a test set

> Associate one or more agents with a test set. The operation is idempotent: already-associated agents are a no-op, and unknown or inactive agent IDs are ignored. The response reflects the resulting association set, so callers can confirm which IDs took effect.



## OpenAPI

````yaml /api-reference/v1/test-sets-v1.yaml post /test-sets/{test_set_id}/agents:add
openapi: 3.0.3
info:
  title: Test Sets API
  version: 1.0.0
  description: >
    API for managing test sets - collections of test cases for evaluation.


    Test sets organize test cases and can define parameters for test case
    generation.
  contact:
    name: Coval API Support
    url: https://coval.dev
    email: support@coval.dev
servers:
  - url: https://api.coval.dev/v1
    description: Production API
security:
  - apiKey: []
tags:
  - name: Test Sets
    description: Operations for managing test sets
paths:
  /test-sets/{test_set_id}/agents:add:
    post:
      tags:
        - Test Sets
      summary: Associate agents with a test set
      description: >-
        Associate one or more agents with a test set. The operation is
        idempotent: already-associated agents are a no-op, and unknown or
        inactive agent IDs are ignored. The response reflects the resulting
        association set, so callers can confirm which IDs took effect.
      operationId: addTestSetAgents
      parameters:
        - name: test_set_id
          in: path
          required: true
          description: Test set ID (8-character ID)
          schema:
            type: string
            minLength: 8
            maxLength: 8
          example: abc12345
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddTestSetAgentsRequest'
      responses:
        '200':
          description: Agents associated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListTestSetAgentsResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Test set not found for this organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    AddTestSetAgentsRequest:
      type: object
      description: Associate one or more agents with the test set.
      required:
        - agent_ids
      properties:
        agent_ids:
          type: array
          description: >-
            Agent IDs (22-char ShortUUIDs) to associate. Already-associated IDs
            are a no-op, and unknown or inactive IDs are ignored; the response
            reflects the resulting association set.
          minItems: 1
          maxItems: 1000
          items:
            type: string
            minLength: 1
            maxLength: 22
            pattern: ^[A-Za-z0-9]+$
          example:
            - abc123def456ghi789jklm
    ListTestSetAgentsResponse:
      type: object
      description: The agents currently associated with the test set.
      required:
        - agents
      properties:
        agents:
          type: array
          items:
            $ref: '#/components/schemas/TestSetAgentResource'
    ErrorResponse:
      type: object
      description: Standard error response
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - details
          properties:
            code:
              type: string
              description: Machine-readable error code
              example: INVALID_ARGUMENT
            message:
              type: string
              description: Human-readable error message
              example: Invalid request parameters
            details:
              type: array
              description: Detailed error information
              items:
                type: object
                properties:
                  field:
                    type: string
                    description: Field that caused the error
                    example: slug
                  description:
                    type: string
                    description: Description of the error
                    example: slug already exists for this organization
    TestSetAgentResource:
      type: object
      description: An agent associated with a test set.
      required:
        - name
        - agent_id
        - display_name
      properties:
        name:
          type: string
          description: Resource name, "test-sets/{test_set_id}/agents/{agent_id}".
          example: test-sets/abc12345/agents/abc123def456ghi789jklm
        agent_id:
          type: string
          description: Agent identifier (22-char ShortUUID).
          example: abc123def456ghi789jklm
        display_name:
          type: string
          description: Human-readable agent name.
          example: Support Bot
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: INVALID_ARGUMENT
              message: Invalid request parameters
              details:
                - field: display_name
                  description: display_name is required and cannot be empty
    Unauthorized:
      description: Authentication failed or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNAUTHENTICATED
              message: Authentication failed
              details:
                - field: X-API-Key
                  description: Invalid or missing API key
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: INTERNAL
              message: Internal server error
              details:
                - description: An unexpected error occurred while processing the request
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Organization API key for authentication

````