---
title: "Deploy function"
method: POST
path: "/v1/functions/{functionId}/deploy"
tags: ["Functions"]
---

# Deploy function

`POST /v1/functions/{functionId}/deploy`

Publish the function. If `sourceCode` or `dependencies` are provided in the body, they replace the current draft before deployment. Returns immediately with a deployment ID — poll `GET /v1/functions/deployments/{deploymentId}` until status is `active` or `failed`.

## Path parameters

- `functionId` string, required

## Request body

- FunctionDeployRequest — Optional source/dependencies update applied before deploying. Omit every field to redeploy the current draft as-is.
  - `files` object — 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.
  - `entrypoint` string — Which file in `files` is the entry point. Defaults to `index.ts`.
  - `sourceCode` string — 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.
  - `dependencies` object — New dependency map (replaces existing dependencies).

## Response `202`

Deployment queued.

- FunctionDeploymentResponse
  - `deployment` FunctionDeployment, required
    - `id` string, required
    - `functionId` string, required
    - `version` integer, required — Monotonically increasing deployment version, starting at 1.
    - `status` 'pending' | 'bundling' | 'uploading' | 'publishing' | 'active' | 'failed' | 'superseded', required — Stage of a function deployment.
    - `sourceCodeBytes` integer, nullable — Total size of the deployed source tree in bytes.
    - `bundleBytes` integer, nullable — Size of the built bundle in bytes. Null until the build finishes.
    - `errorMessage` string, nullable — Failure reason when status is 'failed'.
    - `buildLogs` string, nullable — What the build printed: dependency installation, the bundler's output, and the compiler's message when it failed. Returned when fetching a single deployment, omitted from the list. Read this first when a deploy fails — `errorMessage` is often the outer wrapper's summary, and the line that names the broken import or the syntax error is here.
    - `deployedAt` string, date-time, nullable
    - `createdAt` string, date-time, required

## Other responses

- `400` — Invalid request or function in a non-deployable state.
- `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/revisions/4dacdff2adf8/schema)
