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

# Create Agent Function

> Create a custom function for one agent version.

<Warning>
  **Legacy endpoint - deprecated.** Unversioned endpoints are scheduled for removal on **July 31, 2026**. A public v1 replacement is not currently listed in the v1 reference. This endpoint remains available for existing integrations until then.
</Warning>

Creates a custom function on a specific agent version. Use this nested v1 path for new integrations instead of the legacy flat `agent-functions` route.

## Path parameters

| Parameter       | Description           |
| --------------- | --------------------- |
| `agentId`       | Agent ID.             |
| `versionNumber` | Agent version number. |

## Related endpoints

* [List Agent Functions](/docs/api-reference/agent-functions/list): list functions for an agent version.
* [Custom Functions](/docs/agent-settings/custom-functions): configure function behavior in the dashboard.


## OpenAPI

````yaml POST /agent-functions/{agentId}/{versionNumber}
openapi: 3.0.0
info:
  title: DialNexa API
  description: >-
    Public REST API for the DialNexa voice AI platform. Versioned endpoints are
    under /v1; unversioned endpoints are legacy and deprecated.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: API Keys
  - name: Agent Functions
  - name: Agents V1
  - name: Agents2
  - name: Batch Calls
  - name: Batch Calls V1
  - name: Call Logs
  - name: Calls
  - name: Calls V1
  - name: Campaign Leads
  - name: Campaigns
  - name: External Webhooks
  - name: Knowledge Base
  - name: Knowledge Base V1
  - name: LLMs
  - name: LLMs V1
  - name: Languages
  - name: Languages V1
  - name: Organization Phone Numbers
  - name: Organization Phone Numbers V1
  - name: Phone Number Pricing
  - name: Phone Number Pricing V1
  - name: Transcribers
  - name: Transcribers V1
  - name: User Webhooks
  - name: User Webhooks V1
  - name: V1
  - name: Voices
  - name: Voices V1
  - name: Webcall
  - name: Workflow Leads
  - name: Workflow Leads V1
  - name: Workflows
  - name: Workflows V1
paths:
  /agent-functions/{agentId}/{versionNumber}:
    post:
      tags:
        - Agent Functions
      summary: Create a new agent function
      description: >-
        **Legacy endpoint - deprecated, scheduled for removal on July 31,
        2026.** Use the `/v1` version for new integrations. 
      operationId: AgentFunctionsController_create
      parameters:
        - name: agentId
          required: true
          in: path
          description: ID of the agent
          schema:
            type: string
        - name: versionNumber
          required: true
          in: path
          description: Version number of the agent
          schema:
            type: string
        - name: x-organization-id
          in: header
          description: RSA encrypted organization ID (base64 format)
          required: true
          schema:
            type: string
            example: BASE64_ENCRYPTED_ORG_ID_HERE
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentFunctionDto'
      responses:
        '201':
          description: The agent function has been successfully created.
        '400':
          description: Bad request.
        '401':
          description: Unauthorized.
        '403':
          description: Agent does not belong to your organization.
      deprecated: true
components:
  schemas:
    CreateAgentFunctionDto:
      type: object
      properties:
        displayName:
          type: string
          description: Display name of the function (max 35 characters)
          example: End Call Function
          maxLength: 35
        description:
          type: string
          description: Description of the function
          example: This function ends the call
        type:
          type: string
          description: Type of the function
          enum:
            - end_call
            - call_transfer
            - custom
            - check_calendar_availability
            - book_calendar
            - integration
          example: end_call
        config:
          type: object
          description: Configuration object for the function
          example:
            timeout: 30
            message: Goodbye!
      required:
        - type
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````