Compute / Serverless functions
Serverless functions
Run code on each request to its own HTTPS URL, on a schedule or from the API. It scales with traffic, down to nothing when idle, and is billed per request and run time.
What a function is
A function is a piece of your code with its own address, https://<random>.fn.pantechdynamics.com. Each request to that address runs your handler, which gets the request as an event and returns the response. You don't run or patch a server: functions start when called, run as many copies as the traffic needs, and stop after 10 minutes without a call, when they cost nothing.
Use them for webhooks, small HTTP APIs, scheduled jobs (reports, clean-ups, syncs), and glue between services. For long-running processes, anything holding a connection open for more than 15 minutes, or software you need to control the server for, use a virtual machine.
| Runtimes | Node.js 24 and 22, Python 3.14, 3.13 and 3.12, Bun 1.3 (TypeScript and JavaScript), Go 1.25, Ruby 3.3, PHP 8.4 (all ids) |
| Code | One file up to 256 KiB, or a zip of a folder up to 25 MiB (250 MiB unpacked) |
| Dependencies | package.json, requirements.txt, go.mod, Gemfile or composer.json in the zip, installed when the function builds |
| Memory | 128, 256, 512, 1024 or 2048 MiB; 1 vCPU up to 1024 MiB, 2 vCPU at 2048 MiB |
| Timeout | 1 to 900 seconds per request (default 30) |
| Requests and responses | Up to 6 MiB each |
| Environment variables | Up to 4 KiB in all; values marked secret are stored encrypted and never shown again |
| Concurrency | Up to 50 calls at once per function (default 10) |
| Zone | af-abj-1, Abuja |
Create a function in the console
- Go to Compute → Serverless functions and press Create function.
- Give it a name (lowercase letters, digits and hyphens), pick the zone, and choose Who can call it: Callers with a key (the default) or Anyone with the URL.
- Pick the language by its logo, then its version. The code box starts with a working handler in that language; change it, or switch Code to Upload a zip.
- Add any environment variables.
- Press Create and deploy.
The function page opens while the first version builds, usually in under a minute. When it says the version is serving, the URL answers. If the build fails, the version shows why (a missing handler, a syntax error, a Go compile error, a dependency that would not install) and the URL keeps answering with whatever served before.
Runtimes
| Language | Runtime id | Handler (default) | Dependencies |
|---|---|---|---|
| Node.js 24 | nodejs24 | file.export (index.handler) | package.json |
| Node.js 22 | nodejs22 | file.export (index.handler) | package.json |
| Python 3.14 | python3.14 | module.function (main.handler) | requirements.txt |
| Python 3.13 | python3.13 | module.function (main.handler) | requirements.txt |
| Python 3.12 | python3.12 | module.function (main.handler) | requirements.txt |
| Bun 1.3 | bun1.3 | file.export (index.handler); .ts files run as they are | package.json |
| Go 1.25 | go1.25 | main.Name, an exported function of package main (main.Handler) | go.mod |
| Ruby 3.3 | ruby3.3 | file.method (handler.handler) | Gemfile |
| PHP 8.4 | php8.4 | file.function (index.handler) | composer.json |
A handler's file may sit in a folder of the zip: src/api.handler is the handler function of src/api.mjs (or .js, .ts, .rb, .php). In Python it is a dotted module path instead, app.api.handler for app/api.py. Go has no files in its handler: the code is the zip's root package. Every runtime runs on Linux x86-64. Each version is its own runtime: move to a newer one by deploying with it, and roll back the same way.
Write a handler
The handler receives the event and a context, and returns a response with a status, headers and body.
export async function handler(event, context) {
const name = event.query?.name ?? "world";
return {
status: 200,
headers: { "content-type": "application/json" },
body: JSON.stringify({ hello: name, path: event.path }),
};
}Handler: index.handler (file.export).
import json
def handler(event, context):
name = (event.get("query") or {}).get("name", "world")
return {
"status": 200,
"headers": {"content-type": "application/json"},
"body": json.dumps({"hello": name, "path": event.get("path")}),
}Handler: main.handler (module.function). async def works too.
type Event = { path: string; query?: Record<string, string> };
export async function handler(event: Event) {
const name = event.query?.name ?? "world";
return {
status: 200,
headers: { "content-type": "application/json" },
body: JSON.stringify({ hello: name, path: event.path }),
};
}Handler: index.handler (file.export). TypeScript runs as written, with no build step of yours; JavaScript files work too.
package main
import (
"context"
"encoding/json"
)
type Event struct {
Path string `json:"path"`
Query map[string]string `json:"query"`
}
func Handler(ctx context.Context, raw json.RawMessage) (any, error) {
var event Event
if err := json.Unmarshal(raw, &event); err != nil {
return nil, err
}
name := event.Query["name"]
if name == "" {
name = "world"
}
body, _ := json.Marshal(map[string]string{"hello": name, "path": event.Path})
return map[string]any{
"status": 200,
"headers": map[string]string{"content-type": "application/json"},
"body": string(body),
}, nil
}Handler: main.Handler. The function must have exactly this signature: func(ctx context.Context, event json.RawMessage) (any, error). The code is package main with no func main (the build adds one) and is compiled once, when the function builds, into a static binary (CGO_ENABLED=0), so a request never waits for a compiler. ctx is cancelled at the call's deadline. A returned error, or a panic, is a handler error (502).
require "json"
def handler(event:, context:)
name = (event["query"] || {})["name"] || "world"
{
status: 200,
headers: { "content-type" => "application/json" },
body: JSON.generate(hello: name, path: event["path"])
}
endHandler: handler.handler (file.method). def handler(event, context) works too. Event keys are strings.
<?php
function handler($event, $context)
{
$name = $event['query']['name'] ?? 'world';
return [
'status' => 200,
'headers' => ['content-type' => 'application/json'],
'body' => json_encode(['hello' => $name, 'path' => $event['path'] ?? null]),
];
}Handler: index.handler (file.function). The event is an associative array. PHP 8.4 with the curl, mbstring, xml and zip extensions; with Composer packages, vendor/autoload.php is loaded for you.
The event for a request to the URL:
| Field | |
|---|---|
method | GET, POST and so on |
path | The path, such as /orders/42 |
query | The query string as a map |
headers | Request headers, names in lowercase. A function key the caller sent is removed first |
body | The body as a string; base64 when is_base64 is true (binary uploads) |
is_base64 | Whether body is base64 |
source_ip | The caller's address |
request_id | The call's id, also in the logs and the X-Request-Id response header |
The response: status (default 200), headers, and body as a string, or base64 with is_base64: true for binary. Handlers written for other serverless platforms work unchanged: statusCode and isBase64Encoded are read too.
The context: function_id, version, request_id, memory_mib, deadline_ms (when the call is stopped, in Unix milliseconds) and remaining_ms(); in Ruby and PHP these are methods and properties of context. In Go, ctx carries the deadline, and FunctionRequest(ctx) (added to your package by the build) returns the request id, function id, version, memory and deadline.
What the handler prints (console.log, print, fmt.Println, puts, echo or error_log) goes to the function's logs. An uncaught error answers 502 and a call past its timeout 504, both with the request id and never the stack trace.
Call it
Copy the URL from the function's page; the page also shows a curl example.
$ curl https://k3j9x2m8q1w7e4r5.fn.pantechdynamics.com/?name=Ada{"hello":"Ada","path":"/"}Protected functions. With Callers with a key, create a key under Keys on the function page. It is shown once; store it like a password. Callers send it in either header:
$ curl -H "Authorization: Bearer pfk_..." https://<slug>.fn.pantechdynamics.com/$ curl -H "X-Function-Key: pfk_..." https://<slug>.fn.pantechdynamics.com/Revoking a key refuses it at once. Switch a function between public and protected at any time from the button at the top of its page.
Test from the console. The function page's Test card sends an event you write to the function and shows what it returned, the outcome, how long it took and what it printed. From the API it is POST /public/v1/functions/{function_id}/invocations with the event as the body (API reference).
Environment variables and secrets
Add variables when you create or deploy: a name (letters, digits and underscores, not starting with a digit or PANTECH_) and a value. Read them as process.env.NAME in Node.js and Bun, os.environ["NAME"] in Python, os.Getenv("NAME") in Go, ENV["NAME"] in Ruby, or getenv('NAME') in PHP.
Turn on Secret for API keys, passwords and tokens. A secret is stored encrypted, given only to the function as it runs, and never shown again, in the console or the API. Because of that, deploying again asks you to type each secret's value again (or remove the variable).
Variables belong to a version: changing one is a new deploy, and rolling back brings back that version's variables.
Upload a zip with dependencies
For more than one file, or for packages:
- Put your code at the top of a folder, with its dependency file:
package.json(and its lock file) for Node.js and Bun,requirements.txtfor Python,go.mod(andgo.sum) for Go,Gemfile(andGemfile.lock) for Ruby, orcomposer.json(andcomposer.lock) for PHP. - Zip the folder's contents, not the folder itself:
cd my-function && zip -r ../my-function.zip . - On create or Deploy new code, choose Code → Upload a zip, pick the file, and set the handler to the file and function inside the zip.
The build installs the dependencies and loads your handler once:
| Runtime | The build runs |
|---|---|
| Node.js | npm ci, or npm install without a lock file |
| Bun | bun install --production |
| Python | pip install -r requirements.txt |
| Go | go mod tidy (and go mod init without a go.mod), then go build |
| Ruby | bundle install |
| PHP | composer install --no-dev |
Packages come from the public registries (npm, PyPI, the Go module proxy, RubyGems, Packagist); private registries are not supported yet. Packages that compile native code need it to build on Linux x86-64; Go builds with cgo off. Loading the handler at build time means a missing file, export or import (or, in Go, a compile error) fails the build with the runtime's message rather than failing your first request. Dependencies already inside the zip work too. A zip may hold only files and folders: no links, and nothing that unpacks outside it.
Versions and rolling back
Every deploy is a new numbered version with its own code, runtime, handler, memory, timeout and variables. The version serving keeps serving while a new one builds, and if the build fails. Under Versions, Serve switches back to an earlier ready version at once, with nothing rebuilt.
Run asynchronously
To hand a function work and not wait for it, send the event to its async endpoint. It is accepted at once (202), and the function runs it shortly after:
$ curl -X POST "https://api.pantechdynamics.com/public/v1/functions/fn_.../async-invocations?max_retries=2" \ -H "Authorization: Bearer $PANTECH_API_KEY" -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" -d '{"order_id": 42}'{"id":"fna_...","status":"queued","attempts":0,"max_retries":2,"max_event_age_seconds":21600,...}- Retries. If the handler fails (throws, crashes or times out), it is tried again after one minute, then after two.
max_retriessets how many retries, 0 to 2 (default 2). A call that cannot reach the handler, because the function is at its concurrency limit, busy or not serving yet, waits 30 seconds and tries again without using a retry. - Maximum age. An invocation still not done after
max_event_age_seconds(60 to 21600, default 6 hours) expires. - Failures. When an invocation fails on every attempt, or expires, your organization's webhooks subscribed to
function.async_invocation_failedget an event naming it. That is where to alert, or to queue the work again. - Status.
GET /public/v1/functions/{function_id}/async-invocations/{invocation_id}shows its status (queued,succeeded,failedorexpired), attempts, and the last attempt's outcome and request id; the attempt's printed lines are in the function's logs under that id.GET …/async-invocationslists them, newest first. Finished invocations are kept for 7 days. - Limits. The event is any JSON value up to 256 KiB. Send an
Idempotency-Key: a retried request with the same key returns the same invocation instead of queuing it twice. A function can have up to 10,000 invocations waiting. Each attempt is billed like any call.
Your handler gets the event as it was sent. Because a failed attempt is retried, and a run can rarely arrive twice, make work that must not repeat idempotent, for example by remembering the ids you have handled.
Bucket events. A bucket notification that targets a function queues one async invocation per event, so a failed handler is retried and a lost event ends in function.async_invocation_failed instead of disappearing.
Schedules
Under Triggers, add a schedule to call the function on a timetable, with an optional JSON input:
| Expression | Runs |
|---|---|
*/15 * * * * | Every 15 minutes |
0 6 * * 1-5 | 06:00 on weekdays |
@daily, @hourly, @weekly, @monthly | As named |
rate(5 minutes), rate(2 hours), rate(1 days) | Every so often |
Cron expressions have five fields (minute, hour, day of month, month, day of week) and are read in the time zone you choose (UTC by default, or an IANA name such as Africa/Lagos). A function can have up to 10 schedules; pause and resume them without losing them.
A scheduled run's event is:
{ "trigger": "schedule", "schedule_id": "fns_...", "event_id": "fns_...:1764396000", "scheduled_at": "2026-11-29T06:00:00Z", "input": {} }Runs are delivered at least once: rarely, after a failure on our side, a run can arrive twice with the same event_id, so a handler that must not repeat work should remember the ids it has done. Runs missed while a schedule was paused are not caught up.
Logs and metrics
Logs list every call for 7 days: when it started, how long it took, its status and outcome, and every line it printed. Search the text, filter by outcome, open a call for its full output, or turn on Live to follow new calls. Logs hold whatever your code printed, secrets included, so reading them needs the functions:ReadLogs permission.
Metrics show calls, errors, timeouts, crashes, throttled calls (429 and 503), cold starts and durations (p50, p95, p99) for the last hour up to 14 days, and this month's billed requests and compute.
Scaling, concurrency and cold starts
Each call runs in its own isolated microVM. More calls at once start more copies, up to the function's concurrency limit (1 to 50, default 10, set on the function page). Over the limit, a call gets 429 with Retry-After: 1; when there is briefly no room, it waits up to 2 seconds, then gets 503 with Retry-After. Both are safe to retry and are not billed.
A copy idle for 10 minutes stops. The next call starts one again from a snapshot (a cold start), which adds a short delay to that call only. Metrics count cold starts.
Errors callers can get
| Status | Meaning |
|---|---|
401 | The function needs a key and the call had none, or a wrong or revoked one |
403 | The organization is suspended, so its functions do not run |
404 | No function at this address |
408 | The request body took more than a minute to arrive |
413 | The request body is over 6 MiB |
429 | Over the function's concurrency limit; retry after a second |
502 | The handler threw an error or crashed |
503 | No room to run it right now; retry |
504 | The handler ran past its timeout |
Every answer carries X-Request-Id; give it to support with any question about a call.
Pricing
| Meter | Naira | Dollars |
|---|---|---|
| Requests | ₦240 per million | $0.20 per million |
| Compute | ₦0.02 per GiB-second | $0.0000166667 per GiB-second |
Compute is the memory you chose times the time your handler ran, from receiving the event to returning: start-up, waiting for room and refused calls are not billed. A 128 MiB function running 100 ms uses 0.0125 GiB-seconds. Usage is measured hourly and appears on your bill. There is no charge while a function is idle, and no free allowance.
Who can manage functions
Function actions are part of access policies. Owners and admins can do everything; the developer policy (pol_pantech_developer) can create, deploy and change functions but not delete them; read-only members can see functions but not their logs. A policy can grant or deny each action, such as letting a team deploy one function but not delete it.
Use the API
Everything in the console is in the public API: create, deploy (one file as JSON, or a zip as multipart), versions, keys, invoke, logs, metrics and schedules. See the functions API reference.
$ curl -X POST https://api.pantechdynamics.com/public/v1/functions/fn_.../deploy \ -H "Authorization: Bearer $PANTECH_API_KEY" -H "Idempotency-Key: $(uuidgen)" \ -F 'spec={"runtime":"nodejs24","handler":"index.handler","environment":[{"name":"API_URL","value":"https://example.com","secret":false}]}' \ -F 'code=@my-function.zip'