Skip to main content

Get Function by ID

curl -X GET "https://your-instance.com/api/functions/id/my_function" \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
Retrieve a specific function by its ID.

Path Parameters

id
string
required
The function identifier

Response

Returns the complete FunctionModel object including content and configuration.

Update Function

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"
    }
  }'
Update an existing function’s code and metadata.

Request Body

Same as Create Function request body.

Toggle Function

curl -X POST "https://your-instance.com/api/functions/id/my_function/toggle" \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
Toggle a function’s active state (enable/disable).

Response

Returns the updated FunctionModel with the new is_active value.

Toggle Global

curl -X POST "https://your-instance.com/api/functions/id/my_function/toggle/global" \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
Toggle a function’s global availability.

Response

Returns the updated FunctionModel with the new is_global value.

Delete Function

curl -X DELETE "https://your-instance.com/api/functions/id/my_function/delete" \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
Delete a function and remove it from the system cache.

Response

result
boolean
true if deletion was successful, false otherwise

Valve Management

Get Function Valves

curl -X GET "https://your-instance.com/api/functions/id/my_function/valves" \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
Retrieve the current valve configuration for a function.

Response

Returns a dictionary of valve values.

Get Valves Schema

curl -X GET "https://your-instance.com/api/functions/id/my_function/valves/spec" \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY"
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

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
  }'
Update valve configuration values. The request body should match the valve schema.

User Valves

Get User Valves

curl -X GET "https://your-instance.com/api/functions/id/my_function/valves/user" \
  -H "Authorization: Bearer YOUR_API_KEY"
Retrieve user-specific valve values for the authenticated user.

Get User Valves Schema

curl -X GET "https://your-instance.com/api/functions/id/my_function/valves/user/spec" \
  -H "Authorization: Bearer YOUR_API_KEY"
Retrieve the user valve schema definition (if the function defines a UserValves class).

Update User Valves

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"
  }'
Update user-specific valve values. Stored in user settings.

Load Function from URL

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"
  }'
Load a function from a GitHub URL. Supports both file and folder URLs.

Request Body

url
string
required
GitHub URL to the function file or folder. URLs are automatically converted to raw.githubusercontent.com format.

Response

name
string
Suggested function name extracted from the filename/folder
content
string
Function source code

Sync Functions

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
      }
    ]
  }'
Synchronize multiple functions at once. Updates existing functions, creates new ones, and removes functions not in the list.

Request Body

functions
array
required
Array of FunctionWithValvesModel objects to sync

Response

Returns the complete list of synced functions.

Authentication

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