Execute
Synchronous and asynchronous execution, custom domain, scheduling, events, key scopes and logs.
A function runs in four ways: through its domain, through the SDK, on a schedule and on an event. Who can execute over HTTP and through the SDK is set in Who can execute (anyone, signed-in users or only with an API key).
Through the domain
Section titled “Through the domain”Each function responds at https://<id>.fn.owbase.dev, with any method and path: the whole request reaches req. It is the way to receive webhooks from other services and to serve a small API. These calls are synchronous. The function can also respond on your own domain, for example api.myshop.com.br: see the Custom domain guide.
Through the SDK
Section titled “Through the SDK”import { ExecutionMethod, Functions } from '@owbase/web';import { client } from './client';
const functions = new Functions(client);
// Synchronous: waits for the function's response (up to 30 s).const execution = await functions.createExecution({ functionId: '<FUNCTION_ID>', xpath: '/orders', method: ExecutionMethod.POST, headers: { 'content-type': 'application/json' }, body: JSON.stringify({ total: 120 }),});console.log(execution.responseStatusCode, execution.responseBody);Synchronous or asynchronous
Section titled “Synchronous or asynchronous”- Synchronous (default): the SDK waits and returns the response (
responseStatusCode,responseBody). The function must respond within its timeout (default 15 s, configurable up to 900 s) and within 30 s, including cold start. Through the function’s domain, the limit for a synchronous call is 60 s. - Asynchronous (
async: true): returns immediately, with the execution queued. The result is available later throughgetExecution, and the function can run up to its timeout. WithscheduledAt, the execution is scheduled for a date and time.
import { ExecutionMethod, ExecutionStatus, Functions } from '@owbase/node';import { client } from './client';
// The key needs the executions.write and executions.read scopes.const functions = new Functions(client);
// Asynchronous: returns right away, queued; the result comes later (up to the function's timeout).const queued = await functions.createExecution({ functionId: '<FUNCTION_ID>', async: true, xpath: '/report', method: ExecutionMethod.POST });
let execution = queued;while (execution.status === ExecutionStatus.Waiting || execution.status === ExecutionStatus.Processing) { await new Promise((r) => setTimeout(r, 2000)); execution = await functions.getExecution({ functionId: '<FUNCTION_ID>', executionId: queued.$id });}console.log(execution.status, execution.responseStatusCode, execution.logs);Scheduling
Section titled “Scheduling”In Settings → Schedule (cron), an expression with five fields: minute, hour, day, month and day of week. The time is UTC: 0 12 * * 1-5 runs at noon UTC (9 a.m. in Brasília) Monday to Friday. The console shows the next run.
Events
Section titled “Events”In Settings → Events, choose what triggers the function, such as users.*.create (user created), databases.*.tables.*.rows.*.create (row created) or buckets.*.files.*.create (file uploaded). In Other events you can restrict it to one resource: buckets.photos.files.*.create. The event arrives in x-owbase-event, and the resource in the request body.
Execution key scopes
Section titled “Execution key scopes”The x-owbase-key header carries a temporary key with the scopes from Settings → Execution key scopes. Grant only what the code uses (for example, rows.write and users.read).
The Executions tab lists each execution (status, trigger, method and path, HTTP code, duration). The detail shows the request, the response, the logs and the errors. Execute now runs a test execution from the console.