Skip to content
Aurabase Logo
aurabase

Edge Functions HTTP API reference

The complete HTTP surface of the functions service, with the role each route requires.

Reference10 min readLevel reference

Conventions#

Base URL. The URL of your project, for example https://my-app.aurabase.dev. The project is identified by the host, so the paths below carry no project id. The long form /v1/functions/{project_id}/… is accepted as well.

Authentication. Send your key in the apikey header. Add Authorization: Bearer <JWT> to call as a signed-in user. The Studio calls the same routes with a console session token, which gives it the admin role.

RoleHow you get itMay call
anonThe public key of the projectPOST …/invoke
authenticatedThe public key plus a user's JWTPOST …/invoke
service_roleThe service_role key (server only)Every route below
adminA console session (the Studio)Every route below

Any other route answers 403 to anon and authenticated:

{ "error": { "code": "FORBIDDEN", "type": "forbidden", "request_id": "…",
  "message": "Accès interdit : Opération réservée au rôle service_role : seule l'invocation d'une fonction est ouverte aux clés publiques" } }

Format. Bodies are JSON and need Content-Type: application/json. A success is { "data": …, "meta": null }. A failure is { "error": { "code", "message", "type", "request_id" } }.

Function object.

FieldType
id, project_id, namestring
runtime"deno" or "wasm"
codestringSource for deno; base64 of the compiled binary for wasm
code_hashstringSHA-256 of code
env_varsobjectKey to value
permissionsobjectallow_net (string array), memory_mb, timeout_secs
is_activeboolean
created_at, updated_atISO 8601

Functions#

Method and pathRoleBodyResponse
GET /v1/functionsservice_rolenonearray of function objects
POST /v1/functionsservice_role{ name, runtime, code, env_vars? }the function object
GET /v1/functions/{name}service_rolenonethe function object. {name} is the name, or the id when no function has that name.
PATCH /v1/functions/{name}service_role{ code?, env_vars?, is_active?, permissions? }the function object
DELETE /v1/functions/{name}service_rolenone{ "data": null }
GET /v1/functions/{name}/codeservice_rolenone{ "data": { "code": "…" } }
GET /v1/functions/{name}/envservice_rolenone{ "data": [ { "key", "value" } ] }, values decrypted
PUT /v1/functions/{name}/envservice_role{ "vars": [ { "key", "value" } ] }{ "data": null }

Notes:

  • POST is an upsert on name: posting an existing name replaces its code. An env_vars field in that body replaces the existing variables; omit it to keep them.
  • In PATCH, permissions is merged field by field: { "permissions": { "timeout_secs": 60 } } keeps allow_net and memory_mb. A field outside its bounds returns 400.
  • PUT …/env replaces the whole set of variables and is the only route that encrypts them. See secrets.
  • A function with is_active: false is not found by invoke or by jobs.
curl -X POST "$NEXT_PUBLIC_AURABASE_URL/v1/functions" \
  -H "apikey: $AURABASE_SERVICE_ROLE_KEY" -H "Content-Type: application/json" \
  -d '{"name":"hello","runtime":"deno","code":"Deno.serve(() => new Response(\"ok\"))"}'

Invoke#

POST /v1/functions/{name}/invoke. Role: anon, authenticated or service_role.

FieldTypeDefault
methodstringPOSTHTTP method seen by the function
pathstring/Path seen by the function
headersobjectnoneHeaders given to the function. Reserved headers are dropped.
bodyany JSONnoneBody given to the function
Request header
apikeyRequired
Content-Type: application/jsonRequired
Authorization: Bearer <JWT>Optional: call as that user
X-Aurabase-Invoke-Mode: rawOptional: return the function's own response

Default response, always 200:

{ "data": { "status": 200, "headers": { "content-type": "application/json" },
  "body": { "greeting": "Hello, Ada!" }, "logs": [], "duration_ms": 74 }, "meta": null }

status is the status of your function. logs is empty for deno. In raw mode the response is your function's own: status, content-type, bytes, plus x-aurabase-invoke-origin: function.

FailureStatuserror.code
Function not found or inactive404NOT_FOUND
Runtime unreachable503SERVICE_UNAVAILABLE
The platform stopped waiting for the runtime (after timeout_secs plus a margin)504TIMEOUT
Plan quota exhausted403QUOTA_EXCEEDED
Too many calls from one client429rate_limit_exceeded
Body above about 256 KiB503SERVICE_UNAVAILABLE

Jobs and dead-letter queue#

Method and pathRoleBody or queryResponse
POST /v1/functions/jobsservice_role{ function_name, payload?, delay_secs?, max_attempts? }the job
GET /v1/functions/jobsservice_role?status=&limit= (1 to 500, default 50)array of jobs
GET /v1/functions/jobs/{id}service_rolenonethe job
POST /v1/functions/jobs/{id}/retryservice_rolenonethe job, back to pending
GET /v1/functions/jobs/dlqservice_role?limit=array of dead jobs
POST /v1/functions/jobs/dlq/requeueservice_rolenone{ "data": { "requeued": 1 } }

Job object: id, project_id, function_name, payload, status (pending, running, completed, failed, dead), attempts, max_attempts, error, scheduled_at, started_at, completed_at, created_at. Behaviour: Jobs, cron and the dead-letter queue.

Cron#

Method and pathRoleBodyResponse
POST /v1/functions/cronservice_role{ name, schedule, function_name, payload? }the cron entry
GET /v1/functions/cronservice_rolenonearray of entries
DELETE /v1/functions/cron/{name}service_rolenone{ "data": null }, or 404 for an unknown name

Entry: id, project_id, name, schedule (stored with 6 fields), function_name, payload, is_active, last_run, next_run, created_at.

Alerts#

Method and pathRoleBody or query
POST /v1/functions/alertsservice_role{ name, metric, condition, threshold, channel, destination }
GET /v1/functions/alertsservice_rolenone
PATCH /v1/functions/alerts/{id}service_role{ "enabled": true }
DELETE /v1/functions/alerts/{id}service_rolenone
GET /v1/functions/alerts/{id}/eventsservice_role?limit=&offset=
GET /v1/functions/alerts/eventsservice_role?limit=&offset=

Values and behaviour: Alerts.

@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Report a problem