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

# Create a function

> Creates a function.



## OpenAPI

````yaml post /functions
openapi: 3.0.3
info:
  title: Vogent - OpenAPI 3.0
  description: Test Description
  version: 1.0.11
servers:
  - url: https://api.vogent.ai/api
security:
  - bearerAuth: []
paths:
  /functions:
    post:
      summary: Create a function
      description: Creates a function.
      operationId: createFunction
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFunctionInput'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Function'
        '400':
          description: Invalid input
        '422':
          description: Validation exception
components:
  schemas:
    CreateFunctionInput:
      allOf:
        - $ref: '#/components/schemas/BasicCreateFunctionInput'
        - oneOf:
            - $ref: '#/components/schemas/CreateTransferFunctionInput'
              title: Transfer
            - $ref: '#/components/schemas/CreateAPIFunctionInput'
              title: API
          discriminator:
            propertyName: type
            mapping:
              transfer:
                $ref: '#/components/schemas/CreateTransferFunctionInput'
              api:
                $ref: '#/components/schemas/CreateAPIFunctionInput'
    Function:
      allOf:
        - $ref: '#/components/schemas/BasicFunction'
        - oneOf:
            - $ref: '#/components/schemas/TransferFunction'
              title: Transfer
            - $ref: '#/components/schemas/APIFunction'
              title: API
          discriminator:
            propertyName: type
            mapping:
              transfer:
                $ref: '#/components/schemas/TransferFunction'
              api:
                $ref: '#/components/schemas/APIFunction'
    BasicCreateFunctionInput:
      type: object
      properties:
        name:
          type: string
          description: The name of the function.
          nullable: false
        description:
          type: string
          description: A description of what the function does.
          nullable: false
        type:
          type: string
          enum:
            - transfer
            - api
        lifecycleMessages:
          $ref: '#/components/schemas/FunctionLifecycleMessages'
          description: Messages to display during function execution lifecycle events.
      required:
        - name
        - description
    CreateTransferFunctionInput:
      type: object
      properties:
        allowedNumbers:
          type: array
          description: >-
            The numbers that the agent is allowed to transfer to in e.164 format
            (+11234567890).
          items:
            $ref: '#/components/schemas/AllowedNumber'
          nullable: false
        allowAnyNumber:
          type: boolean
          description: >-
            Instead of using a fixed list of allowed numbers, allow the agent to
            transfer to any number (not recommended).
      required:
        - allowedNumbers
    CreateAPIFunctionInput:
      type: object
      properties:
        apiPath:
          type: string
          description: The path to the API.
          nullable: false
        headers:
          type: array
          description: Headers to be sent with the API request
          items:
            $ref: '#/components/schemas/KVMapping'
          nullable: false
        inputJsonSchema:
          type: string
          description: >-
            The JSON schema for the input to the function. Must be a top level
            object.
      required:
        - apiPath
        - headers
        - inputJsonSchema
    BasicFunction:
      type: object
      properties:
        id:
          type: string
          nullable: false
        name:
          type: string
          description: The name of the function.
          nullable: false
        description:
          type: string
          description: A description of what the function does.
          nullable: false
        type:
          type: string
          enum:
            - transfer
            - api
          nullable: false
        lifecycleMessages:
          $ref: '#/components/schemas/FunctionLifecycleMessages'
          description: Messages to display during function execution lifecycle events.
      required:
        - id
        - name
        - description
        - type
    TransferFunction:
      type: object
      properties:
        allowedNumbers:
          type: array
          description: The numbers that the agent is allowed to transfer to.
          items:
            $ref: '#/components/schemas/AllowedNumber'
          nullable: false
        allowAnyNumber:
          type: boolean
          description: >-
            Instead of using a fixed list of allowed numbers, allow the agent to
            transfer to any number (not recommended).
      required:
        - allowedNumbers
        - allowAnyNumber
    APIFunction:
      type: object
      properties:
        apiPath:
          type: string
          description: The path to the API.
          nullable: false
        headers:
          type: array
          description: Headers to be sent with the API request
          items:
            $ref: '#/components/schemas/KVMapping'
          nullable: false
        inputJsonSchema:
          type: string
          description: >-
            The JSON schema for the input to the function. Must be a top level
            object.
      required:
        - apiPath
        - headers
        - inputJsonSchema
    FunctionLifecycleMessages:
      type: object
      properties:
        started:
          type: array
          description: >-
            Messages to display when the function starts executing. One will be
            chosen at random.
          items:
            type: string
          nullable: false
      required:
        - started
    AllowedNumber:
      type: object
      properties:
        number:
          type: string
          nullable: false
          description: The number in e.164 format.
      required:
        - number
    KVMapping:
      type: object
      properties:
        key:
          type: string
          nullable: false
        value:
          type: string
          nullable: false
      required:
        - key
        - value
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        In the form `Bearer <api_key_here>`. You can find your api key in your
        dashboard.

````