---
title: "Update function draft"
method: PATCH
path: "/v1/functions/{functionId}"
tags: ["Functions"]
---

# Update function draft

`PATCH /v1/functions/{functionId}`

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.

## Path parameters

- `functionId` string, required

## Request body

- FunctionUpdateRequest — Fields to update on an existing function. Provide at least one. `sourceCode` and `dependencies` edit the draft and take effect on the next deploy; `httpEnabled` applies immediately to the deployed function.
  - `sourceCode` string — New source code for the draft (replaces it).
  - `dependencies` object — New dependency map (replaces existing dependencies).
  - `httpEnabled` boolean — 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 `200`

Draft updated.

- ZavuFunctionResponse
  - `function` ZavuFunction, required — A Zavu Function — user-supplied TypeScript that runs in Zavu Cloud and reacts to messaging events or HTTP requests.
    - `id` string, required
    - `slug` string, required — URL-safe identifier, unique per project.
    - `name` string, required
    - `description` string, nullable
    - `runtime` 'nodejs24', required — Runtime the function is deployed on.
    - `status` 'draft' | 'bundling' | 'deploying' | 'active' | 'failed' | 'disabled', required — Lifecycle status of a Zavu Function.
    - `timeoutSec` integer, required — Per-invocation timeout in seconds.
    - `memoryMb` integer, required — Memory allocation in MB.
    - `httpEnabled` boolean, required — Whether the function can be invoked over HTTPS via its public URL.
    - `publicUrl` string, uri, nullable — HTTPS endpoint, present only while httpEnabled is true. Null otherwise, including for a function that was previously exposed — the stored URL stops serving the moment HTTP is turned off, so it is never returned.
    - `dependencies` object, required — npm dependencies installed in the function bundle. Keys are package names, values are semver ranges.
    - `activeDeploymentId` string, nullable — ID of the deployment currently serving traffic.
    - `createdAt` string, date-time, required
    - `updatedAt` string, date-time, required

## Other responses

- `400` — No fields provided.
- `401` — Unauthorized.
- `404` — Function not found.

---

[API](https://skmtc.net/zavudev/apis/zavu-unified-messaging-layer-api.md) · [All operations](https://skmtc.net/zavudev/apis/zavu-unified-messaging-layer-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/zavudev/zavu-unified-messaging-layer-api/versions/07b87b6ae707/schema)
