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

# Duplicate function

> Clone an existing function into a new one with a different name, copying its code and parameters. Use when you want to reuse a function's logic as a starting point without modifying the original.



## OpenAPI

````yaml api-reference/agents/openapi.json POST /v1/agents/{agentId}/branches/{branchId}/functions/{functionId}/duplicate
openapi: 3.1.0
info:
  title: PolyAI Agents API
  version: 1.0.11
  description: Manage PolyAI agents, telephony, deployments, and real-time configs.
servers:
  - url: https://api.us.poly.ai
    description: US region
  - url: https://api.eu.poly.ai
    description: EU region
  - url: https://api.uk.poly.ai
    description: UK region
  - url: https://api.studio.poly.ai
    description: Studio region
security:
  - polyApiKey: []
paths:
  /v1/agents/{agentId}/branches/{branchId}/functions/{functionId}/duplicate:
    parameters:
      - name: agentId
        in: path
        required: true
        schema:
          type: string
      - name: branchId
        in: path
        required: true
        schema:
          type: string
      - name: functionId
        in: path
        required: true
        schema:
          type: string
    post:
      tags:
        - Functions
      summary: Duplicate a function
      description: >-
        Clone an existing function into a new one with a different name, copying
        its code and parameters. Use when you want to reuse a function's logic
        as a starting point without modifying the original.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DuplicateFunctionPublicBody'
      responses:
        '201':
          description: Duplicated function
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DuplicateFunctionPublicResponse'
        '404':
          description: Function not found
components:
  schemas:
    DuplicateFunctionPublicBody:
      title: DuplicateFunctionPublicBody
      description: An optional name to use for a duplicated function.
      type: object
      properties:
        name:
          type: string
          minLength: 1
      additionalProperties: false
    DuplicateFunctionPublicResponse:
      title: DuplicateFunctionPublicResponse
      description: Identifiers for a newly duplicated function.
      type: object
      properties:
        id:
          type: string
        name:
          type: string
      required:
        - id
        - name
      additionalProperties: false
  securitySchemes:
    polyApiKey:
      type: apiKey
      in: header
      name: X-API-KEY

````