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

# Execute & Manage Functions

> Execute, update, toggle, and manage function configurations

## Get Function by ID

<CodeGroup>
  ```bash GET /api/functions/id/{id} theme={null}
  curl -X GET "https://your-instance.com/api/functions/id/my_function" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
  ```
</CodeGroup>

Retrieve a specific function by its ID.

### Path Parameters

<ParamField path="id" type="string" required>
  The function identifier
</ParamField>

### Response

Returns the complete `FunctionModel` object including content and configuration.

## Update Function

<CodeGroup>
  ```bash POST /api/functions/id/{id}/update theme={null}
  curl -X POST "https://your-instance.com/api/functions/id/my_function/update" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "id": "my_function",
      "name": "Updated Function Name",
      "content": "def main():\n    print(\"Updated\")",
      "meta": {
        "description": "Updated description"
      }
    }'
  ```
</CodeGroup>

Update an existing function's code and metadata.

### Request Body

Same as [Create Function](/api/functions/create-function) request body.

## Toggle Function

<CodeGroup>
  ```bash POST /api/functions/id/{id}/toggle theme={null}
  curl -X POST "https://your-instance.com/api/functions/id/my_function/toggle" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
  ```
</CodeGroup>

Toggle a function's active state (enable/disable).

### Response

Returns the updated `FunctionModel` with the new `is_active` value.

## Toggle Global

<CodeGroup>
  ```bash POST /api/functions/id/{id}/toggle/global theme={null}
  curl -X POST "https://your-instance.com/api/functions/id/my_function/toggle/global" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
  ```
</CodeGroup>

Toggle a function's global availability.

### Response

Returns the updated `FunctionModel` with the new `is_global` value.

## Delete Function

<CodeGroup>
  ```bash DELETE /api/functions/id/{id}/delete theme={null}
  curl -X DELETE "https://your-instance.com/api/functions/id/my_function/delete" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
  ```
</CodeGroup>

Delete a function and remove it from the system cache.

### Response

<ResponseField name="result" type="boolean">
  `true` if deletion was successful, `false` otherwise
</ResponseField>

## Valve Management

### Get Function Valves

<CodeGroup>
  ```bash GET /api/functions/id/{id}/valves theme={null}
  curl -X GET "https://your-instance.com/api/functions/id/my_function/valves" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
  ```
</CodeGroup>

Retrieve the current valve configuration for a function.

#### Response

Returns a dictionary of valve values.

### Get Valves Schema

<CodeGroup>
  ```bash GET /api/functions/id/{id}/valves/spec theme={null}
  curl -X GET "https://your-instance.com/api/functions/id/my_function/valves/spec" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
  ```
</CodeGroup>

Retrieve the valve schema definition (if the function defines a `Valves` class).

#### Response

Returns a JSON schema object with valve field definitions and options.

### Update Function Valves

<CodeGroup>
  ```bash POST /api/functions/id/{id}/valves/update theme={null}
  curl -X POST "https://your-instance.com/api/functions/id/my_function/valves/update" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "api_key": "new_value",
      "enabled": true
    }'
  ```
</CodeGroup>

Update valve configuration values. The request body should match the valve schema.

## User Valves

### Get User Valves

<CodeGroup>
  ```bash GET /api/functions/id/{id}/valves/user theme={null}
  curl -X GET "https://your-instance.com/api/functions/id/my_function/valves/user" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```
</CodeGroup>

Retrieve user-specific valve values for the authenticated user.

### Get User Valves Schema

<CodeGroup>
  ```bash GET /api/functions/id/{id}/valves/user/spec theme={null}
  curl -X GET "https://your-instance.com/api/functions/id/my_function/valves/user/spec" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```
</CodeGroup>

Retrieve the user valve schema definition (if the function defines a `UserValves` class).

### Update User Valves

<CodeGroup>
  ```bash POST /api/functions/id/{id}/valves/user/update theme={null}
  curl -X POST "https://your-instance.com/api/functions/id/my_function/valves/user/update" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "preference": "value"
    }'
  ```
</CodeGroup>

Update user-specific valve values. Stored in user settings.

## Load Function from URL

<CodeGroup>
  ```bash POST /api/functions/load/url theme={null}
  curl -X POST "https://your-instance.com/api/functions/load/url" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "url": "https://github.com/user/repo/blob/main/function.py"
    }'
  ```
</CodeGroup>

Load a function from a GitHub URL. Supports both file and folder URLs.

### Request Body

<ParamField body="url" type="string" required>
  GitHub URL to the function file or folder. URLs are automatically converted to raw\.githubusercontent.com format.
</ParamField>

### Response

<ResponseField name="name" type="string">
  Suggested function name extracted from the filename/folder
</ResponseField>

<ResponseField name="content" type="string">
  Function source code
</ResponseField>

## Sync Functions

<CodeGroup>
  ```bash POST /api/functions/sync theme={null}
  curl -X POST "https://your-instance.com/api/functions/sync" \
    -H "Authorization: Bearer YOUR_ADMIN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "functions": [
        {
          "id": "func1",
          "user_id": "user123",
          "name": "Function 1",
          "type": "filter",
          "content": "...",
          "meta": {},
          "valves": {},
          "is_active": true,
          "is_global": false,
          "updated_at": 1234567890,
          "created_at": 1234567890
        }
      ]
    }'
  ```
</CodeGroup>

Synchronize multiple functions at once. Updates existing functions, creates new ones, and removes functions not in the list.

### Request Body

<ParamField body="functions" type="array" required>
  Array of `FunctionWithValvesModel` objects to sync
</ParamField>

### Response

Returns the complete list of synced functions.

## Authentication

Most endpoints require admin privileges. User valve endpoints only require verified user authentication.
