Aurabase Logo
aurabasedocs
docs›Edge Functions›SDK reference

JavaScript SDK: functions

Every method of `aura.functions`, its signature, the role it needs and what it returns.

8 min read·Level reference·Revised on Oct 12, 2026
This English text was generated automatically from the French original and has not been reviewed yet.
#
Setup

1. Get the client

aura.functions is a FunctionsService. You almost never build it yourself.

client.tstypescript
import { createClient } from '@aurabase/aurabase-js'

const aura = createClient('https://my-app.aurabase.cloud', 'aura_anon_…')
aura.functions.invoke('hello')

The package @aurabase/functions is installed with @aurabase/aurabase-js. Install it alone only if you compose your own client from @aurabase/core. It requires Node.js 20 or later and ships ES modules and CommonJS with type declarations.

Every method returns Promise<AuraResponse<T>>, an object { data, error } that never throws:

Casedataerror
Successthe valuenull
Success without content (204, empty body)nullnull
Failurenullan AuraError

Test data rather than error when you need the value: only then does TypeScript know it is not null.

MethodRole needed
invokepublic key (anon), user, or service_role
every other methodservice_role (server only)
#
Call

2. invoke

signaturetypescript
invoke<T = unknown>(
  name: string,
  options?: {
    body?: unknown
    method?: string
    path?: string
    headers?: Record<string, string>
    signal?: AbortSignal
    timeout?: number
    responseType?: 'json' | 'text' | 'blob' | 'arrayBuffer'
  },
): Promise<AuraResponse<T>>
OptionDefault
bodynoneJSON-serialisable. A Blob, ArrayBuffer, typed array, FormData, URLSearchParams or ReadableStream returns the error invalid_body without any request.
method'POST'The method the function sees
path'/'The path the function sees
headersnoneHeaders given to the function. authorization, apikey, x-request-id and x-aura-* are discarded by the platform.
timeoutclient default, 30 sMilliseconds. Cancels the call and returns the code timeout.
signalnoneYour own AbortSignal. A cancelled call returns the code timeout.
responseType'json'How data is decoded: a parsed value, a string, a Blob or an ArrayBuffer

name is encoded in the URL, so a value containing /, ? or # cannot leave its position. A name that contains such characters simply is not found.

invoke refreshes an expired user session first, sends the user's JWT when there is one, and never retries a call.

How to use it: Invoke a function. How it fails: Errors, timeouts and retries.

#
Manage

3. list and get

signaturestypescript
list(): Promise<AuraResponse<FunctionDef[]>>
get(nameOrId: string): Promise<AuraResponse<FunctionDef>>

Both need a service_role key. get accepts the name or the id; if a function is named like an id, the name wins. A FunctionDef contains the source code and the variables of the function, which is why a public key receives 403.

There is no method to deploy, update or delete a function, or to write secrets: use the HTTP API or the CLI.

#
Background

4. Jobs

signaturestypescript
enqueueJob(
  functionName: string,
  options?: { payload?: unknown; delaySecs?: number; maxAttempts?: number },
): Promise<AuraResponse<Job>>

listJobs(options?: { status?: string; limit?: number }): Promise<AuraResponse<Job[]>>
getJob(jobId: string): Promise<AuraResponse<Job>>
  • enqueueJob returns { code: 'bad_request', status: 400 } without any request when functionName is empty or only spaces, and trims the name otherwise.
  • listJobs filters on status (pending, running, completed, failed, dead) and returns between 1 and 500 jobs, 50 by default.
  • Retrying dead jobs has no method: see the dead-letter queue.
#
Schedule

5. Cron

signaturestypescript
listCronJobs(): Promise<AuraResponse<CronJob[]>>
createCronJob(
  name: string,
  schedule: string,
  functionName: string,
  options?: { payload?: unknown },
): Promise<AuraResponse<CronJob>>
deleteCronJob(name: string): Promise<AuraResponse<null>>

schedule has 5 or 6 fields, in UTC. deleteCronJob takes the name, and returns 404 for an unknown name. There is no getCronJob or updateCronJob.

#
Reference

6. Types and errors

Exported by @aurabase/aurabase-js and @aurabase/functions:

importstypescript
import {
  FunctionsHttpError,
  FunctionsRelayError,
  isRelayStatus,
  type FunctionsResponseType,
} from '@aurabase/aurabase-js'
ExportWhat it is
FunctionsHttpErrorYour function (or a management route) answered with an error. error.context holds the body it returned.
FunctionsRelayErrorThe platform failed: network (status 0) or 502, 503, 504 produced by the gateway or the runtime.
isRelayStatus(status)true for 0, 502, 503, 504.
FunctionsResponseType'json' | 'text' | 'blob' | 'arrayBuffer'

Both error classes extend AuraError, so isAuraError(error) is true. AuraError has status, code, message, details, retryAfter, and the getters isNotFound, isUnauthorized, isForbidden and isRateLimited.

Data types, exported by @aurabase/aurabase-js:

TypeFields
FunctionDefid, project_id, name, runtime, code, code_hash, env_vars, permissions, is_active, created_at, updated_at
FunctionPermissionsallow_net: string[], memory_mb: number, timeout_secs: number
Jobid, project_id, function_name, status, payload, attempts, max_attempts, error?, scheduled_at, started_at?, created_at, completed_at?
CronJobid, project_id, name, schedule, function_name, payload, is_active, last_run?, next_run?, created_at
AuraResponse<T>{ data, error, meta? }
Backward-compatible properties

When a function returns a JSON object, data also carries two non-enumerable properties, body and status, kept for code written against older versions. Do not rely on them in new code.

Last updated · Oct 12, 2026