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

# Clone agent

> Copies an agent into a fresh draft (records the source in `template_agent_id`). **Requires a bearer login session** — an API key alone returns `400`. Scope `sessions:write`.



## OpenAPI

````yaml /api-reference/openapi.json post /agent/{agent_id}/clone
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/{agent_id}/clone:
    post:
      tags:
        - Agents
      summary: Clone agent
      description: >-
        Copies an agent into a fresh draft (records the source in
        `template_agent_id`). **Requires a bearer login session** — an API key
        alone returns `400`. Scope `sessions:write`.
      operationId: clone_agent_ca_api_v0_agent__agent_id__clone_post
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent Id
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                  description: >-
                    Optional id for the clone (alias: `agent_id`);
                    auto-generated if omitted.
                name:
                  type: string
                  description: Optional name; defaults to the source name with a suffix.
            example:
              name: Sales Agent v2
      responses:
        '201':
          description: Cloned draft agent (full agent record)
          content:
            application/json:
              example:
                id: agent_01CLONE
                name: Sales Agent v2
                objective: You are a sales assistant for {{company}}.
                instruction: Be polite, concise, and never invent prices.
                task: Qualify the lead and book a callback.
                channel: voice
                config:
                  llm_provider: gemini
                  tts_provider: sarvam
                  voice: anushka
                tools: []
                custom_variables:
                  - callee_name
                  - company
                knowledge_base_id: null
                pronunciation_dictionary_id: null
                customer_id: customer_01EXAMPLE
                owner_user_id: user_01EXAMPLE
                created_by_user_id: user_01EXAMPLE
                visibility: private
                status: draft
                template_agent_id: agent_sales_hi
                published_at: null
                created_at: '2026-05-22T12:00:00Z'
                updated_at: '2026-05-22T12:00:00Z'
        '400':
          description: Called with an API key instead of a bearer login session
          content:
            application/json:
              example:
                error:
                  code: invalid_request
                  message: Bearer login is required to clone agents
        '404':
          description: Source agent not found
        '409':
          description: An agent with the target id already exists
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    BearerAuth:
      type: http
      scheme: bearer

````