functionPlatform Functions

Deploy, invoke, version, promote, and roll back registered platform functions.

Platform functions are registered, parameterized read queries that the agent calls mid-conversation to retrieve live data. The API provides endpoints for the full function lifecycle: deploy, invoke, test, promote, and rollback.

Concepts

Versions

Every deploy creates a new immutable version. Versions are numbered monotonically per function name within a workspace (v1, v2, v3, ...). Prior versions are never modified.

Aliases

Functions are resolved through aliases, not raw version numbers:

Alias
Description

latest

Automatically rebound on every deploy

staging

Manually promoted for pre-production validation

production

Manually promoted for production traffic

Parameter Types

Type
Description

string

Text value (also covers UUIDs, dates, datetimes)

integer

Whole number

number

Floating-point number

boolean

True or false

Function Types

Type
Description

sql

Parameterized query against entity and analytical data

ai

Query wrapping an AI classification or extraction step

udtf

User-defined table function (reserved)

python

Custom logic authored externally (reserved)

Return Kinds

Kind
Description

table

Returns a list of rows (list of objects)

scalar

Returns a single value (first column of first row)

Endpoints

Deploy a Function

Validates and registers a new function version. Automatically rebinds the latest alias to the new version.

Request body:

Field
Type
Required
Description

name

string

Yes

Function name. Lowercase letters, digits, and underscores. 1-128 characters. Must start with a letter.

description

string

Yes

What the function does. 1-2048 characters. Surfaced to the agent for tool selection.

when_to_use

string

No

Guidance for when the agent should select this function. Max 2048 characters.

function_type

string

No

One of sql, ai, udtf, python. Default: sql.

returns

string

No

One of table, scalar. Default: table.

parameters

array

No

List of parameter declarations (max 32). See Parameter object below.

sql

string

Yes

Query template with :name-style bind placeholders. 1-8192 characters.

timeout_ms

integer

No

Execution timeout in milliseconds. 100-60000. Default: 30000.

examples

array

No

Example calls (max 8). See Example object below.

Parameter object:

Field
Type
Required
Description

name

string

Yes

Parameter name. Lowercase letters, digits, underscores. Must start with a letter. 1-64 characters.

type

string

Yes

One of string, integer, number, boolean.

description

string

Yes

What this parameter controls. 1-512 characters.

required

boolean

No

Whether the caller must supply this parameter. Default: true.

default

string, integer, number, or boolean

No

Default value when the caller omits this parameter. Must match declared type.

Example object:

Field
Type
Required
Description

input

object

Yes

Example caller arguments.

output

any

Yes

Expected output.

description

string

No

What this example demonstrates.

Response: FunctionVersion object (see below).

Errors:

Status
Description

409

Concurrent deploy raced at the same version

422

Validation failure (read-only violation, parameter mismatch, missing workspace binding)

429

Rate limited

Validation rules applied at deploy time:

  • Query must be a read-only operation. Mutation keywords are rejected.

  • Every declared parameter must be referenced in the query template.

  • Every bind placeholder in the query must have a matching parameter declaration.

  • Queries against workspace-scoped data must include the workspace binding (auto-injected at execution time).

  • Default values must match their declared parameter type.


List Functions

Returns the latest version of every registered function in the workspace.

Response:

Field
Type
Description

items

array

List of FunctionVersion objects

count

integer

Total number of functions


List Function Versions

Returns all versions of a function, newest first.

Response:

Field
Type
Description

items

array

List of FunctionVersion objects

count

integer

Total number of versions


Get Function Version

Resolves a function name and alias to a specific version.

Query parameters:

Parameter
Type
Default
Description

alias

string

latest

One of latest, staging, production

Response: FunctionVersion object.


Invoke a Function

Executes a registered function with caller-supplied arguments.

Request body:

Field
Type
Required
Description

input

object

No

Caller arguments matching the function's input schema. Default: empty object.

alias

string

No

Alias to resolve. One of latest, staging, production. Default: latest.

Response:

Field
Type
Description

result

any

Query result. For table functions: list of row objects. For scalar functions: single value.

duration_ms

number

Execution time in milliseconds

row_count

integer

Number of rows returned

version

integer

Version that was executed

Errors:

Status
Description

404

Function not found at the specified alias

422

Bind validation failure (missing required argument, unknown argument, type mismatch)

429

Rate limited

503

Query execution backend unavailable

Notes:

  • Workspace isolation is automatically applied. The workspace identifier is injected as a bind parameter at execution time.

  • Unknown arguments (not declared in the function's parameter list) are rejected.

  • Missing optional parameters use their declared default value, or null if no default is set.

  • Read-only keys (view permission) are allowed to invoke functions.


Test a Function

Same as invoke, but also persists test results (pass/fail status, error details, execution duration) on the version row for dashboard display.

Request body: Same as Invoke.

Response: Same as Invoke, plus:

Field
Type
Description

status

string

pass or fail

error

string or null

Error message if status is fail

test_duration_ms

integer

Total test duration including overhead

Permissions: Requires write access (admin or owner role).


Promote a Function

Rebinds an alias to a specific version.

Request body:

Field
Type
Required
Description

alias

string

Yes

One of latest, staging, production

version

integer

Yes

Version number to bind the alias to. Must be >= 1.

Response:

Field
Type
Description

name

string

Function name

alias

string

Alias that was rebound

version

integer

Version the alias now points to

Errors:

Status
Description

404

Function or version not found

429

Rate limited

Permissions: Requires write access (admin or owner role).


Rollback a Function

Rebinds both latest and production aliases to a prior version. The staging alias is not affected.

Request body:

Field
Type
Required
Description

version

integer

Yes

Prior version to roll back to. Must be >= 1.

Response:

Field
Type
Description

name

string

Function name

rolled_back_to_version

integer

Version that latest and production now point to

Errors:

Status
Description

404

Function or version not found

429

Rate limited

Permissions: Requires write access (admin or owner role).


FunctionVersion Object

Field
Type
Description

name

string

Function name

version

integer

Version number

function_type

string

sql, ai, udtf, or python

returns_kind

string

table or scalar

description

string

Function description

when_to_use

string

Guidance for agent tool selection

parameters

array

Parameter declarations

sql_template

string

Query template with bind placeholders

input_schema

object

JSON Schema derived from parameters. Used by the agent for tool selection.

examples

array

Example calls

timeout_ms

integer

Execution timeout in milliseconds

source_path

string or null

Source file path (for repository-managed functions)

source_hash

string or null

Source content hash (for repository-managed functions)

last_test_at

string or null

ISO timestamp of last test execution

last_test_status

string or null

pass or fail

last_test_error

string or null

Error message from last test

last_test_duration_ms

integer or null

Duration of last test in milliseconds

deployed_at

string or null

ISO timestamp of deployment

deployed_by

string or null

ID of the API key that deployed this version

Permissions

Operation
Required Permission

Deploy

Workspace.update (admin, owner)

List, Get, Invoke

Workspace.view (read and above)

Test

Workspace.update (admin, owner)

Promote

Workspace.update (admin, owner)

Rollback

Workspace.update (admin, owner)

Last updated

Was this helpful?