api-reference
serverless-functions

API Reference

Base URL: http://deno-runtime.serverless.svc.cluster.local:8000 (in-cluster) or http://localhost:24006 (port-forwarded)

Health

GET /health
{
  "status": "healthy",
  "scripts": 3,
  "uptime": 45123.456
}

Deploy Function

POST /deploy
{
  "id": "hello",
  "code": "function handler(data) { return { message: 'Hello ' + data.name }; }"
}
FieldRequiredDescription
idYesUnique function identifier
codeYesTypeScript/JavaScript code with a handler function

Response (201):

{
  "id": "hello",
  "url": "/invoke/hello"
}

Redeploying with the same id replaces the existing function (old Worker terminated, new one created).

Invoke Function

POST /invoke/{id}

Send any JSON body — it's passed as the argument to handler():

curl -X POST /invoke/hello \
  -H "Content-Type: application/json" \
  -d '{"name": "World"}'

Response:

The return value of handler() is serialized to JSON. If the handler returns an object with status and body fields, it's treated as an HTTP response:

// Returns JSON directly
function handler(data) {
  return { greeting: "Hello" };
}

// Returns custom HTTP response
function handler(data) {
  return {
    status: 200,
    body: "plain text response",
    headers: { "content-type": "text/plain" }
  };
}

Delete Function

DELETE /delete/{id}

Terminates the Worker and frees memory.

{ "status": "deleted", "id": "hello" }

List Functions

GET /scripts
{
  "scripts": [
    {
      "id": "hello",
      "invocations": 42,
      "uptime": 123456,
      "lastInvoked": "2026-03-28T18:35:22.885Z"
    }
  ]
}

Server Stats

GET /stats
{
  "totalScripts": 3,
  "maxScripts": 500,
  "scripts": [...]
}

Error Responses

Function not found:

{ "error": "Script not found: unknown-id" }

Execution timeout:

{ "error": "Execution timeout (30s)" }

Handler missing:

{ "error": "No handler function exported" }

Deploy limit reached:

{ "error": "Max scripts limit reached (500)" }