Update function draft
Update an existing function. sourceCode / dependencies edit the draft without triggering a build — they go live on the next POST /v1/functions/{functionId}/deploy. httpEnabled is applied to the deployed function immediately, so turning the public endpoint on or off does not require a redeploy.
curl --request PATCH \
--url https://api.zavu.dev/v1/functions/{functionId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"files": {
"index.ts": "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n",
"lib/orders.ts": "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n"
},
"entrypoint": "index.ts",
"sourceCode": "<string>",
"dependencies": {},
"httpEnabled": true
}
EOFimport requests
url = "https://api.zavu.dev/v1/functions/{functionId}"
payload = {
"files": {
"index.ts": "import { formatOrder } from './lib/orders';
export default async function handler(event) {
return { statusCode: 200, body: formatOrder(event) };
}
",
"lib/orders.ts": "export function formatOrder(event) {
return JSON.stringify(event);
}
"
},
"entrypoint": "index.ts",
"sourceCode": "<string>",
"dependencies": {},
"httpEnabled": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
files: {
'index.ts': 'import { formatOrder } from \'./lib/orders\';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n',
'lib/orders.ts': 'export function formatOrder(event) {\n return JSON.stringify(event);\n}\n'
},
entrypoint: 'index.ts',
sourceCode: '<string>',
dependencies: {},
httpEnabled: true
})
};
fetch('https://api.zavu.dev/v1/functions/{functionId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zavu.dev/v1/functions/{functionId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'files' => [
'index.ts' => 'import { formatOrder } from \'./lib/orders\';
export default async function handler(event) {
return { statusCode: 200, body: formatOrder(event) };
}
',
'lib/orders.ts' => 'export function formatOrder(event) {
return JSON.stringify(event);
}
'
],
'entrypoint' => 'index.ts',
'sourceCode' => '<string>',
'dependencies' => [
],
'httpEnabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zavu.dev/v1/functions/{functionId}"
payload := strings.NewReader("{\n \"files\": {\n \"index.ts\": \"import { formatOrder } from './lib/orders';\\n\\nexport default async function handler(event) {\\n return { statusCode: 200, body: formatOrder(event) };\\n}\\n\",\n \"lib/orders.ts\": \"export function formatOrder(event) {\\n return JSON.stringify(event);\\n}\\n\"\n },\n \"entrypoint\": \"index.ts\",\n \"sourceCode\": \"<string>\",\n \"dependencies\": {},\n \"httpEnabled\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.zavu.dev/v1/functions/{functionId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"files\": {\n \"index.ts\": \"import { formatOrder } from './lib/orders';\\n\\nexport default async function handler(event) {\\n return { statusCode: 200, body: formatOrder(event) };\\n}\\n\",\n \"lib/orders.ts\": \"export function formatOrder(event) {\\n return JSON.stringify(event);\\n}\\n\"\n },\n \"entrypoint\": \"index.ts\",\n \"sourceCode\": \"<string>\",\n \"dependencies\": {},\n \"httpEnabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v1/functions/{functionId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"files\": {\n \"index.ts\": \"import { formatOrder } from './lib/orders';\\n\\nexport default async function handler(event) {\\n return { statusCode: 200, body: formatOrder(event) };\\n}\\n\",\n \"lib/orders.ts\": \"export function formatOrder(event) {\\n return JSON.stringify(event);\\n}\\n\"\n },\n \"entrypoint\": \"index.ts\",\n \"sourceCode\": \"<string>\",\n \"dependencies\": {},\n \"httpEnabled\": true\n}"
response = http.request(request)
puts response.read_body{
"function": {
"id": "fn_abc123",
"slug": "order-bot",
"name": "Order Bot",
"runtime": "nodejs24",
"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>"
}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Zavu Function ID.
Body
Fields to update on an existing function. Provide at least one. files / sourceCode and dependencies edit the draft and take effect on the next deploy; httpEnabled applies immediately to the deployed function.
The project's source files, keyed by path relative to the project root (e.g. index.ts, lib/orders.ts). Imports between them are resolved when the function is built, so a function can be split across as many files as it needs.
Paths must be relative and use forward slashes; .., node_modules/ and package.json are rejected. npm packages are not uploaded here — declare them under dependencies and Zavu installs them. Limits: 200 files and 900,000 bytes for the whole tree.
Show child attributes
Show child attributes
{
"index.ts": "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n",
"lib/orders.ts": "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n"
}
Which file in files is the entry point. Defaults to index.ts.
"index.ts"
Shortcut for a single-file function: exactly equivalent to sending files with one entry named after entrypoint (index.ts by default). Fully supported — use whichever fits. If both are sent, files wins.
900000New dependency map (replaces existing dependencies).
Show child attributes
Show child attributes
Expose the function on its public HTTPS URL, or take it down. Applies to the already-deployed function without redeploying; the URL is returned as publicUrl.
Response
Draft updated.
A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to messaging events or HTTP requests.
Show child attributes
Show child attributes
curl --request PATCH \
--url https://api.zavu.dev/v1/functions/{functionId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"files": {
"index.ts": "import { formatOrder } from './lib/orders';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n",
"lib/orders.ts": "export function formatOrder(event) {\n return JSON.stringify(event);\n}\n"
},
"entrypoint": "index.ts",
"sourceCode": "<string>",
"dependencies": {},
"httpEnabled": true
}
EOFimport requests
url = "https://api.zavu.dev/v1/functions/{functionId}"
payload = {
"files": {
"index.ts": "import { formatOrder } from './lib/orders';
export default async function handler(event) {
return { statusCode: 200, body: formatOrder(event) };
}
",
"lib/orders.ts": "export function formatOrder(event) {
return JSON.stringify(event);
}
"
},
"entrypoint": "index.ts",
"sourceCode": "<string>",
"dependencies": {},
"httpEnabled": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
files: {
'index.ts': 'import { formatOrder } from \'./lib/orders\';\n\nexport default async function handler(event) {\n return { statusCode: 200, body: formatOrder(event) };\n}\n',
'lib/orders.ts': 'export function formatOrder(event) {\n return JSON.stringify(event);\n}\n'
},
entrypoint: 'index.ts',
sourceCode: '<string>',
dependencies: {},
httpEnabled: true
})
};
fetch('https://api.zavu.dev/v1/functions/{functionId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zavu.dev/v1/functions/{functionId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'files' => [
'index.ts' => 'import { formatOrder } from \'./lib/orders\';
export default async function handler(event) {
return { statusCode: 200, body: formatOrder(event) };
}
',
'lib/orders.ts' => 'export function formatOrder(event) {
return JSON.stringify(event);
}
'
],
'entrypoint' => 'index.ts',
'sourceCode' => '<string>',
'dependencies' => [
],
'httpEnabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zavu.dev/v1/functions/{functionId}"
payload := strings.NewReader("{\n \"files\": {\n \"index.ts\": \"import { formatOrder } from './lib/orders';\\n\\nexport default async function handler(event) {\\n return { statusCode: 200, body: formatOrder(event) };\\n}\\n\",\n \"lib/orders.ts\": \"export function formatOrder(event) {\\n return JSON.stringify(event);\\n}\\n\"\n },\n \"entrypoint\": \"index.ts\",\n \"sourceCode\": \"<string>\",\n \"dependencies\": {},\n \"httpEnabled\": true\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.zavu.dev/v1/functions/{functionId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"files\": {\n \"index.ts\": \"import { formatOrder } from './lib/orders';\\n\\nexport default async function handler(event) {\\n return { statusCode: 200, body: formatOrder(event) };\\n}\\n\",\n \"lib/orders.ts\": \"export function formatOrder(event) {\\n return JSON.stringify(event);\\n}\\n\"\n },\n \"entrypoint\": \"index.ts\",\n \"sourceCode\": \"<string>\",\n \"dependencies\": {},\n \"httpEnabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v1/functions/{functionId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"files\": {\n \"index.ts\": \"import { formatOrder } from './lib/orders';\\n\\nexport default async function handler(event) {\\n return { statusCode: 200, body: formatOrder(event) };\\n}\\n\",\n \"lib/orders.ts\": \"export function formatOrder(event) {\\n return JSON.stringify(event);\\n}\\n\"\n },\n \"entrypoint\": \"index.ts\",\n \"sourceCode\": \"<string>\",\n \"dependencies\": {},\n \"httpEnabled\": true\n}"
response = http.request(request)
puts response.read_body{
"function": {
"id": "fn_abc123",
"slug": "order-bot",
"name": "Order Bot",
"runtime": "nodejs24",
"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>"
}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}