POST
/projects/{project_id}/branches/{branch_id}/functions/{slug}/deploymentsCreate a function deployment
Creates a deployment for a function on a branch. Supply at least one of zip, environment, or runtime; omitted fields inherit the function's latest version. The first deployment must include zip, and the newest deployment becomes active.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
project_idstringrequired
The Neon project ID. Must contain 1–60 lowercase letters, numbers, or hyphens.
branch_idstringrequired
The Neon branch ID. Must contain 1–60 lowercase letters, numbers, or hyphens.
slugstringrequired
The function slug. Must contain 1–20 lowercase letters or numbers.
Multipart form data for a function deployment. Supply at least one field; the first deployment must include zip.
zipstringoptional
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`.
runtimestringoptional
The function runtime. The only supported value is `nodejs24`.
environmentstringoptional
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.
201Returns the created deployment, including its ID, status, memory allocation, runtime, creation time, and any environment or error details.
deploymentobjectrequired
defaultGeneral Error.
The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.
- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.
The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.
Any request that returns a `503 Service Unavailable` response is always safe to retry.
Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.
request_idstringoptional
Unique identifier for the request, useful for debugging.
You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
codestringrequired
Machine-readable code classifying the error type. See `message` for a human-readable explanation.
messagestringrequired
Error message
Error handling
The project_id path parameter and branch_id path parameter must each contain 1–60 lowercase letters, numbers, or hyphens; the slug path parameter must contain 1–20 lowercase letters or numbers. Supply at least one of zip, environment, or runtime; the first deployment requires zip, and runtime must be nodejs24 if provided.