Create a new Zavu Function. The function starts in draft status. A dedicated API key is auto-provisioned and injected as the ZAVU_API_KEY secret so the function can call back into the Zavu API without manual setup.
Provide sourceCode to seed the draft. Call POST /v1/functions/{functionId}/deploy afterwards to publish.
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.
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
URL-safe identifier (lowercase, digits, hyphens). Must be unique per project.
1 - 50"order-bot"
80"Order Bot"
280Runtime the function is deployed on.
nodejs20 1 <= x <= 30128, 256, 512, 1024 Whether to expose a public HTTPS URL for this function.
TypeScript source code for the function entry point (max ~900KB).
900000npm dependencies. Keys are package names, values are semver ranges.
Show child attributes
{ "openai": "^4.20.0" }Function created.
A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to messaging events or HTTP requests.
Show child attributes
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>"
}
}