---
title: "Create or update function code"
method: POST
path: "/projects/{id}/functions"
tags: ["Functions"]
---

# Create or update function code

`POST /projects/{id}/functions`

## Request

- Base URL: `https://api.volcano.dev`
- URL: `https://api.volcano.dev/projects/{id}/functions`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer

Upload a function source bundle. Direct API clients may send the function code
as a ZIP or tar.gz archive via multipart/form-data. The API stores a normalized tar.gz
source archive.
Cloud deploys should include source files and dependency manifests/lockfiles, not installed
dependency directories. Volcano installs Node.js, Python, and Ruby dependencies during the
function compile build.
Source archive size is enforced by the API with `SOURCE_ARCHIVE_SIZE_LIMIT_MB`; the CLI
does not apply its own source archive size limit. After the final container image is
built, the publish build enforces `LAMBDA_TARGET_CONTAINER_SIZE_LIMIT_MB` before pushing.
Uploaded source archives cannot contain symlink entries. Safe symlinks created during
the cloud build are materialized before publish.
Volcano builds and deploys the function asynchronously after upload. A deployment that starts
immediately returns a Function resource with `status: provisioning`, then transitions to
`active` or `failed`. If another deployment is running, the response preserves the resource's
current status and exposes the queued deployment through `pending_deployment_id`.
Existing function traffic continues to use the last known-good runtime during an update. A failed
update keeps that runtime available and records the attempted deployment as failed.
Only one deployment runs for a given function. A newer request supersedes any queued request
and starts after the running deployment. Different functions and projects deploy concurrently.
If a function with the same name already exists in the project, this operation updates that
function's runtime, handler, and source bundle and returns `200 OK`.
Each project can contain up to 10,000 functions. Creating a new function over this cap returns 403.

## Path parameters

- `id` string, uuid, required

## Request body `multipart/form-data`

- object
  - `name` string, required: DNS-safe function name (lowercase letters, numbers, hyphens; cannot start or end with hyphen)
  - `code` string, binary, required: ZIP or tar.gz archive containing function source code plus dependency manifests/lockfiles. The API enforces SOURCE_ARCHIVE_SIZE_LIMIT_MB and stores a normalized tar.gz source archive.
  - `runtime` 'nodejs22.x' | 'nodejs24.x' | 'python3.10' | 'python3.11' | 'python3.12' | 'python3.13' | 'python3.14' | 'ruby3.3' | 'ruby3.4' | 'ruby4.0', required: Runtime environment. Required. - Node.js: nodejs22.x, nodejs24.x - Python: python3.10, python3.11, python3.12, python3.13, python3.14 - Ruby: ruby3.3, ruby3.4, ruby4.0
  - `handler` string: The name of the function to invoke. Defaults to "handler" if not specified. Your code must export/define a function with this name: - Node.js: exports.handler (in index.js) - Python: def handler() (in main.py) - Ruby: def handler() (in main.rb)
  - `visibility` 'private' | 'authenticated' | 'public': Who can invoke the function. Omit it to keep the function's current visibility; a new function starts `private`.
  - `is_public` boolean: Deprecated alias for `visibility`: `true` means `public` and `false` means `authenticated`. Sending both with different meanings returns 400.
  - `invocation_mode` 'rpc' | 'http': Invocation contract. `rpc` preserves the existing POST `{payload: ...}` contract; `http` forwards HTTP request semantics to the function runtime.
  - `http_auth_mode` 'volcano' | 'none': Authentication applied by the HTTP ingress. `none` is valid only for HTTP-mode functions with `visibility: public` and is intended for externally signed webhooks.
  - `openapi_spec` string: JSON-encoded OpenAPI 3.0 or 3.1 metadata for an HTTP-mode function.
  - `variable_scope` 'all' | 'scoped': Which project variables this function receives. `all` (the default) gives it only project variables marked `shared: true`; `scoped` gives it only the variables it selects. Omitting this leaves an existing function's scope unchanged.
  - `variables` string: JSON-encoded array of project variable names this function requires, on top of the ones detected in its source. A declared name the project does not define is rejected with 400; a detected name it does not define is ignored. Only used when `variable_scope` is `scoped`. Omitting this leaves an existing function's declared names unchanged.

## Response `200`

Existing function updated; its deployment was started or queued

- Function
  - `id` string, uuid, required
  - `project_id` string, uuid, required
  - `name` string, required
  - `status` 'provisioning' | 'active' | 'failed' | 'deleting', required
  - `provisioning_started_at` string, date-time: Timestamp when the current provisioning phase started
  - `visibility` 'private' | 'authenticated' | 'public', required: Who can invoke the function. Each level admits everything the one before it does. - `private`: service keys and the project's schedulers only. The default for a new function. To any other credential the function does not exist: it answers 404, like a missing one. - `authenticated`: also any signed-in user of the project, including anonymous sign-ins. The function receives their auth context. - `public`: also anon keys holding `functions.invoke`, and Frontend Function routes, which forward requests without a credential.
  - `is_public` boolean, required: Deprecated. `true` exactly when `visibility` is `public`.
  - `invocation_mode` 'rpc' | 'http', required: Invocation contract. `rpc` preserves the existing POST `{payload: ...}` contract; `http` forwards HTTP request semantics to the function runtime.
  - `http_auth_mode` 'volcano' | 'none', required: Authentication applied by the HTTP ingress. `none` is valid only for HTTP-mode functions with `visibility: public` and is intended for externally signed webhooks.
  - `openapi_spec` object, nullable, required: Optional OpenAPI 3.0 or 3.1 document describing an HTTP-mode function.
  - `has_openapi_spec` boolean, required: Whether OpenAPI metadata is configured; list responses omit the document itself.
  - `invoke_url` string: Canonical geo-routed HTTPS endpoint for invoking this function. Use it as-is: it does not share a domain with the API, so a host derived from the API URL will not reach the function. Omitted when the deployment serves no public invocation domain, as in local development, so a client testing for an empty string never matches.
  - `deployed_regions` string[], required: Regions where this function is currently deployed
  - `runtime` string
  - `handler` string
  - `current_deployment_id` string, uuid: Identifier of the latest function deployment operation
  - `pending_deployment_id` string, uuid: Newest queued deployment that will run after the current operation
  - `last_invoked_at` string, date-time: Most recent successful invocation timestamp
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `201`: Function created and deployment workflow started
- `400`: Bad request (invalid file, too large, etc.), an unknown `visibility`, or `visibility` and `is_public` disagree
- `403`: Function limit exceeded for the project
- `409`: Function deletion is queued or running, the name is already held by a durable function — a function cannot change kind — or the redeploy would take a function with Frontend Function routes out of `public` or out of HTTP invocation mode. The request is refused before the deploy starts, so nothing is deployed.
- `429`: The owner's billing-cycle build-minutes allowance is spent. The error names the allowance and carries a link to the usage page.
- `500`: Internal server error (function deployment failed)
- `503`: Build usage could not be read, so the allowance could not be checked. The same request succeeds once it can be.

## Changes

- **2026-10-07** `23e7875e7c4c`: 2 warning, 9 info
  - removed the optional property `aws_function_arn` from the response with the `200` status
  - removed the optional property `aws_function_arn` from the response with the `201` status
  - the endpoint scheme security `ProjectAccessToken` was added to the API
  - added the new optional request property `visibility`
  - …7 more
- **2026-09-19** `3a6f365f3f35`: 9 breaking, 57 info
  - added the new path request parameter `id`
  - request property `http_auth_mode` was restricted to a list of enum values
  - request property `invocation_mode` was restricted to a list of enum values
  - the response's body type changed from no type to `object` for status `200`
  - …62 more
- **2026-09-04** `c2ec82fb8ce8`: 4 info
  - added the new optional request property `http_auth_mode`
  - added the new optional request property `invocation_mode`
  - added the new optional request property `is_public`
  - added the new optional request property `openapi_spec`
- **2026-08-27** `bb44e98aba2e`: 26 breaking, 21 warning
  - the response's body type changed from `object` to no type for status `200`
  - the response's body type changed from `object` to no type for status `201`
  - the response's body type changed from `object` to no type for status `400`
  - the response's body type changed from `object` to no type for status `403`
  - …43 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/kong/apis/volcano-api/changes/projects/:id/functions/post.md)

---

[API](https://skmtc.dev/kong/apis/volcano-api.md) - [All operations](https://skmtc.dev/kong/apis/volcano-api/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/volcano-api/revisions/84c4488f91e9?raw)
