Documentation

esc
    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.

    RuntimesNode.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)
    CodeOne file up to 256 KiB, or a zip of a folder up to 25 MiB (250 MiB unpacked)
    Dependenciespackage.json, requirements.txt, go.mod, Gemfile or composer.json in the zip, installed when the function builds
    Memory128, 256, 512, 1024 or 2048 MiB; 1 vCPU up to 1024 MiB, 2 vCPU at 2048 MiB
    Timeout1 to 900 seconds per request (default 30)
    Requests and responsesUp to 6 MiB each
    Environment variablesUp to 4 KiB in all; values marked secret are stored encrypted and never shown again
    ConcurrencyUp to 50 calls at once per function (default 10)
    Zoneaf-abj-1, Abuja

    Create a function in the console

    1. Go to Compute → Serverless functions and press Create function.
    2. 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.
    3. 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.
    4. Add any environment variables.
    5. 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

    LanguageRuntime idHandler (default)Dependencies
    Node.js 24nodejs24file.export (index.handler)package.json
    Node.js 22nodejs22file.export (index.handler)package.json
    Python 3.14python3.14module.function (main.handler)requirements.txt
    Python 3.13python3.13module.function (main.handler)requirements.txt
    Python 3.12python3.12module.function (main.handler)requirements.txt
    Bun 1.3bun1.3file.export (index.handler); .ts files run as they arepackage.json
    Go 1.25go1.25main.Name, an exported function of package main (main.Handler)go.mod
    Ruby 3.3ruby3.3file.method (handler.handler)Gemfile
    PHP 8.4php8.4file.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.

    index.mjs
    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).

    The event for a request to the URL:

    Field
    methodGET, POST and so on
    pathThe path, such as /orders/42
    queryThe query string as a map
    headersRequest headers, names in lowercase. A function key the caller sent is removed first
    bodyThe body as a string; base64 when is_base64 is true (binary uploads)
    is_base64Whether body is base64
    source_ipThe caller's address
    request_idThe 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.

    Terminal
    $ 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:

    Terminal
    $ 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:

    1. 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.txt for Python, go.mod (and go.sum) for Go, Gemfile (and Gemfile.lock) for Ruby, or composer.json (and composer.lock) for PHP.
    2. Zip the folder's contents, not the folder itself: cd my-function && zip -r ../my-function.zip .
    3. 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:

    RuntimeThe build runs
    Node.jsnpm ci, or npm install without a lock file
    Bunbun install --production
    Pythonpip install -r requirements.txt
    Gogo mod tidy (and go mod init without a go.mod), then go build
    Rubybundle install
    PHPcomposer 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:

    Terminal
    $ 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_retries sets 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_failed get 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, failed or expired), 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-invocations lists 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:

    ExpressionRuns
    */15 * * * *Every 15 minutes
    0 6 * * 1-506:00 on weekdays
    @daily, @hourly, @weekly, @monthlyAs 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:

    JSON
    { "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

    StatusMeaning
    401The function needs a key and the call had none, or a wrong or revoked one
    403The organization is suspended, so its functions do not run
    404No function at this address
    408The request body took more than a minute to arrive
    413The request body is over 6 MiB
    429Over the function's concurrency limit; retry after a second
    502The handler threw an error or crashed
    503No room to run it right now; retry
    504The handler ran past its timeout

    Every answer carries X-Request-Id; give it to support with any question about a call.

    Pricing

    MeterNairaDollars
    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.

    Terminal
    $ 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'

    Was this page helpful?

    Updated