Skip to main content
POST
/
v1
/
functions
Create function
curl --request POST \
  --url https://api.zavu.dev/v1/functions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data @- <<EOF
{
  "slug": "order-bot",
  "name": "Order Bot",
  "description": "Replies to order status questions on WhatsApp.",
  "sourceCode": "import { defineFunction } from '@zavu/functions';\n\nexport default defineFunction(async (event, ctx) => {\n  ctx.log('received', event.type);\n});\n",
  "dependencies": {
    "openai": "^4.20.0"
  }
}
EOF
{
  "function": {
    "id": "fn_abc123",
    "slug": "order-bot",
    "name": "Order Bot",
    "runtime": "nodejs20",
    "status": "draft",
    "timeoutSec": 10,
    "memoryMb": 256,
    "httpEnabled": true,
    "dependencies": {
      "openai": "^4.20.0"
    },
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z",
    "description": "<string>",
    "publicUrl": "<string>",
    "activeDeploymentId": "<string>"
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.zavu.dev/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
slug
string
required

URL-safe identifier (lowercase, digits, hyphens). Must be unique per project.

Required string length: 1 - 50
Example:

"order-bot"

name
string
required
Maximum string length: 80
Example:

"Order Bot"

description
string
Maximum string length: 280
runtime
enum<string>

Runtime the function is deployed on.

Available options:
nodejs20
timeoutSec
integer
default:10
Required range: 1 <= x <= 30
memoryMb
enum<integer>
default:256
Available options:
128,
256,
512,
1024
httpEnabled
boolean
default:false

Whether to expose a public HTTPS URL for this function.

sourceCode
string

TypeScript source code for the function entry point (max ~900KB).

Maximum string length: 900000
dependencies
object

npm dependencies. Keys are package names, values are semver ranges.

Example:
{ "openai": "^4.20.0" }

Response

Function created.

function
object
required

A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to messaging events or HTTP requests.