Functions API
Create, change, delete and run JavaScript functions, and read their result, logs and limits.
Functions are small JavaScript programs that run inside AxisIQ and can read and write your workspace data. This API manages them and runs them on demand. To write the code itself, see the Functions SDK. To call a function from the public internet, see Public endpoints.
Endpoints
| Method | Path | Permission | What it does |
|---|---|---|---|
GET |
/orgs/{orgId}/functions |
functions:read |
List functions |
POST |
/orgs/{orgId}/functions |
functions:create |
Create a function |
GET |
/orgs/{orgId}/functions/{fnId} |
functions:read |
Get a function, including its code |
PUT |
/orgs/{orgId}/functions/{fnId} |
functions:create |
Change a function |
DELETE |
/orgs/{orgId}/functions/{fnId} |
functions:create |
Delete a function |
DELETE |
/orgs/{orgId}/functions/{fnId}/draft |
functions:create |
Discard the draft |
GET |
/orgs/{orgId}/functions/{fnId}/versions |
functions:read |
Published versions, newest first |
GET |
/orgs/{orgId}/functions/{fnId}/versions/{version} |
functions:read |
One version, with its code |
POST |
/orgs/{orgId}/functions/{fnId}/versions/{version}/rollback |
functions:create |
Publish an earlier version again |
POST |
/orgs/{orgId}/functions/{fnId}/invoke |
functions:invoke |
Run a function |
GET |
/orgs/{orgId}/functions/stats |
functions:read |
Run counts and failures per function |
GET |
/orgs/{orgId}/functions/{fnId}/invocations |
functions:read |
A function's run history |
GET |
/orgs/{orgId}/functions/{fnId}/invocations/{invId} |
functions:read |
One run, with logs, input and output |
POST |
/orgs/{orgId}/functions/{fnId}/invocations/{invId}/replay |
functions:read + functions:invoke |
Run a past run's input again, as you |
GET |
/orgs/{orgId}/functions/secrets |
functions:read |
List secret names (never values) |
PUT |
/orgs/{orgId}/functions/secrets/{name} |
functions:create |
Create or replace a secret |
DELETE |
/orgs/{orgId}/functions/secrets/{name} |
functions:create |
Delete a secret |
If the Functions app is switched off in Settings › Apps, these routes answer 404 NOT_FOUND.
The function object
{
"id": "0190f0ee-…",
"name": "Tag overdue invoices",
"description": "Marks open invoices past their due date",
"source": "async function handler(input) {\n …\n}",
"timeout_ms": 5000,
"enabled": true,
"http_enabled": false,
"version": 3,
"draft": { "source": "…", "updated_by": "…", "updated_at": "2026-10-05T10:00:00Z" },
"created_at": "2026-10-01T08:00:00Z",
"updated_at": "2026-10-04T09:00:00Z"
}
POST /orgs/{orgId}/functions
| Field | Type | Required | Notes |
|---|---|---|---|
name |
string | Yes | Up to 120 characters |
description |
string | No | Up to 500 characters |
source |
string | Yes | JavaScript, up to 256 KB. It must define a global function named handler |
timeout_ms |
number | No | 100 to 30,000. Default 5,000. Values outside the range are brought into it |
http_enabled |
boolean | No | When true the function can be called from the public internet. See Public endpoints |
curl -s -X POST https://axisiq.co/api/v1/orgs/$ORG/functions \
-H "Authorization: Bearer $AXIS_KEY" -H "Content-Type: application/json" \
-d '{
"name": "Count open invoices",
"source": "function handler(input) {\n var r = axis.records.search(\"invoices\", { filters: [{ field: \"status\", op: \"eq\", value: \"open\" }], limit: 1 });\n return { open: r.total };\n}"
}'
Response 201 with the function object. New functions are enabled.
PUT /orgs/{orgId}/functions/{fnId}
Send any of name, description, source, timeout_ms, enabled, http_enabled, error_status (boolean) and test_inputs (the whole list of saved inputs: up to 20 { "name", "input" }, names unique and up to 60 characters, each input up to 16 KB of JSON). Fields you leave out are unchanged. Response 200 with the function object.
Drafts and publishing
source is the published code — the only code anything runs: the public address, flows, forms, queues, schedules, replays and invoke. A PUT with a changed source saves it as the function's draft and changes nothing that runs; sending the published code back clears the draft. Add "publish": true (with or without a source) to make the draft live as the next version. draft is null when there is none. name, description, timeout_ms, enabled, http_enabled and error_status take effect at once and are not versioned.
Important: Publishing makes you the function's author. When a flow, a queue button or a form runs the function later, it uses the fewer permissions of the trigger's owner and the author, so editing someone else's function cannot be used to borrow their access.
DELETE /orgs/{orgId}/functions/{fnId}
Returns 204 No Content.
POST /orgs/{orgId}/functions/{fnId}/invoke
Run a function now, with the caller's permissions. Permission: functions:invoke.
| Field | Type | Required | Notes |
|---|---|---|---|
input |
any JSON | No | Passed to handler as its argument. Absent means null |
draft |
boolean | No | Run the saved draft instead of the published code. Needs functions:create; the run is recorded with trigger draft |
curl -s -X POST https://axisiq.co/api/v1/orgs/$ORG/functions/$FN/invoke \
-H "Authorization: Bearer $AXIS_KEY" -H "Content-Type: application/json" \
-d '{"input": {"since": "2026-10-01"}}'
Response 200
{
"data": {
"result": { "open": 17 },
"logs": [ { "level": "log", "msg": "checked 17 invoices" } ],
"steps": [ { "method": "records.search", "is_error": false } ],
"duration_ms": 38,
"timed_out": false
}
}
| Field | Meaning |
|---|---|
result |
What handler returned, as JSON. null when it returned nothing |
logs |
Output from console.log, info, warn and error |
steps |
Each SDK call the function made, and whether it failed |
duration_ms |
Run time |
timed_out |
True when the function hit its timeout |
error |
Present only when the function threw or did not finish. The text is the error message |
Note: A function that throws or times out still answers HTTP 200, with
errorset. Checkerrorandtimed_outin the body, not just the status — unless the function haserror_statuson. Then such a run answers 500FUNCTION_ERROR, with the same outcome object undererror.result, so an uptime monitor sees the failure. This applies toinvokeandreplay.
Errors
| Status | Code | When |
|---|---|---|
| 400 | VALIDATION_ERROR |
The function is disabled |
| 403 | FORBIDDEN |
The key lacks functions:invoke |
| 404 | NOT_FOUND |
No such function |
Run history
GET /orgs/{orgId}/functions/{fnId}/invocations lists runs newest first.
| Parameter | Notes |
|---|---|
status |
ok, error or timed_out |
limit |
Up to 100 |
before |
The next_cursor from the previous page |
Returns { "data": { "invocations": [ … ], "next_cursor": "…" } }. Each run has id, fn_id, trigger (manual, draft, replay, agent, http, flow, queue or form), invoked_by, status, duration_ms, error and created_at.
GET /orgs/{orgId}/functions/stats?days=7 sums runs per function over the last days (1 to 90, default 7): { "data": { "stats": [ { "fn_id", "runs", "errors", "timed_out", "avg_ms", "last_run_at" } ] } }. A function with no runs in the window is left out.
GET …/invocations/{invId} adds logs, input, output (as text, possibly shortened) and truncated.
POST …/invocations/{invId}/replay re-runs that run's stored input under your own permissions and answers like invoke. It is refused with 400 when the input was cut short in history or the run is more than 14 days old. Logs, input and output are kept for 14 days; secret values are masked in all of them.
Versions
Every publish stores an immutable version; the newest 50 are kept. Functions start at version 1.
GET …/versions→[{ "version": 3, "published_by": "…", "published_by_name": "Alex Morgan", "published_at": "…" }], newest first.GET …/versions/{version}→ the same plussource.POST …/versions/{version}/rollbackpublishes that version's code again as a new version and returns the function. A draft is left alone. You become the author.DELETE …/draftdiscards the draft and returns the function.
An unknown version is 404 NOT_FOUND.
Secrets
Secrets are read by every function as axis.env.NAME (see Functions SDK).
GET …/functions/secretsreturns[{ "name", "updated_by", "updated_at" }]. A value is never returned.PUT …/functions/secrets/{name}with{ "value": "…" }creates or replaces it and answers204. Names match^[A-Z_][A-Z0-9_]{0,63}$; values up to 8 KB; up to 100 secrets per workspace.DELETE …/functions/secrets/{name}removes it.
Run history and secrets answer 404 until the workspace has taken the update that adds them.
Limits
| Limit | Value |
|---|---|
| Run time | The function's timeout_ms, at most 30 seconds |
| Memory | 128 MB per run |
| Console output | 1,000 lines or 256 KB per run |
| SDK calls | 10,000 per run |
| Concurrent runs | 4 at a time per workspace, the rest wait |
| Source size | 256 KB |
Related
- Functions SDK
- Public endpoints
- In the product: Functions