> ## 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.

# Duplicate an agent

> Clone an existing agent into a new agent owned by your organization.
By default only the agent config is copied; set `include_associations`
to also copy its metric and test-set associations. Returns the new
agent in the same shape as create.




## OpenAPI

````yaml /api-reference/v1/agents-v1.yaml post /agents/{agent_id}/duplicate
openapi: 3.0.3
info:
  title: Coval Agents API
  version: 1.0.0
  description: |

    Manage configurations for simulations and evaluations.
  contact:
    name: Coval API Support
    email: support@coval.dev
    url: https://docs.coval.ai
  license:
    name: Proprietary
    url: https://coval.dev/terms
servers:
  - url: https://api.coval.dev/v1
    description: Production API
security:
  - ApiKeyAuth: []
tags:
  - name: Agents
    description: CRUD operations for AI agent configurations
paths:
  /agents/{agent_id}/duplicate:
    post:
      tags:
        - Agents
      summary: Duplicate an agent
      description: |
        Clone an existing agent into a new agent owned by your organization.
        By default only the agent config is copied; set `include_associations`
        to also copy its metric and test-set associations. Returns the new
        agent in the same shape as create.
      operationId: duplicateAgent
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[A-Za-z0-9]{22}$
          description: ID of the agent to duplicate
          example: abc123def456ghi789jklm
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                include_associations:
                  type: boolean
                  default: false
                  description: >-
                    Also copy the source agent's metric and test-set
                    associations.
              example:
                include_associations: true
      responses:
        '201':
          description: Agent duplicated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateAgentResponse'
        '400':
          description: Missing agent_id or invalid body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Source agent not found or belongs to different organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                notFound:
                  $ref: '#/components/examples/AgentNotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateAgentResponse:
      type: object
      required:
        - agent
      properties:
        agent:
          $ref: '#/components/schemas/AgentResource'
    ErrorResponse:
      type: object
      description: Standard error response
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - details
          properties:
            code:
              type: string
              description: Error code enum
              enum:
                - INVALID_ARGUMENT
                - UNAUTHENTICATED
                - NOT_FOUND
                - ALREADY_EXISTS
                - INTERNAL
              example: INVALID_ARGUMENT
            message:
              type: string
              description: Human-readable error message
              example: Invalid request parameter
            details:
              type: array
              description: Detailed error information
              items:
                type: object
                properties:
                  field:
                    type: string
                    nullable: true
                    description: Field name that caused the error
                    example: page_size
                  description:
                    type: string
                    description: Detailed error description
                    example: page_size must be between 1 and 100
    AgentResource:
      type: object
      description: >
        Agent configuration resource.


        Note: The `active` field (soft delete status) is managed internally and
        not exposed in API responses.
      required:
        - customer_agent_id
      properties:
        id:
          type: string
          description: Agent resource ID
          pattern: ^[A-Za-z0-9]{22}$
          example: abc123def456ghi789jklm
        customer_agent_id:
          type: string
          description: >-
            Customer-supplied external id for the agent. Defaults to `id` when
            not set at creation.
          example: my-support-agent
        display_name:
          type: string
          description: Human-readable agent name
          minLength: 1
          maxLength: 200
          example: Customer Support Agent
        model_type:
          $ref: '#/components/schemas/SimulatorType'
        phone_number:
          type: string
          nullable: true
          description: Phone number in E.164 format or SIP address for voice/SMS agents
          maxLength: 200
          example: '+1234567890'
        endpoint:
          type: string
          nullable: true
          description: Custom API endpoint URL
          maxLength: 200
          example: https://api.example.com/agent
        prompt:
          type: string
          nullable: true
          description: Agent instructions/system prompt
          example: You are a helpful customer support agent...
        language:
          type: string
          nullable: true
          description: Primary language for the agent
          example: en
        attributes:
          type: object
          nullable: true
          description: >-
            Free-form agent attributes; referenceable in metric prompts as
            `{{agent.<key>}}`.
          additionalProperties: true
          example:
            company_name: Acme Corp
            tier: enterprise
        metadata:
          type: object
          description: Simulator-specific configuration (JSONB)
          additionalProperties: true
          example:
            voice: alloy
            model: gpt-realtime-2
        workflows:
          type: object
          description: Workflow configuration (JSONB)
          additionalProperties: true
          example: {}
        metric_ids:
          type: array
          description: Associated metric IDs
          items:
            type: string
          example:
            - abc123def456ghi789jklm
            - def456ghi789jklmabc123
        test_set_ids:
          type: array
          description: Associated test set IDs
          items:
            type: string
          example:
            - gT5wq2Hn
        knowledge_base_ids:
          type: array
          description: >-
            Associated knowledge base entry IDs (read-only, derived from reverse
            FK)
          readOnly: true
          items:
            type: string
          example: []
        tags:
          type: array
          description: Tags associated with this agent
          items:
            type: string
          default: []
          example:
            - production
            - voice
        create_time:
          type: string
          format: date-time
          description: Creation timestamp (ISO 8601)
          example: '2025-10-14T12:00:00Z'
        update_time:
          type: string
          format: date-time
          nullable: true
          description: Last update timestamp (ISO 8601)
          example: '2025-10-15T14:30:00Z'
    SimulatorType:
      type: string
      description: >
        Agent type. Active types that can be created via the v1 API:


        - **MODEL_TYPE_VOICE**: Inbound voice calls (requires phone_number in
        E.164 format or SIP address)

        - **MODEL_TYPE_OUTBOUND_VOICE**: Outbound voice calls (requires endpoint
        webhook URL)

        - **MODEL_TYPE_CHAT**: Text-based chat agents (requires
        metadata.chat_endpoint)

        - **MODEL_TYPE_CHAT_A2A**: A2A JSON-RPC chat agents (requires
        metadata.chat_endpoint)

        - **MODEL_TYPE_CHAT_WEBSOCKET**: Text chat over WebSocket (requires
        metadata.endpoint in direct mode)

        - **MODEL_TYPE_SMS**: SMS messaging agents (requires phone_number in
        E.164 format)

        - **MODEL_TYPE_WEBSOCKET**: WebSocket voice agents (requires
        metadata.endpoint wss:// URL in direct mode;
        metadata.initialization_json is optional)

        - **MODEL_TYPE_OPENAI_REALTIME**: OpenAI Realtime voice-to-voice agents

        - **MODEL_TYPE_GEMINI_REALTIME**: Gemini Live voice-to-voice agents

        - **MODEL_TYPE_GROK_REALTIME**: Grok (xAI) Voice Agent voice-to-voice
        agents
      enum:
        - MODEL_TYPE_VOICE
        - MODEL_TYPE_OUTBOUND_VOICE
        - MODEL_TYPE_CHAT
        - MODEL_TYPE_CHAT_A2A
        - MODEL_TYPE_CHAT_WEBSOCKET
        - MODEL_TYPE_SMS
        - MODEL_TYPE_WEBSOCKET
        - MODEL_TYPE_OPENAI_REALTIME
        - MODEL_TYPE_GEMINI_REALTIME
        - MODEL_TYPE_GROK_REALTIME
      example: MODEL_TYPE_VOICE
  responses:
    Unauthorized:
      description: Authentication failed
      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
  examples:
    AgentNotFoundError:
      summary: Agent not found
      value:
        error:
          code: NOT_FOUND
          message: Agent not found
          details:
            - field: agent_id
              description: Agent not found or not accessible by your organization
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````