Ways to deploy to Turn Zero Cloud #

View this page as Markdown

On this page

This page is mainly for AI assistants to use directly. It explains how to choose among the ways to deploy an app to Turn Zero Cloud. For a new app, start with serverless for static files, functions that fit their limits, or both. A link shortener can look up a link and redirect the visitor in one function. Choose a server if the app needs anything on the server checklist. Examples include a WebSocket or another long-lived connection, work that continues after a reply, and an existing Express server.

With a shell and the whole app folder, use turnzero where it works. Use it from the first deploy of an app to keep. Where it works, use it for binary files, later deploys, creating app files or running locally. Try command_npx first (command_npx_windows on Windows). No global install is needed. A first simple test app to discard can use deploy_files within its limits if none of those uses applies.

If you have no shell or no usable turnzero command, use deploy_files within its limits. If npx cannot run, try turnzero --version. If that works, use the command route. If a route refuses permission, choose another route. Use the upload route with a shell for anything beyond the deploy_files limits. Install the command only if the person wants to keep it. If you have no shell, skip local runs and tests. If you cannot read a binary file, ask the person to upload it on the app's page, then use stored. Ask for commands if no route works.

With no shell, use deploy_files through your signed-in Cloud connection, including for an app the person will keep. Use only a route your tool permits, and tell the person which route you chose and why. Choose how to supply each file:

File What to send
Text up to 512 KiB Send its complete text as content.
Binary file up to 512 KiB whose exact bytes you can read Send those bytes as base64 in content, with encoding set to base64.
File over 512 KiB, or one whose exact bytes you cannot read Ask the person to upload it, then name it in a stored entry as described below.

For a stored entry, call list_storage_areas and choose an area bound to the application. If none exists, call declare_storage_area. Ask the person to upload the file from the application's page and tell you its stored filename. Include the area and name in a stored entry of deploy_files. Do not call mint_upload_grant for this page upload. Upload it to the environment you will deploy to. A stored entry reads that environment's files.

The 512 KiB limit counts decoded bytes; base64 does not raise it. Stored entries have no per-file cap. The complete deployment must fit within 4 MiB and 200 listed entries. Filled library files count toward the bytes, but not the listed entries. Each JSON request also has a 4 MiB bound.

Beyond the total or entry limit, ask the person to deploy from a computer with a shell. You cannot run a command or the ZIP upload line without one. For an app within the limits, follow Deploy from a chat for the complete file list, checks and deploy.

Tell the person the limits before deploying. Local runs and tests need a shell; this route writes no project files on the person's computer.

You do not need to identify your permission mode or network policy in advance. With a shell, run the returned command_npx once (command_npx_windows on Windows), or try npx --no-update-notifier -y turnzero@next --version. Do not skip this check because a session note or a guess says the network is off. A refused command, install, authorization, or connection tells you which alternative to use. A tool may refuse the global install even when it permits npx.

Your tool's permission to run a command is separate from its shell's network access. If the command cannot reach turnzero.ai or the npm registry, explain that the tool's setting for its shell's network access controls this. A change to that setting takes effect in a new chat. Ask the person before switching to the file route.

Before choosing the file route for any reason, tell the person its limits. deploy_files alone provides neither the scaffold's local tests nor a local run. If you have no shell, or your shell is elsewhere, this route writes no project files on the person's computer.

The turnzero command's npm package is turnzero, with no @turnzero/ scope; run it as npx turnzero@next.

These routes deploy application files. To restore, export, or inspect production data with PostgreSQL tools, use Connect to your database from a computer with a terminal and the tools installed.

Prerequisites #

For code that already runs elsewhere, start with Bring an existing application.

Check that your Cloud connection is signed in. Create the application and submit its manifest as Deploy from your computer describes, regardless of the route you choose.

After submitting the manifest, call check_deploy before the first deploy and after fixing what it reports, whichever route you use. Resolve its refusals. This call checks platform readiness, not your code.

A readiness result from check_deploy includes without_command, even when it lists readiness refusals. The response also includes the check command and its npx and Windows forms if you call it with a token you created or sign in outside a hosted chat connection. A hosted chat connection receives no command. Having a shell does not by itself determine which forms the connection receives.

A code-only check is recommended, not required. A deploy runs the same code checks. If those checks refuse the deploy, it creates no version and counts no deploy.

To check with the command, run the returned check command where the command, network access and computer credential are available.

To check through deploy_files, use the returned without_command call with the complete file list and check_only: true, as Deploy from a chat describes. Resolve any refusals before deploying. This check uses your signed-in MCP connection and needs no computer authorization, even when you have a shell. This file check keeps passing files even if a later check refuses the request. The daily cleanup removes them after they have been kept for a day, unless a version that is serving or deploying still uses them.

If the check command cannot run and your files exceed deploy_files' limits, follow Upload a ZIP without the turnzero command below. A clear check_deploy answer does not mean the ZIP has been checked. On this route, the deploy call is the ZIP's only platform check. If it refuses the ZIP, no version starts.

In Windows PowerShell, type npm.cmd, npx.cmd and turnzero.cmd instead of npm, npx and turnzero, keeping the same arguments.

Local tests without npx #

A shell with Node.js 24 or later can still run local tests when npx or the turnzero command cannot run. Choosing deploy_files does not run those tests for you. Prepare and run them before the first deploy, then again after code changes.

Read the complete example and write its application and test files into the approved project folder. Use the application paths in its file table, without the download URLs' .txt suffix. Read each required entry with read_library, naming it in entry, and follow the returned file paths to fetch the complete package.

Write each package under lib/<entry>/, with its package.json at that folder's root and its lib/ directory inside it. Keep the example's root file:lib/… dependencies. Use the returned library versions in the manifest.

If npm works, run npm install, then the example's npm test, from the application folder. On Windows, use npm.cmd. These commands need the dependencies the example names, including its test dependencies.

For the unchanged server-ai-chat example, a shell without npm can use complete copies of its two packages:

  • Copy the Account package to node_modules/@turnzero/account/.
  • Copy the AI Generation package to node_modules/@turnzero/ai_generation/.
  • Keep each copy's package.json and its lib/ directory, including the testing modules. Run node --test from the application folder.

Those packages need no further npm dependencies. Their testing exports provide the doubles the example's tests use. A modified app may need more dependencies. The notes example also needs pg and PGlite; copying only its Turn Zero packages is insufficient.

Leave node_modules and the library folders Cloud fills out of deploy_files, as the file route requires. Local copies let tests run; they do not change what Cloud fills for a deploy.

If the files, dependencies or test command cannot be made available, report local tests as not run and give the reason. Distinguish checks run before deployment from those run afterward. A deploy, health response or page load does not establish that the tests ran.

Steps #

An application starts with one environment, production. If you deploy without naming an environment, the version goes live on production without a separate promotion. If the person turns development on, a deploy with no environment given goes to development; use promote to take that version to production.

1. Choose the route your environment supports #

If you can do this Route to use If it cannot work
Run the turnzero command through npx or a global installation, and reach turnzero.ai Use the returned npx form from the first deploy of an app the person will keep. A first simple test app the person will discard can use deploy_files within its limits when none of those command uses applies. If npx is refused, try the installed command when available. Otherwise, use deploy_files within its limits, then the upload route past them. Install the command only if the person wants to keep it.
Run CLI commands and access the turnzero.ai REST APIs, but cannot run turnzero through npx or a global installation Use deploy_files within its limits, and the upload route past them. Ask the person for the step you cannot perform if neither route works.
Run CLI commands, but cannot access the turnzero.ai REST APIs from that shell Use deploy_files through the signed-in MCP connection, within its limits. Explain the missing network access or size limit; ask the person for an available route.
Use the MCP connection but have no shell Follow Build from a chat AI (no terminal), using deploy_files. For a binary file you cannot read, ask the person to upload it from the application's page, then name it in a stored entry. Stored files still count toward 4 MiB and 200 entries. Beyond those limits, ask the person to deploy from a computer with a shell.
Run an automated pipeline with no AI or MCP connection Use the turnzero CLI command with a preconfigured minted token, or the authenticated HTTP API. Fix the missing credential, tool, or network access before retrying.

A desktop or cloud workspace follows the same table. For example, a workspace may reach turnzero.ai but not the npm registry. Within deploy_files' limits, use deploy_files. Past them, the upload route can still work through curl or PowerShell even though installing the turnzero CLI command cannot.

2. Deploy using that route #

Route What it needs Limits and details
deploy_files in one call A signed-in MCP connection. Send the complete file list with contents or stored entries. Inline files: 512 KiB each. Stored entries have no per-file cap. Both count toward 4 MiB total and 200 entries; filled library files count toward the total. The JSON request also has a 4 MiB bound.
deploy_files in several calls The same connection. Send contents first, then the complete file list using the hashes in kept. The same limits apply. Splitting calls does not raise the 200-entry limit on the final list.
The turnzero CLI command A shell, Node.js 24 or later, access to the npm registry and turnzero.ai, and computer authorization or a minted token. Zips and uploads text and binary files. The finished ZIP is limited to 32 MiB on Turn Zero Cloud.
The upload route A signed-in MCP connection, and a shell that can ZIP the folder and run curl 7.76 or later, or PowerShell, with access to turnzero.ai. Run curl --version to read its version on the first line. Needs no Node.js, turnzero installation, or standing computer credential. The same ZIP upload limit applies.
Authenticated HTTP deploy A script with access to turnzero.ai and a minted token kept outside the chat. Uses the command's ZIP deployment API and upload limit.
The person runs a command Explain which step you cannot perform and give the person the exact command needed. Use this after the available in-tool routes cannot complete the deploy.

For deploy_files, send text as content, or binary bytes as base64 in content with "encoding": "base64". Inline files are limited to 512 KiB of decoded bytes; base64 makes the request about a third larger. To include a file from storage, use { path, stored: { area, name } }; the platform copies its bytes exactly. Stored files have no per-file cap, but still count toward the 4 MiB total and 200 entries. Store the file in the environment that the deploy targets.

The route rule above applies even to one binary file, such as an icon. Binary files need their original bytes. An image preview alone does not provide them. If no available tool can read those bytes, leave the deploy pending. Ask the person to upload the file from the application's page so you can use a stored entry, or to deploy the original folder from a computer with a shell.

Leave out node_modules and the Turn Zero library package copies (lib/<name>) the platform fills. Filled library files count toward 4 MiB, but not the 200 listed entries. Follow Deploy from a chat for the file list, library versions, and successive calls.

For the turnzero CLI command, follow Authorize this computer for deploys, then Deploy from your computer. Try your call's command_npx first, or command_npx_windows on Windows. Signing in your AI assistant does not by itself authorize the command. deploy_files needs no such authorization; it uses the signed-in connection.

For the upload route, follow Upload a ZIP without the turnzero command below. It uses a storage area you declare for the application, not its reserved deploy area.

A ZIP may contain up to 65,535 entries. Its size limit for this check is 128 MiB, using the larger of the compressed and uncompressed sizes recorded for each entry. Root package.json and manifest.json each have a 1 MiB limit. See the artifact refusals for the remaining checks.

Turn Zero Cloud limits the upload to 32 MiB (33,554,432 bytes) of the finished ZIP. This applies to the command and the storage upload route. Follow any smaller limit the grant's max_bytes gives. Compression can let a ZIP within the upload limit carry more declared entry data.

To reduce an oversized ZIP, leave out files the application does not need. Files it serves at run time can instead use storage, with each upload within its own byte limit. If the ZIP still cannot fit, ask the person what to leave out. Switching ZIP routes does not raise the limit.

For a server application, during the deploy the platform installs the runtime dependencies package.json names, not devDependencies, taking the versions package-lock.json records where they still meet the package's ranges. Leave node_modules out on every route, including a ZIP you make yourself. Its ZIP still includes the Turn Zero library package copies your application imports; only deploy_files fills them from the library.

For a pipeline, prepare the application and its services beforehand. Store its minted token in the pipeline's secret store as TURNZERO_CLOUD_MINTED_TOKEN; never paste the token into chat. Deploy with nobody at the keyboard explains the setup; the deploy reference describes the HTTP forms.

Upload a ZIP without the turnzero command #

Use this route when your shell can reach turnzero.ai and run curl or PowerShell, but cannot run the turnzero command. Your signed-in MCP connection makes the management calls; the shell reads and uploads the local file.

  1. Build the app if needed, then ZIP the deployable folder and compute the ZIP's SHA-256. For a server application, keep package.json at the root and include the library copies the app imports. Leave out node_modules, credentials, and AI-tool configuration files. Follow What the deploy ZIP holds and the ZIP and SHA-256 commands in Build and upload the artifact.
  2. Call list_storage_areas to find an area bound to this application, or declare_storage_area to create one. Call mint_upload_grant with application, area, the ZIP's stored filename as name, and its local path as local_path. Set environment to production with one environment, development with two. The returned max_bytes is this upload's byte limit; Turn Zero Cloud limits the finished ZIP to 32 MiB even when a grant is used. Do not use deploy-<application id>; it accepts only the deploy command's own upload grant.
  3. Run the returned commands.curl or commands.powershell line exactly as given, before expires_at. Confirm that the upload succeeded. An upload grant from your tool explains the commands, timeouts, and recovery from an unknown result.
  4. Call deploy with the application and artifact containing the area, stored filename as name, and the ZIP's SHA-256 as hash (64 lowercase hexadecimal characters). Set artifact.environment to the environment holding the ZIP. That selects the stored file. The deploy goes to production with one environment or development with two; reaching production from development requires promote.
  5. Follow Read the result using the returned read_status call. If a response is lost, read status before retrying. The deploy may already have started.

A chat AI with no shell cannot run the upload line. Ask a person with a terminal for that step if no available in-tool route can finish the deployment.

When to ask the person #

Try the available routes before handing work back. Ask for one step at a time, explain what was refused and why, then wait for the result.

  • The MCP connection is not signed in: ask the person to sign in.
  • An install or upload command is refused and no available route remains: give the person that exact command to run in their own terminal. Continue from its result, giving the next command only when it is needed.
  • Authorization is refused and no available route remains: ask the person to run turnzero login --origin https://dev.turnzero.ai in their own terminal. Give the browser-login steps, one at a time.
  • turnzero deploy --origin https://dev.turnzero.ai is refused and no available route remains: give the person that exact command to run in their own terminal.
  • You have no shell and cannot read a binary file: declare a storage area with declare_storage_area if the application has none. Ask your user to upload the file from the application's page and tell you its stored name. Use that name in a stored entry.
  • You have no shell and the app exceeds 4 MiB total or 200 entries: ask your user to deploy from a computer with a shell.
  • Your shell cannot reach turnzero.ai and the app is past those limits: explain that the deploy needs access to turnzero.ai; ask the person to provide an authorized environment or deploy from their own computer.
  • Node.js is below 24 on the person's computer: explain the required version and let the person decide whether to update it.

Never suggest changing your tool's permissions to bypass a refusal. Never ask the person to paste a token value into chat.

The deploy in one pass #

Once the application exists and its manifest is recorded (steps 1 and 2: Create the application and Declare the manifest), a deploy is one call, one command, and one read.

You call tzcloud_deploy_command with the application identifier and nothing else.

{ "application": "<application id>" }

The response returns 200 and state: "awaiting_command". If you use a hosted connector, follow detail to deploy_files. The connector returns no command. Other sessions receive command_npx, command_npx_windows, and the installed forms command and command_windows. If the command returns before the deploy ends, follow next to tzcloud_read_status.

If the account has no authorized computer, the response also includes authorize, shown below. Run authorize.command_npx or authorize.command_npx_windows on Windows first, with nothing piped. Make the mint_token call it prints and run the returned command. Then run the deploy command.

The response omits authorize when the account has an authorized computer, when the connection uses a minted token, and on a hosted connector session.

If you run the command on a temporary computer, authorize that computer for this Cloud address even if your account has already authorized another one. An unattended job can supply its own minted token through TURNZERO_CLOUD_MINTED_TOKEN. See Authorize this computer for deploys.

MCP always names tzcloud_deploy_files in fallback, even with a minted token or an authorized computer. HTTP omits the tzcloud_ prefix. Use the command where it runs. Otherwise use tzcloud_deploy_files and tell the person why. detail, omitted below, names the target environment.

Choose the command form this way:

  • For the deploy itself, run command_npx first, or command_npx_windows on Windows. It works whether or not turnzero is installed globally.
  • If npx can't run here, use the installed command when turnzero --version responds. Otherwise, use tzcloud_deploy_files within its limits, then the upload route past them. Install the command only if the person wants to keep it.
  • If npm install -g turnzero@next can't run here, try the available deployment routes before asking the person to run a step.
  • A person or a job may use any of the four forms.

The response looks like this:

{
  "application": "<application id>",
  "environment": "production",
  "state": "awaiting_command",
  "fallback": "tzcloud_deploy_files",
  "authorize": {
    "command": "turnzero authorize --origin https://dev.turnzero.ai",
    "command_windows": "turnzero.cmd authorize --origin https://dev.turnzero.ai",
    "command_npx": "npx --no-update-notifier -y turnzero@next authorize --origin https://dev.turnzero.ai",
    "command_npx_windows": "npx.cmd --no-update-notifier -y turnzero@next authorize --origin https://dev.turnzero.ai"
  },
  "command": "turnzero deploy --origin https://dev.turnzero.ai --application <application id>",
  "command_windows": "turnzero.cmd deploy --origin https://dev.turnzero.ai --application <application id>",
  "command_npx": "npx --no-update-notifier -y turnzero@next deploy --origin https://dev.turnzero.ai --application <application id>",
  "command_npx_windows": "npx.cmd --no-update-notifier -y turnzero@next deploy --origin https://dev.turnzero.ai --application <application id>",
  "next": { "action": "tzcloud_read_status", "arguments": { "application": "<application id>", "environment": "production", "wait_seconds": 45 } }
}

Run the deploy command once, as given, in the application's folder, or the folder local_path is relative to. The command zips the folder, uploads it, starts the deploy, and prints each step.

On the first deploy from a folder with no application in manifest.json, the command writes the application there and prints bound:. Later commands naming another application are refused. On a first deploy, tzcloud_deploy_command warns of this before you run it.

The deploy’s own last line is address: https://<hostname>/, after settled: deployed version 1, and the run ends with status 0. A notice that a newer turnzero is available may follow that line. The same command deploys each later version too: it contains no grant and no version, so you run it again, as given, after each change.

Where the command returned before that, you make the next call, tzcloud_read_status with wait_seconds. It waits up to 45 seconds for the deploy to end before it responds.

{ "application": "<application id>", "environment": "production", "wait_seconds": 45 }

Read the environment named in the tzcloud_deploy_command response. Once the deploy in that environment shows deployed, confirm that the intended version is serving there. Request each changed read-only route on that environment’s hostname. Without a shell, use tzcloud_request_route and pass that environment. Then read errors as Check the release describes.

If a route returns an unexpected HTTP error, follow the tzcloud_read_logs call in the response’s detail when it appears. It uses x-request-id to find any retained 5xx router record and app logs your code tagged with that ID. The same detail names a separate console read for a server or function. Match a failed request to its logs.

Before you choose a server size, check what you expect to use. For example, a Shared 0.5 GB production server costs $5 if it stays awake all month. A shared database costs $5 per app for a full month, plus $0.125 per GB of database storage for a month. File storage costs $0.02 per GB for a month. For an estimate before you deploy, open Small app in the pricing calculator. It also accounts for server awake time and data transfer.

3. Read the result #

Read read_status with wait_seconds for the environment the deploy targets until it ends. For a server application, request its health path; for a static site, request a published file. Use the hostname that read_status returns with curl in a shell. Without a shell, call request_route with environment set to the environment the deploy targeted.

To confirm a fix, request the route that showed the problem and compare its answer with the expected one. If that answer is insufficient, read the application's logs for the new version.

If a response is lost or comes from outside Turn Zero Cloud, read read_status first. Match the kind, version and start time. If its latest row leaves the outcome unclear, read list_versions for that environment before retrying. Retry an uncertain start only when the history confirms it did not start. Use pending_upload.retry where the reply gives it. While a deploy is running, the same artifact hash or the same prepared upload ID can return that deploy. Once it ends, sending the same bytes again can start a new deploy that counts toward the day's limit.

Expected result #

The deploy reaches deployed. A server application's health path succeeds; a static site's published files load. Report the version and hostname returned by the platform. If the deploy is still running or failed, report that state instead. A failed deploy can leave data the new copy wrote while the old version keeps serving.

Refusals #

What you see Cause Remedy
deploy_files_too_large An inline file exceeds 512 KiB, or the app exceeds 4 MiB or 200 entries. For an oversized inline file, use a stored entry. This does not raise the total or entry-count limits. Beyond those, use the command or ZIP upload route; with no shell, ask the person to deploy from a computer with a shell.
request_too_large (HTTP 413) A ZIP exceeds its upload limit, or a deploy_files request body exceeds 4 MiB. For a ZIP, make a smaller ZIP. For deploy_files, send smaller batches and use their retained hashes in the final list. If that list still exceeds the total size or entry limit, use the command or upload route.
artifact_not_found (HTTP 404) The ZIP is absent from the named area and environment. Check the stored name and the environment in artifact.
artifact_area_mismatch (HTTP 403) The ZIP's area cannot be used for this application. Upload to an area bound to the application. Use that area in artifact.
artifact_hash_mismatch (HTTP 400) The stored ZIP differs from the SHA-256 in artifact.hash. Confirm the intended ZIP, then compute the SHA-256 from that exact file.
Installation, authorization, or command execution refused Your tool's own permission check refused the step. Respect the refusal. Use another available route, telling the person which route and why; do not bypass the host's controls.
The shell cannot connect to turnzero.ai The network the shell runs on cannot reach turnzero.ai. Use the MCP route within its limits, or explain the network access the person needs to provide.
No valid sign-in or token Your tool holds no signed-in connection, or this computer holds no token. Follow Connect your AI assistant.

Deploy troubleshooting starts from the failure you see, and Refusals lists the platform's named errors.

For a site of HTML, CSS and images, Publish a static site shows how to deploy the files as a serverless application.