Skip to content

Functions API

MethodPathPurpose
POST/v1/{app_id}/functionsDeploy or update a function
GET/v1/{app_id}/functionsList all functions
GET/v1/{app_id}/functions/{name}Get function details and metrics
DELETE/v1/{app_id}/functions/{name}Delete a function
POST/v1/{app_id}/functions/{name}/invokeTest-invoke a function
GET/v1/{app_id}/functions/{name}/logsView invocation logs
MethodPathPurpose
ANY/v1/{app_id}/fn/{function_name}Call a deployed function (any HTTP method)

End-user tokens are forwarded to the function.

POST /v1/{app_id}/functions
Authorization: Bearer {token}
{
"name": "hello-world",
"code": "export default async function handler(req) {\n return new Response(JSON.stringify({ message: 'Hello!' }), {\n headers: { 'Content-Type': 'application/json' }\n });\n}",
"description": "A simple greeting function",
"triggers": [
{ "type": "http", "config": { "auth": "required" } },
{ "type": "cron", "config": { "schedule": "0 9 * * *" } }
],
"envVars": {
"API_KEY": "secret123"
},
"timeoutMs": 30000,
"memoryLimitMb": 128
}
FieldDescription
nameUnique name (1-100 characters)
codeSource code with default export handler
FieldDefaultDescription
descriptionWhat the function does
envVarsEnvironment variables (encrypted)
timeoutMs30000Max execution time (max: 300000)
memoryLimitMb128Memory limit (range: 64-1024)
triggers[{type: "http"}]Array of trigger configs. At most one per type.
triggerLegacy single-trigger shorthand; normalized server-side to a 1-element triggers array.
agent_toolfalseExpose this function to agents as a tool.
agent_tool_descriptionShort description shown to the LLM (max 500 chars).
agent_tool_moderead_onlyread_only or read_write. read_write requires HITL approval.
agent_tool_exposed_todeveloper_onlydeveloper_only or end_user.

Each trigger object has a type and a type-specific config. At most one trigger of each type may be attached to a function (enforced by a unique index).

TypeConfigNotes
http{ method?, path?, auth? }auth defaults to required — anonymous callers get 401 at the edge. Set none only for intentionally public endpoints.
cron{ schedule, timezone? }schedule is a cron expression (e.g. */5 * * * *). timezone defaults to UTC.
s3_upload{ bucket, prefix?, contentTypes? }Fires when an object lands in the bucket matching prefix and (optionally) the listed MIME types.
webhook{ secret_required?, allowed_sources? }Generates a signed webhook URL. allowed_sources is a comma-separated list of provider tags.
websocket{}Invoked on each incoming WebSocket frame from the realtime channel.

When agent_tool: true, this function becomes callable from any agent in the same app whose graph spec lists its name under tools.functions[]. See the Agents API for how agents reference function tools.

{
"name": "lookup_account",
"code": "...",
"agent_tool": true,
"agent_tool_description": "Look up a customer by email. Returns id, plan, status.",
"agent_tool_mode": "read_only",
"agent_tool_exposed_to": "developer_only"
}

The 4 agent_tool* fields are returned on GET /functions and GET /functions/{name} so clients can render UI state.

PATCH /v1/{app_id}/functions/{name}/env
Authorization: Bearer {token}
{
"envVars": {
"API_KEY": "new-secret",
"NEW_VAR": "value",
"OLD_VAR": null
}
}

Values are merged with existing env vars (not replaced). Set a value to null to delete a key.

GET /v1/{app_id}/functions/{name}/logs?limit=50&since=2026-01-01T00:00:00Z&level=error
ParameterDescription
limitNumber of log entries
sinceISO date filter
levelFilter by level (error, all)
include_deletedtrue to read logs for a soft-deleted function (post-incident forensics). Default false.
FieldDescription
methodHTTP method
pathRequest path
status_codeResponse status
duration_msExecution time
memory_mbMemory used
errorError message (if any)
consoleLogsArray of captured console output ({ level, message, timestamp })
MetricDescription
total_invocationsTotal invocation count
error_countNumber of errors
error_rateError percentage
avg_duration_msAverage execution time
last_invocationTimestamp of last call