Skip to main content
POST
Create Function

Create New Function

Creates a new function. The function ID must be unique and contain only alphanumeric characters and underscores.

Request Body

string
required
Unique identifier for the function. Must be alphanumeric with underscores only (will be converted to lowercase).
string
required
Display name for the function
string
required
Python source code for the function. The system will:
  • Replace imports with internal versions
  • Load and validate the function module
  • Extract function type (e.g., “filter”, “action”)
  • Parse frontmatter manifest
object
required
Metadata for the function

Response

string
The function identifier
string
ID of the user who created the function
string
Function type (automatically detected from the function code)
string
Function name
object
Function metadata with parsed manifest
boolean
Whether the function is active (default: false)
boolean
Whether the function is globally available (default: false)
integer
Unix timestamp of creation
integer
Unix timestamp of creation

Function Types

The system automatically detects the function type from your code:
  • filter: Functions that process/filter content
  • action: Functions that perform actions
  • Other types may be supported depending on your configuration

Python Function Pattern

Functions should follow this pattern:
The frontmatter (between """) is parsed as the manifest.

Special Behaviors

Filter Functions with Toggle

If your function is detected as a “filter” type and has a toggle attribute, the system automatically sets meta.toggle to true.

Import Replacement

The system automatically replaces imports to use internal module versions for security and compatibility.

Error Responses

string
Error message
400 Bad Request
  • Invalid function ID format (non-alphanumeric/underscore characters)
  • Function ID already exists
  • Invalid Python code
  • Failed to load function module
401 Unauthorized
  • Missing or invalid admin authentication

Authentication

Requires admin privileges.