Edge functions
Edge functions (PandaEdge) run small units of code on demand, invoked over HTTP. A function is your code (uploaded as a zip) plus a little metadata — timeout, memory, environment variables, and a runtime. Each function gets a stable, name-based invoke URL and keeps a full invocation history you can inspect from the dashboard, CLI, or API.
How functions work
Section titled “How functions work”- Your code lives in Google Cloud Storage, not in the database. Each upload is stored at
{organizationId}/{name}/{version}/{name}.zip. The database holds only metadata and the per-version pointer. - Every function runs inside your organization’s namespace,
org-{organizationId}. - Invocations execute on the PandaStack microVM runtime (the
pandastack.aifn-invoker service), which captures each run’s status, duration,stdout, andstderr. - Functions are versioned. Uploading new code creates a new version; metadata-only edits do not. You can roll back to any previous version without re-uploading.
Runtimes
Section titled “Runtimes”Two runtimes are supported. The runtime determines the entrypoint file PandaStack looks for inside your zip.
| Runtime | runtime value | Entrypoint file | Notes |
|---|---|---|---|
| Node.js | nodejs | index.js | Default runtime. |
| Python | python | main.py |
The entrypoint is auto-detected from the runtime — you do not configure a start command. Package
your handler as index.js (Node.js) or main.py (Python) at the root of the zip and PandaStack
finds it automatically.
Configuration
Section titled “Configuration”| Field | Type | Default | Range | Notes |
|---|---|---|---|---|
name | string | — | 1–63 chars, RFC-1123 label | Lowercase letters, numbers, hyphens. See naming below. |
runtime | enum | nodejs | nodejs | python | Chooses the entrypoint file. |
timeout | number (ms) | 60000 | 1000–900000 | Hard cap of 15 minutes. |
memory | number (MB) | 256 | 128–2048 | Informational / template-baked. |
description | string | — | ≤ 500 chars | Optional. |
env | array | [] | — | [{ "name", "value" }]. Stored as a {KEY:value} object, surfaced back as a list. |
Naming and the invoke URL
Section titled “Naming and the invoke URL”The name you choose must be a valid RFC-1123 label (regex ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$). On
create, PandaStack appends a random 6-character suffix to guarantee global uniqueness — for
example, demo becomes demo-a1b2c3. That suffixed name is what becomes the invoke-URL slug and
the GCS path segment, so the public endpoint is stable for the life of the function.
Deploying a function
Section titled “Deploying a function”Functions are always addressed by name, never by numeric id, in the invoke path. The public invoke endpoint is:
POST /v1/functions/:name/invoke
# Invoke a function by name (e.g. demo-a1b2c3)curl -X POST https://api.pandastack.io/v1/functions/demo-a1b2c3/invoke \ -H "Authorization: Bearer $PANDASTACK_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "params": { "hello": "world" } }'The request body is { "params": <object> } (defaults to {}). The response reports the run
outcome:
{ "success": true, "data": { "status": "success", "result": { "ok": true }, "error": null, "durationMs": 42, "version": 3 }}status is success or error. On failure, result is null and error carries the message;
status is error.
For the full request/response schemas of every function endpoint (create, list, versions, rollback, invocation history, metrics), see the Functions API reference.
Versions and rollback
Section titled “Versions and rollback”| Action | Creates a version? | Effect |
|---|---|---|
| Upload new code | Yes | Increments currentVersion and adds a version row. |
Edit timeout / memory / description / env | No | Metadata-only update; version unchanged. |
| Rollback | No | Re-points currentVersion to an existing version. No re-upload needed. |
Each version row records its version number and whether it is current. Rolling back is instant
because the code for older versions already lives in GCS.
Environment variables
Section titled “Environment variables”Environment variables are stored as a {KEY: value} object and surfaced in API responses as a list
of { name, value } pairs. Editing env is a metadata-only update — it does not create a new
version. Your function reads these variables from its process environment at invocation time.
The per-org function token
Section titled “The per-org function token”Each organization has a single edge-function API token used internally by the invoker. This token is only ever returned masked in API responses — the clear value is never exposed.
Invocation history and metrics
Section titled “Invocation history and metrics”Every invocation is recorded with its status (success | error), duration (ms), stdout,
stderr, and timestamp. You can page through this history and read time-bucketed metrics.
Function metrics are computed over the invocation log in 5-minute buckets across the requested window (default: the last 24 hours). They are pure Postgres aggregations — no external time-series store is involved. Each bucket reports:
| Field | Meaning |
|---|---|
timestamps | ISO bucket start times. |
invocations | Invocation count per bucket. |
errors | Error count per bucket. |
latency | Average duration (ms) per bucket; null where there were no invocations. |
Related
Section titled “Related”- Scheduled functions — run an existing function on a cron schedule.
- Cronjobs — the heavier, container-based scheduled-job option.
- Functions API reference — every endpoint with request/response schemas.
- Plans & limits — which plans include functions.