Skip to main content
POST/functions

Deploy Function

Registers a new function or redeploys an existing one within the specified project.

Requires PROJECT_ADMIN minimum.

The request body must include the artifact reference, runtime, tier (edge or platform), semver version, and function name. description is optional.

The artifact reference is artifactKey: the key returned by POST /@{projectSlug}/functions/artifacts, of the form functions/<projectId>/<sha256>.wasm|.tar.

Any other key is rejected with K9O_FUNCTION_ARTIFACT_KEY_INVALID.

The platform inserts a function registry entry with status: "deploying" and begins tier-specific preparation asynchronously.

The response is 202 Accepted with the registry entry at that status.

Poll GET /@{projectSlug}/functions/{name} until status transitions to active or error.

Parameters
projectSlug *path

The project's slug: the path segment after @.

It is unique within the org.

Request body
name *string

The function's name: a lowercase letter, then lowercase letters, digits and hyphens.

With functions, it is the module's name and each operation is stored as <name>:<operation>.

Deploying an existing name redeploys it.

runtime *"bun" | "rust" | "go" | "tinygo" | "zig" | "assemblyscript" | "c" | "cpp"

The language runtime: bun for JavaScript and TypeScript, or rust, go, tinygo, zig, assemblyscript, c or cpp for a WebAssembly (WASI) module. bun runs only on the sandbox tier; tinygo, assemblyscript, c and cpp run only on gateway; go, rust and zig run on either.

Any other value is refused.

tier *"gateway" | "sandbox"

Where the function runs: gateway runs a WebAssembly module in the gateway, sandbox runs a container image in an isolated microVM.

artifactKey *string

The key of the uploaded code: functions/<project id>/<sha256>.wasm for the gateway tier or .tar for the sandbox tier, as returned by POST /@<project>/functions/artifacts.

version *string

Your version label for this deploy.

descriptionstring

What the function does.

Shown to developers and to agents that call it as a tool.

functionsobject[]

Deploys the code as a module of named operations, 1 to 25 of them, all sharing one artifact.

A live operation left out of a redeploy is retired, which takes the same authority as deleting it.

name *string

The operation's name: lowercase letters, digits and hyphens.

It is stored as <module>:<name>.

descriptionstring

What the operation does.

Defaults to the module's description.

Responses
HTTPK9O CodeDescription
202Accepted
400K9O_INVALID_FIELD_VALUEThe function name is malformed or the requested tier is not supported by the declared runtime.
400K9O_FUNCTION_ARTIFACT_KEY_INVALIDThe artifactKey is not this project's content-addressed key (functions/<projectId>/<sha256>.wasm or .tar); upload the bytes with POST /@{projectSlug}/functions/artifacts and use the key it returns.
401K9O_INVALID_CREDENTIALSThe request credentials are missing or invalid.
401K9O_SESSION_EXPIREDYour session has expired; sign in again to continue.
403K9O_ACCESS_DENIEDPROJECT_ADMIN is required to deploy functions.
409K9O_FUNCTION_NOT_READYA deployment for this function name is already in progress; wait for it to complete before redeploying.
Response body (202)
data *any

A single function as deployed, with status deploying; or, for a body with functions, the module result.

Poll the function until it is active.

One of: object
id *string <uuid>

The function's id, a UUID.

It stays the same across redeploys.

name *string

The function's name.

A module's operations are named <module>:<operation>.

runtime *"bun" | "rust" | "go" | "tinygo" | "zig" | "assemblyscript" | "c" | "cpp"

The language runtime: bun, rust, go, tinygo, zig, assemblyscript, c or cpp.

tier *"gateway" | "sandbox"

Where the function runs: gateway or sandbox.

entryPoint *string

The artifact key of the deployed code.

version *string

The version label of the deploy.

status *"deploying" | "active" | "error" | "retired"

deploying while the code is prepared, active once it can be invoked, error when preparing it failed (see errorDetail), retired after it was deleted.

source *string

Who manages the function: developer for one you deployed, extension:<slug> for one an installed extension owns.

description *any

What the function does.

Null when none was given.

One of: string
or: null
createdAt *string <date-time>

When the function was first deployed.

deployedAt *any

When the current deploy became active.

Null while it is deploying.

One of: string <date-time>
or: null
retiredAt *any

When the function was retired.

Null unless status is retired.

One of: string <date-time>
or: null
errorDetail *any

Why the deploy failed.

Null unless status is error.

One of: string
or: null
or: object
functions *object[]

The module's operations as deployed, in the order declared, each deploying.

id *string <uuid>

The function's id, a UUID.

It stays the same across redeploys.

name *string

The function's name.

A module's operations are named <module>:<operation>.

runtime *"bun" | "rust" | "go" | "tinygo" | "zig" | "assemblyscript" | "c" | "cpp"

The language runtime: bun, rust, go, tinygo, zig, assemblyscript, c or cpp.

tier *"gateway" | "sandbox"

Where the function runs: gateway or sandbox.

entryPoint *string

The artifact key of the deployed code.

version *string

The version label of the deploy.

status *"deploying" | "active" | "error" | "retired"

deploying while the code is prepared, active once it can be invoked, error when preparing it failed (see errorDetail), retired after it was deleted.

source *string

Who manages the function: developer for one you deployed, extension:<slug> for one an installed extension owns.

description *any

What the function does.

Null when none was given.

One of: string
or: null
createdAt *string <date-time>

When the function was first deployed.

deployedAt *any

When the current deploy became active.

Null while it is deploying.

One of: string <date-time>
or: null
retiredAt *any

When the function was retired.

Null unless status is retired.

One of: string <date-time>
or: null
errorDetail *any

Why the deploy failed.

Null unless status is error.

One of: string
or: null
retired *object[]

Live operations this deploy left out, now retired.

id *string <uuid>

The function's id, a UUID.

It stays the same across redeploys.

name *string

The function's name.

A module's operations are named <module>:<operation>.

runtime *"bun" | "rust" | "go" | "tinygo" | "zig" | "assemblyscript" | "c" | "cpp"

The language runtime: bun, rust, go, tinygo, zig, assemblyscript, c or cpp.

tier *"gateway" | "sandbox"

Where the function runs: gateway or sandbox.

entryPoint *string

The artifact key of the deployed code.

version *string

The version label of the deploy.

status *"deploying" | "active" | "error" | "retired"

deploying while the code is prepared, active once it can be invoked, error when preparing it failed (see errorDetail), retired after it was deleted.

source *string

Who manages the function: developer for one you deployed, extension:<slug> for one an installed extension owns.

description *any

What the function does.

Null when none was given.

One of: string
or: null
createdAt *string <date-time>

When the function was first deployed.

deployedAt *any

When the current deploy became active.

Null while it is deploying.

One of: string <date-time>
or: null
retiredAt *any

When the function was retired.

Null unless status is retired.

One of: string <date-time>
or: null
errorDetail *any

Why the deploy failed.

Null unless status is error.

One of: string
or: null
reattached *object

What binds by name to operations that were retired and are deployed again.

Both lists are empty when nothing was brought back.

triggers *object[]

Triggers bound to an operation this deploy brought back from retirement.

They fire again; nothing they skipped while it was retired is replayed.

id *string

The trigger id.

functionName *string

The operation the trigger fires.

triggerKind *string

The kind of trigger, such as event or scheduled.

collectionActions *object[]

Collection actions bound to an operation this deploy brought back from retirement.

collection *string

The collection the action is on.

action *string

The action's name.

functionName *string

The operation the action runs.

meta *any
TypeScript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.functions.deploy({
  name: 'My Resource',
  runtime: 'bun',
  tier: 'sandbox',
  artifactKey: 'string',
  version: 'string'
})

Showing example in TypeScript

Request example
{
  "name": "My Resource",
  "runtime": "bun",
  "tier": "sandbox",
  "artifactKey": "string",
  "version": "string"
}
Response example (202)
{
  "data": {
    "id": "string",
    "name": "string",
    "runtime": "bun",
    "tier": "gateway",
    "entryPoint": "string",
    "version": "string",
    "status": "deploying",
    "source": "string",
    "description": "string",
    "createdAt": "string",
    "deployedAt": "string",
    "retiredAt": "string",
    "errorDetail": "string"
  }
}

More in Compute & Automation