Functions
Deploy, invoke, schedule, and observe managed serverless functions.
Functions are managed, serverless handlers: an OCI image plus a wire contract (an HTTP server on a port) that Daytona invokes on demand, scaling microVM instances up and to zero for you and billing per invocation duration. All routes below are project-scoped by your API key (Authorization: Bearer $RLP_API_KEY) except the public web endpoint POST /fn/:project/:name, which is called without a key. For the conceptual model, see the Functions guides.
POST /fns
Deploy a function, creating a new immutable version and pointing current at it. Redeploying the same name rolls forward. Accepts JSON (a registry or named image source) or multipart/form-data to build from a Dockerfile (fields: name, dockerfile, config text parts, and a context tar; ~8 MiB cap). Every field except name and image has a default.
Request
| Field | Type | Required / default | Description |
|---|---|---|---|
name | string | required | Per-project unique name; [a-z0-9]([a-z0-9-]*[a-z0-9])?, 1–64 chars. |
image | object | required | {"type":"registry","ref":"<image>"} or {"type":"named","name":"<project-image>"}. |
handler | string[] | [] (image entrypoint) | Argv that starts the HTTP server on port. |
port | int | 8080 | Port the handler listens on (RLP_FN_PORT); 1–65535. |
vcpus | int | 1 | Provisioned vCPUs; ≥ 1. |
mem_mib | int | 512 | Provisioned memory (MiB); ≥ 128. |
scratch_mib | int | 512 | Scratch disk (MiB); ≥ 64. |
timeout_s | int | 300 | Max seconds per invocation; 1–172800 (48h). |
scaledown_window_s | int | 60 | Idle seconds before scale-to-zero; ≥ 2. |
max_concurrency | int | 1 | Invocations one instance serves at once; ≥ 1. |
max_instances | int | null (unbounded) | Spend guard capping concurrent instances; ≥ 1 when set. |
env | object | {} | Handler env vars; names match [A-Za-z_][A-Za-z0-9_]*. |
snapshot_kind | string | pre_entrypoint | pre_entrypoint or fn_ready (pre-warmed handler; falls back automatically). |
Functions are always non-spot, non-persistent, and burstable, homed in the caller's default region — there is no region, spot, persistent, secrets, or mode field.
Errors
400— invalidname,portout of range,vcpus/mem_mib/scratch_mibbelow minimums,timeout_sout of range,scaledown_window_s < 2,max_concurrency < 1,max_instances < 1, invalidsnapshot_kind, or invalidenvname.
GET /fns
List the project's functions, newest first, each with its current version and template state.
GET /fns/:name
Fetch one function's detail, including its current version's full configuration.
Errors
404— unknown function, or a function in another project.
GET /fns/:name/versions
List a function's version history, newest first. Each entry is the full version projection.
Errors
404— unknown function.
PATCH /fns/:name/config
Update the runtime scaling knobs on the current version in place, without a rebuild. The change takes effect on the next invocation. Only the fields below may be updated here; changing the image or handler requires a redeploy via POST /fns. Send max_instances: null to remove a previously set cap (absent leaves it unchanged).
Request
| Field | Type | Description |
|---|---|---|
max_concurrency | int | Invocations one instance serves at once; ≥ 1. |
max_instances | int | null | Spend-guard cap; null removes it. |
timeout_s | int | Max seconds per invocation; 1–172800. |
scaledown_window_s | int | Idle seconds before scale-to-zero; ≥ 2. |
Errors
400—max_concurrency < 1,max_instances < 1,timeout_sout of range, orscaledown_window_s < 2.404— unknown function.
POST /fns/:name/invoke
Synchronous invoke. The request body is forwarded verbatim to the handler as POST /, and the connection is held until the handler responds or timeout_s elapses. The response body is the handler's response. Response headers: x-rlp-invocation-id, x-rlp-fn-status (the handler's own status), and x-rlp-cold (1 if a cold start, else 0). The payload cap is ~6 MiB.
Errors
404— unknown function, or no current version.429— no capacity could be placed within the queue budget (~30 s). Honor theRetry-After: 5header and retry.502— the handler instance was unreachable.504— the handler exceededtimeout_s.
POST /fns/:name/spawn
Async invoke. Returns an invocation id immediately and runs the work in the background; poll GET /invocations/:id for the outcome. The retrievable async result is limited to 256 KiB of JSON.
Errors
404— unknown function, or no current version.
POST /fns/:name/map
Fan-out: submit up to 1000 payloads in one call and get back that many invocation ids to poll in parallel. Each payload is forwarded verbatim as a handler POST / body.
Request
| Field | Type | Description |
|---|---|---|
payloads | array | One entry per parallel invocation; non-empty, ≤ 1000. |
Errors
400— emptypayloads, or more than 1000 entries.404— unknown function, or no current version.
GET /invocations/:id
Poll an async, map, or scheduled invocation for its status and result. status is one of pending, running, succeeded, failed, timeout, or shed; done is true once terminal. result is present only for a succeeded invocation whose result was ≤ 256 KiB of JSON.
Errors
404— unknown invocation, or one in another project.
POST /fns/:name/schedules
Create a cron schedule for the function. cron is a 5-field expression (minute hour day-of-month month day-of-week) evaluated in UTC; payload is forwarded verbatim on each fire.
Request
| Field | Type | Required / default | Description |
|---|---|---|---|
cron | string | required | 5-field cron expression, UTC. |
payload | any | null | JSON body sent to the handler on each fire. |
enabled | bool | true | Whether the schedule fires. |
Errors
400— invalid cron expression, or one that never fires.404— unknown function.
GET /fns/:name/schedules
List the function's schedules, newest first.
Errors
404— unknown function.
DELETE /fns/:name/schedules/:id
Delete a schedule by id. Returns 204 No Content.
Errors
404— unknown function, or unknown schedule for that function.
POST /fns/:name/public
Enable or disable the function's public web endpoint. With require_token: true while enabling, a bearer token is minted and returned once in the response (null otherwise) — store it, as it isn't retrievable again.
Request
| Field | Type | Required / default | Description |
|---|---|---|---|
enabled | bool | required | Turn the public endpoint on or off. |
require_token | bool | false | Require a per-function bearer token on the public URL. |
Errors
404— unknown function.
POST /fn/:project/:name
The public web endpoint — invoked with no project API key. The request body is forwarded to the handler as POST / and the handler's response is returned, exactly like a keyed synchronous invoke. If the function requires a token, pass it as a bearer token; otherwise omit the Authorization header.
Errors
401— a token is required and the presented bearer token is wrong or missing.404— no such function, or the function is not public (its existence is not revealed on the public host).429— no capacity within the queue budget; honorRetry-After: 5.504— the handler exceededtimeout_s.
GET /fns/:name/invocations
The invocation log for a function: past invocations newest first, with per-invocation status, duration, cold/warm, and error. Supports filtering and pagination.
| Query param | Type | Default | Description |
|---|---|---|---|
status | string | — | Filter by status (succeeded, failed, timeout, shed, …). |
version | int | — | Filter by function version. |
limit | int | 100 | Page size, clamped to [1, 1000]. |
offset | int | 0 | Offset for pagination. |
Errors
404— unknown function.
GET /fns/:name/usage/series
Time-bucketed invocation counts for a function, for charting. Buckets are hourly by default or daily, with totals, outcome breakdowns, and cold/warm counts per bucket.
| Query param | Type | Default | Description |
|---|---|---|---|
resolution | string | h | h (hourly) or d (daily). |
from | RFC3339 | 24h/30d ago | Window start. |
to | RFC3339 | now | Window end. |
Errors
404— unknown function.
GET /fns/usage/report
Aggregate usage and billing report across the project's functions for a window: per-function counts by outcome, latency percentiles (p50/p95/p99), cold-vs-warm split, and total billed credits.
| Query param | Type | Default | Description |
|---|---|---|---|
from | RFC3339 | 24h ago | Window start. |
to | RFC3339 | now | Window end. |
fn | string | — | Restrict to one function by name. |