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

# List Custom Functions

> List all custom functions in the organization

List all custom functions in your organization. Custom functions are user-defined Python functions that can be attached to agents as tools.

## Query Parameters

<ParamField query="page" type="integer" default={1}>
  Page number (starting from 1)
</ParamField>

<ParamField query="per_page" type="integer" default={20}>
  Items per page (maximum 50)
</ParamField>

## Response

<ResponseField name="items" type="array">
  Array of custom function objects

  <Expandable title="Custom Function Object">
    <ResponseField name="id" type="string">
      Unique identifier for the custom function
    </ResponseField>

    <ResponseField name="name" type="string">
      Display name of the function
    </ResponseField>

    <ResponseField name="description" type="string">
      Human-readable description
    </ResponseField>

    <ResponseField name="technical_description" type="string">
      Auto-generated technical description from code analysis
    </ResponseField>

    <ResponseField name="status" type="string">
      Function status: `analysing`, `ready`, `error`
    </ResponseField>

    <ResponseField name="input_schema" type="object">
      Auto-extracted JSON schema for function parameters
    </ResponseField>

    <ResponseField name="source_code" type="string">
      Python source code of the function
    </ResponseField>

    <ResponseField name="limits" type="object">
      Execution limits (timeout, memory, etc.)
    </ResponseField>

    <ResponseField name="organization_id" type="string">
      Organization UUID
    </ResponseField>

    <ResponseField name="created_at" type="string">
      ISO timestamp of creation
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of custom functions
</ResponseField>

<ResponseField name="page" type="integer">
  Current page number
</ResponseField>

<ResponseField name="per_page" type="integer">
  Items per page
</ResponseField>

<ResponseField name="total_pages" type="integer">
  Total pages available
</ResponseField>

## Example Request

```bash theme={"dark"}
curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/custom_functions?page=1&per_page=10"
```

## Notes

* Custom functions are attached to agents using `attached_tools` with `id='xpander-custom-functions'`
* Functions in `analysing` status are being processed and not yet available for use


## OpenAPI

````yaml GET /v1/custom_functions
openapi: 3.1.0
info:
  title: xpander.ai API Service
  description: |2-

        The xpander.ai API Service provides a unified REST API for managing AI agents,
        executing tasks, managing knowledge bases, and integrating with external systems.
        
        Features:
        - Agent Management: Create, update, deploy, and delete AI agents
        - Task Execution: Invoke agents with support for sync, async, and streaming modes
        - Knowledge Bases: Manage knowledge bases and documents for RAG workflows
        - Tools: Discover, connect, and attach tools (connectors, custom functions, MCP servers, sub-agents, workflows) to agents and workflows
        - MCP Integration: Model Context Protocol support for standardized AI interactions
        
        Authentication: All endpoints require authentication via either an API key (`x-api-key`) or an OAuth2 JWT (`Authorization: Bearer <jwt>`).
        
  version: '0.001'
servers:
  - url: https://api.xpander.ai
security: []
paths:
  /v1/custom_functions:
    get:
      tags:
        - API v1
        - Custom Functions
        - Custom Functions CRUD
      summary: List Custom Functions
      description: >-
        List all custom functions in the organization. Custom functions are
        user-defined Python functions that can be attached to agents as tools
        using attached_tools with id='xpander-custom-functions'.
      operationId: List_custom_functions_v1_custom_functions_get
      parameters:
        - name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            description: Page number (starting from 1)
            default: 1
            title: Page
          description: Page number (starting from 1)
        - name: per_page
          in: query
          required: false
          schema:
            type: integer
            maximum: 50
            minimum: 1
            description: Items per page (max 50)
            default: 20
            title: Per Page
          description: Items per page (max 50)
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedResponse_CustomFunctionItem_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    PaginatedResponse_CustomFunctionItem_:
      properties:
        items:
          items:
            $ref: '#/components/schemas/CustomFunctionItem'
          type: array
          title: Items
        total:
          type: integer
          title: Total
        page:
          type: integer
          title: Page
        per_page:
          type: integer
          title: Per Page
        total_pages:
          type: integer
          title: Total Pages
      type: object
      required:
        - items
        - total
        - page
        - per_page
        - total_pages
      title: PaginatedResponse[CustomFunctionItem]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CustomFunctionItem:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the custom function.
        name:
          type: string
          title: Name
          description: Human-readable name of the function.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Description of what the function does.
        technical_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Technical Description
          description: >-
            Auto-generated technical description from code analysis. Explains
            the function's logic, inputs, and outputs.
        status:
          anyOf:
            - type: string
            - type: 'null'
          title: Status
          description: >-
            Current function status. 'analysing' = being analyzed after
            create/update, 'ready' = available for execution, 'error' = analysis
            failed (check analysis_error_details), 'draft' = not yet analyzed.
        limits:
          anyOf:
            - $ref: '#/components/schemas/CustomFunctionLimitsModel'
            - type: 'null'
          description: Resource limits for execution.
        input_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Input Schema
          description: >-
            Auto-detected JSON schema of the function's input parameters.
            Generated during analysis from the function signature and type
            hints.
        source_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Code
          description: >-
            Python source code of the function. Only included in get-by-id
            responses, not in list.
        analysis_error_details:
          anyOf:
            - type: string
            - type: 'null'
          title: Analysis Error Details
          description: >-
            Error details if the function analysis failed. Only present when
            status is 'error'.
        organization_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Organization Id
          description: Organization that owns this function.
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
          description: ISO timestamp of when the function was created.
      type: object
      required:
        - id
        - name
      title: CustomFunctionItem
      description: >-
        Public-facing custom function response model.


        Returned by list and get endpoints. Contains function metadata,

        status, auto-detected input schema, and source code.


        To use a custom function as an agent tool:

        1. Add to attached_tools: {"id": "xpander-custom-functions",
        "operation_ids": ["<function_id>"]}

        2. Add to graph: {"item_id": "<function_id>", "name": "<function_name>",
        "type": "tool", "targets": []}
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    CustomFunctionLimitsModel:
      properties:
        max_run_time:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Run Time
          description: >-
            Maximum execution time in seconds. The function will be terminated
            if it exceeds this limit. Default: 15 seconds.
          default: 15
      type: object
      title: CustomFunctionLimitsModel
      description: Resource limits for custom function execution.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      description: API Key for authentication
      in: header
      name: x-api-key

````