Deploy code to a function

Creates a deployment for the function. Supply any subset of zip,
environment, and runtime; omitted fields inherit the
function's latest version. At least one field must be supplied. The
first deployment of a function must include zip. The newest deployment
becomes active.

Note: This endpoint is currently in Beta.

Path Params
string
required
^[a-z0-9-]{1,60}$

The Neon project ID

string
required
^[a-z0-9-]{1,60}$

The Neon branch ID

string
required
^[a-z0-9]{1,20}$

The function slug

Body Params
file

Optional ZIP archive of the function source code. Omit to reuse the
latest version's bundle (a config-only change). Required for the
first deployment of a function.

Place index.mjs or index.js at the archive root, without a
containing directory. If both exist, index.mjs is loaded. Export a
request handler function or an object with a fetch method. Use
export default for ESM or module.exports for CommonJS; prefer
index.mjs for ESM.

Upload JavaScript ready to run on Node.js 24. Compile TypeScript
before uploading. Bundle dependencies into the entry module, or
include the required modules and assets in the archive with their
relative paths preserved (including node_modules for external
packages). Node.js built-in modules do not need to be bundled.
The API does not transpile, bundle, or install dependencies.
The ZIP is limited to 32 MiB compressed and 128 MiB extracted, with
at most 32,768 entries and 64 MiB per file. Bundle large dependency
trees to keep the archive small. ZIPs larger than 32 MiB are rejected
with HTTP 413 before creating a deployment. The extracted-size,
entry-count, and per-file limits are enforced during the asynchronous
build; an accepted upload that exceeds them fails the build.

For example, a self-contained ESM bundle needs only index.mjs
at the ZIP root. The Neon CLI bundles source into this layout by
default; neon function deploy --no-bundle packages a prebuilt
directory or an entry file named index.mjs or index.js.

string
enum
Allowed:
string

Optional JSON object (a string-to-string map) of environment
variables for the deployment, e.g. {"KEY":"VALUE"}. Carried as a
JSON-encoded string because multipart form data does not support
typed object parts.

Values are write-only: they are encrypted at rest, and responses
carry only the variable names (the environment array), never the
values.

Responses

Language
Credentials
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json