Skip to content

This page is for developers who need logic the no-code tools cannot express: calling an external service, a calculation, a custom validation. You write a small TypeScript function, upload it, and the platform builds it, deploys it and calls it when an automation runs, when a record is saved, or when a request comes in.

You need…Use
To react to an event with built-in actions (create a record, send an email, call a URL)A reaction — no code
A computed field, a dynamic value, a template tokenThe built-in expression engine — no deployment
Your own code, external network calls, or heavier computationA function

A reaction can call a function when it needs custom logic, so the two combine well.

  • A function is a record in Administration › Applications › Functions. Its source is a ZIP file you upload.
  • When you save it, the platform builds the source and deploys it as a serverless service inside the cluster. Its Status moves from Provisioning to Provisioned (or Build failed), and its URL is filled in. Only then can it be called.
  • The platform calls it over HTTP using the CloudEvents format and reads the JSON you return.
  • Uploading new source rebuilds it; archiving the record removes the deployment.

A function has one of four Types, which decides who calls it and with what:

TypeCalledIt receivesIt returns
Reaction Custom ActionBy a reaction’s Execute Function action{ context, parameters }Any JSON object; later actions can use it
Standalone ValidatorWhen a record is saved, edited or archived{ dataEntry, existingEntry }{ success, errors?: [{ errorCode }] }
Value ValidatorWhen a field value is saved{ value }{ success, errors?: [{ errorCode }] }
InterceptorBefore a matching incoming request is handledThe request’s method, path, query, headers and bodyA rewritten request, or a response of its own

A function is a Knative Functions TypeScript project. Its folder looks like this:

my-function/
├── func.yaml # required
├── params.yaml # optional: the parameters a reaction can map
├── package.json
├── tsconfig.json # compiles src/ to build/
└── src/
└── index.ts # exports handle()
specVersion: 0.36.0
name: order-total # replaced by the platform's deployed name (Since 1.10)
runtime: typescript
build:
builder: pack
buildEnvs:
- name: BP_NODE_RUN_SCRIPTS
value: build

The platform deploys your function under a name it derives from the record, so the name here does not decide the deployed name Since 1.10. It also makes every function private to the cluster; you never get a public URL for it.

Declare the inputs a builder maps in the Execute Function action:

version: "1"
parameters:
- name: amount
- name: currency

The platform reads the names when it deploys the function and offers them in the action. They describe inputs; they do not validate them.

{
"name": "order-total",
"version": "1.0.0",
"scripts": {
"build": "npx -p typescript tsc",
"start": "faas-js-runtime ./build/index.js"
},
"dependencies": {
"cloudevents": "^9.0.0",
"faas-js-runtime": "^2.4.0"
},
"devDependencies": {
"typescript": "^5.5.2"
}
}

This function receives an amount and a currency mapped by the reaction, applies VAT, and returns a result that later actions in the same reaction can use:

src/index.ts
import { Context } from 'faas-js-runtime';
interface Input {
context?: unknown; // the event that triggered the reaction
parameters?: { amount?: string | number; currency?: string };
}
const handle = async (context: Context) => {
// The platform sends a CloudEvent; depending on its mode the payload is the body
// itself or the body's `data` property.
const body = (context.body ?? {}) as { data?: Input } & Input;
const input: Input = body.data ?? body;
const amount = Number(input.parameters?.amount);
if (!Number.isFinite(amount)) {
return { success: false, message: 'amount must be a number' };
}
const vat = Math.round(amount * 0.05 * 100) / 100;
return {
success: true,
message: 'VAT calculated',
result: { net: amount, vat, gross: amount + vat, currency: input.parameters?.currency ?? 'AED' },
};
};
export { handle };
  • Return a JSON object. The platform parses your answer as JSON. An answer sent as plain text is treated as an error.
  • Keep the shape stable. Since 1.10 later actions and chained reactions can bind success, message and any key under result (for example result.gross) — see Execute Function output. If you rename a key, those bindings break.
  • Report failures in the body. The action is recorded as run whenever your function answers; return success: false so later actions can tell.

A standalone validator returns error codes; the platform shows the message you entered for each code in the function’s Errors list. Answer success: true and put the verdict in result — a top-level success: false means the function itself failed, and the save fails with a technical error instead of your message:

src/index.ts
import { Context } from 'faas-js-runtime';
const handle = async (context: Context) => {
const body = (context.body ?? {}) as any;
const { dataEntry } = body.data ?? body;
const end = new Date(dataEntry?.value?.end_date);
const start = new Date(dataEntry?.value?.start_date);
if (end < start) {
return { success: true, result: { success: false, errors: [{ errorCode: 'END_BEFORE_START' }] } };
}
return { success: true, result: { success: true } };
};
export { handle };

A value validator works the same way and receives { value }.

Terminal window
npm install
npm run build
npm start # serves the function on http://localhost:8080
curl -s -X POST http://localhost:8080 \
-H 'Content-Type: application/json' \
-d '{"parameters": {"amount": 200, "currency": "AED"}}'

The runtime also answers health checks on /health/readiness and /health/liveness.

Create a ZIP with func.yaml at its root, next to package.json and src/. Leave out node_modules and build; the platform installs and builds when it deploys.

Terminal window
cd my-function && zip -r ../order-total.zip . -x 'node_modules/*' 'build/*'

Only ZIP uploads are deployed. Any other source is ignored without an error.

  1. Open Administration › Applications › Functions, then select Add function.
  2. Enter a Name, choose the Type and the Function Scope (System, Module or Entity).
  3. Leave Provisioning Type on Internal (the default, with the ZIP option) and upload the ZIP in Function Zip File.
  4. Save. The Status shows Provisioning while the platform builds.
  5. When the status is Provisioned and a Function URL appears, the function is ready. If it shows Build failed, read Provisioning Error, fix the source, and upload a new ZIP.

For a validator, add each error code you return, with its message, under Errors.

You need the system Admin level to manage functions.

  1. Make sure the function is Provisioned.
  2. A builder opens the entity’s Reactions tab, adds a reaction, and chooses the event.
  3. They add the Execute Function action, choose the function, and map a value to each parameter from params.yaml.

Reactions and their actions are covered in Reactions & automation.

You can also run a provisioned function from your own code:

Terminal window
curl -s -X POST "https://acme.example.com/api/functions/v1/<function-id>/execute" \
-H "Authorization: Bearer <access-token>" \
-H "Content-Type: application/json" \
-d '{"parameters": {"amount": 200, "currency": "AED"}}'

The call needs a credential Since 1.10. It answers your function’s JSON, or { "success": false, "error": … } when the function failed or did not answer with JSON. A function that is missing, not active or not provisioned is refused with 404 or 400. To list the functions available in a scope, call GET /api/functions/v1/{scope} (SYSTEM, MODULE or ENTITY, with ?scopeId= for the last two); only provisioned, active functions are listed.

A validator function runs only where a builder attaches it to an entity:

  • A Standalone Validator checks the record’s whole value. When it runs — before the record is saved, edited or archived — is chosen when it is attached. It only applies to records of the entity in its scope.
  • A Value Validator checks a single field value when the record is saved.
  • The first validator that returns errors stops the save. Each errorCode is looked up in the function’s Errors list to show its message; for a value validator the error is attached to the field.

The builder’s side, with worked examples, is in Block a save with a validation function.

An Interceptor function runs before an incoming request that matches its path and HTTP method is handled. It can return a rewritten request — body, headers, query — or answer the request itself, so it never reaches the platform. Only the before-handling stage exists, and interceptors fail open: if one fails or answers something unreadable, it is skipped and the request continues.

  • Each tenant’s functions are isolated. In a multi-tenant deployment every tenant has its own space in the cluster, so two tenants’ functions with the same name never collide.
  • The deployed name comes from the record, not from func.yaml: a short form of the function’s normalized name plus part of its id, for example order-total-e93838fe1c2d. It stays the same when you rename the function.
  • Archiving deletes the deployment.
  • The build and its callbacks are secured by the operator. How the platform authenticates to the function builder, and how the builder’s status callbacks are verified, are deployment settings — see Functions in a multi-tenant deployment and, for the mechanics, Functions — internals.

Since 1.10 every function receives its tenant’s address in its environment:

VariableValue
OSOS_API_BASE_URLThe tenant’s API, for example https://acme.example.com/api
APP_IDThe tenant’s id

Always build URLs from OSOS_API_BASE_URL; never hard-code a host. A tenant with no public host gets its function without this variable.

On the 1.10 line a function has no credential of its own, and the platform keeps no secrets for it: nothing in its environment lets it call the API, and the function record has no secrets list. Both arrive on the development line, described below.

On the development line every function also receives OSOS_API_TOKEN, the API token of its own application user. The function calls the API as itself:

const res = await fetch(`${process.env.OSOS_API_BASE_URL}/v2/entities/orders/entries/count`, {
headers: { 'x-app-token': process.env.OSOS_API_TOKEN ?? '' },
});
const { result } = await res.json();
  • The function’s user starts with no access. A tenant administrator grants it exactly what it needs, like any application user — see Use an API token and, for the administrator, Create an API token — Step 2.
  • Re-uploading the ZIP does not change the token.
  • When an administrator regenerates the token, the new one goes straight to the function, which restarts with it; the old one keeps working for the usual grace period. It is never emailed.
  • Archiving the function archives its user, so the token stops working (after the gateway’s short cache time).

On the development line, a function record has a Secrets list: one row per secret, with a key and a value. Each value reaches the running function as an environment variable named by its key:

const apiKey = process.env.PAYMENT_API_KEY;
  • Values are stored encrypted and shown masked. Nobody can read them back, including administrators.
  • Change a value by entering a new one; saving the masked value unchanged keeps it. Delete a secret by removing its row.
  • A change takes effect on a new revision. The platform updates the secret and restarts the function without rebuilding it; a running instance keeps the old value until then.
  • Packages carry names, not values. Exporting a function keeps its secret keys and drops the values. After installing a package, fill the values in on the target; an installed function lets you change existing secret values, and nothing else.

A save that breaks a rule is refused with 422:

CodeWhen
FUNCTION_SECRET_KEY_INVALIDA key is not a valid environment-variable name (letters, digits and _, not starting with a digit).
FUNCTION_SECRET_KEY_DUPLICATETwo rows use the same key.
FUNCTION_SECRET_KEY_RESERVEDThe key is set by the platform: APP_ID, OSOS_API_BASE_URL, PORT, K_SERVICE, K_CONFIGURATION, K_REVISION.
FUNCTION_SECRET_SYSTEM_MANAGEDYou added, changed or removed the OSOS_API_TOKEN row.
FUNCTION_IDENTITY_SYSTEM_MANAGEDYou set the function’s identity.

Size limits are checked when the function is deployed, not when you save: each KEY=value at most 131071 bytes, all secrets together at most 1 MiB, and no NUL character. If they are exceeded, or the secrets cannot be delivered, Provisioning Error shows one of:

CodeMeaning
IDENTITY_UNAVAILABLEThe function’s user could not be created; nothing was deployed.
SECRETS_SYNC_FAILEDThe secrets could not be delivered before the deploy; nothing was deployed.
SECRETS_UPDATE_FAILEDA secrets change could not be delivered to the running function; the platform retries.

None of these messages contains a secret value.

For logic that does not need a deployment — computed fields, dynamic values, conditional targets, template tokens — use the built-in, sandboxed expression engine. A field can take its value from an expression or a pointer, recalculated when the form opens, on save, when the record changes, or when chosen fields change. Two calls resolve expressions from code:

  • POST /api/v1/entities/{entityId}/expressions/resolve — an entity-level expression;
  • POST /api/v1/entities/{entityId}/{entryId}/tokens/resolve — tokens for one record.
  • TypeScript and ZIP only. Other languages and source types (such as a GitHub repository) are not deployed.
  • Only new source redeploys. Editing other fields of the function record does not rebuild it. Since dev a secrets change restarts it without a rebuild.
  • Deployment is asynchronous. Until the status is Provisioned, the function cannot be listed or run.
  • Functions are private to the cluster. They are reached only through the platform.
  • Isolation comes from the serverless runtime, not from the platform: a function runs as its own service.

The status never reaches Provisioned. The platform’s function builder may not be set up in this deployment; in that case saving a function does nothing. Ask your operator.

The status is Build failed. Read Provisioning Error. Common causes: func.yaml missing or invalid at the ZIP root, a runtime other than typescript, or a build error in your code. Run npm run build locally first.

The reaction runs but later actions get nothing. Check that your handler returns JSON (not text), and that the keys the builder bound under result exist in your answer.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27