---
title: Manage versions and environments
description: Roll production back, read the version history, halt, resume, or restart an environment, rename an application, or delete it or its development environment.
slug: /guides/manage-versions-and-environments
order: 25
visibility: public
redirects_from: []
---

# Manage versions and environments

Prompt:

> Checkout broke with the last release. Roll production back to the version before it.

Also works:

- "What did we deploy this week?"
- "Stop the development environment for now."
- "Rename this application to parts-search."
- "Delete the test application."

Your AI assistant rolls production back with `tzcloud_list_versions` and `tzcloud_roll_back`. A rollback brings back the earlier version's code and recorded settings. Database changes already made stay in place. On a serverless app, rollback can run migrations that production has yet to apply ([Roll back](#roll-back)). It halts, resumes, or restarts an environment with one call each. The signed-in site also offers **Pause app** and **Resume app** ([Halt and resume](#halt-and-resume)). A rename or a deletion waits for your approval in the browser.

## What your AI does

- For a rollback, reads the `release` [skill](/cloud/concepts/glossary/#skill) (`read_context`, id `skill:release`) and follows it. It rolls back only when you say so. A rollback needs no separate browser approval.
- Calls `tzcloud_list_versions` when you ask what was deployed, narrowed to one environment if you name one.
- Before halting production, [asks for your yes unless you already asked](#halt-and-resume). Calls `tzcloud_halt_environment` to halt an environment, the same tool with `resume: true` to resume it, or `tzcloud_restart_application` to restart it. Each runs without a separate approval page. The signed-in site's **Pause app** and **Resume app** controls make the same halt and resume actions ([Halt and resume](#halt-and-resume)).
- For a rename or a deletion, calls `tzcloud_rename_application`, `tzcloud_delete_environment`, or `tzcloud_delete_application` and prints the approval link in the response. After you approve in the browser, it reads the outcome with `read_approval_status`.
- Requests browser approval to lift an application deletion lock. Setting the lock needs no browser approval.
- Reports the version production serves, the environment's `halted` member, or the [pending action](/cloud/concepts/glossary/#pending-action)'s outcome, and writes nothing into your project.

## What you need

- For renaming or deleting an application, sign in to a browser with the same account, because you approve that action there yourself.

## Before your AI starts

**For the AI assistant:** Check the following before starting.

- Your AI assistant connected and signed in ([Connect your AI assistant](/cloud/getting-started/connect-your-tool/)).
- An application deployed as [Deploy from your computer](/cloud/getting-started/deploy-an-application/) describes. A rollback needs an eligible deployed version. If production serves a version, choose an earlier one.
- For a production halt, your signed-in session or a [token](/cloud/concepts/glossary/#minted-token) minted for the whole account.

## Steps

Choose the section for the task you need. You can do each task independently. The guide starts with a rollback, the most common task.

### Roll back

If production starts answering errors after a release, call `tzcloud_read_status` with `environment: "production"`. Compare `application.version`, the version serving now, with the last operation under `application.environments.production.deploy`. Read that operation's state and outcome. If the last attempt failed and the earlier good version is still serving, read the failed operation's outcome for the cause before making another switch.

For an error from a version already serving, trace the failing route using its response's request ID and the time it failed. See [From a 5xx record to the error your application wrote](/cloud/guides/read-logs-and-counters/#from-a-5xx-record-to-the-error-your-application-wrote).

In `tzcloud_read_status`, `application.kind` is `server` or `serverless`. A value starting with `database-dedicated-` in `application.environments.production.database_size` means production has a dedicated database.

Call `tzcloud_list_versions` for production to find the version it served before the release. On an app with development, a rollback may also name an eligible development-only version. Omit `environment` to include those versions or when production serves nothing. If production serves a version, choose a lower number.

```json
{ "application": "<application id>", "environment": "production" }
```

The response lists the rows newest first and gives the current production version in `serving.production`. If production serves a version, find an earlier deployed row with `promotable: true`. Use the most recent eligible version you know worked on the affected route. Use the version history and the last good response or check to establish that. If production serves nothing, choose an eligible deployed version you have reason to trust. With `promotable: true`, Cloud still has the build and any client files the version published. Cloud excludes builds marked for deletion.

Your AI assistant needs your request or agreement before it rolls back. If the rollback crosses a migration, it explains that the migration's schema and data changes stay in place. Check that the target version can read and write with the current schema. If unsure, test against a copy before rolling back. If Cloud promoted the newer version to production, it took no database snapshot at that promote. It waits for you to decide what to do about the data before it calls `tzcloud_roll_back`.

Once it has your agreement, your AI assistant calls `tzcloud_roll_back` with that version. Pass `wait_seconds` as a whole number from 1 to 45. If the operation is still running when the call returns, follow the returned `next` call.

```json
{ "application": "<application id>", "version": 41, "wait_seconds": 45 }
```

A rollback [promotes](/cloud/concepts/glossary/#promote) the version you name. A server rollback reuses the version's image and creates a new production [platform credential](/cloud/concepts/glossary/#platform-credential). A serverless rollback reuses its stored client files and any function tree. A server rollback uses the current manifest's health path and keeps the database password.

A serverless rollback creates a production platform credential only for a version with functions. The database credential stays the same. It takes `wait_seconds`, 1 to 45, as a promote does ([Promote to production](/cloud/guides/turn-on-development-and-promote/#promote-to-production)). The response then waits until the rollback ends, and returns HTTP 200 with `state` `deployed` or `failed` and the record's `outcome`.

Without `wait_seconds`, or when the wait ends before the rollback does, the call returns HTTP 202 with `state: "deploying"`. Both 202 responses include `next`, the exact `tzcloud_read_status` call that follows the rollback until it ends. That call names `environment: "production"`, so the top-level members describe production. A settled HTTP 200 response has no `next`.

Use `tzcloud_read_status` to confirm that production serves the version you chose and that the matching rollback succeeded, even if the rollback returned HTTP 200. On the same production hostname, repeat the affected route if it leaves data unchanged. Report the response. If the route writes data or you cannot tell what it changes, tell the owner what you could verify and agree on a safe check before making the request.

When a server rollback that replaces a serving version shows `deployed`, every router already sends production's hostname to the version you named. The switch waits until the rollback is 10 seconds old, and the record turns `deployed` 3 seconds after it. So that server rollback takes at least 13 seconds. The response's `summary` and `detail` say how it ended, and `health_path` names the path the [health check](/cloud/concepts/glossary/#health-check-and-health-path) probes. A serverless rollback runs no container check and records `deployed` at its finish write.

If the reply is lost or comes from outside the platform, its outcome is unknown. Read production with `tzcloud_read_status`. Match the version and start time to your request. A rollback is recorded as a `"promote"` row. If the latest row belongs to another attempt, check production's rows in `tzcloud_list_versions`. Roll back again only where none started for your request. On a rollback row in `tzcloud_list_versions`, `rolled_back_from`, when present, names the production version the rollback replaced.

`tzcloud_roll_back` works on every application, including one with a single environment, where `tzcloud_promote` itself is refused. On a one-environment application, the eligible version comes from production's own deploy history.

If production serves a version, a rollback to it is [refused](/cloud/concepts/glossary/#refusal) 409 `version_already_serving`. A rollback to a newer version is then refused 409 `version_newer_than_serving`; use `tzcloud_promote` on an application with two environments, or deploy that code again on one. A number that no deployed row has is refused 404 `no_such_version`. If retention has marked the build for deletion or removed it, the rollback is refused 409 `version_image_pruned`. If its client files were deleted while the deployment is still kept, the rollback is refused 409 `version_client_pruned`.

Choose a version still marked `promotable`, or deploy the earlier [artifact](/cloud/concepts/glossary/#artifact) again as a new version. While production is halted, a rollback is refused 409 `target_environment_halted`.

A rollback uses the earlier version's recorded plain settings and its recorded links to secrets. Each link reads the secret's current value in production. Use `tzcloud_read_logs` with `environment: "production"` and `source: "platform"` to check for warnings about settings the new copy did not receive. The platform takes no database snapshot at a promote. A serverless rollback runs the target version's saved migration files before the version serves. Files already recorded in production stay applied. Files production has yet to record can run, even if the target version never served there. If a later file fails, the earlier files stay applied.

Decide separately how to handle changes to the database. To [restore a dedicated database](/cloud/guides/add-a-database/#restore-a-dedicated-database), choose a restore time with the owner and get separate approval. For Cloud's serverless migrations or the Database package, read the file's `applied` time in production's `schema_migrations` table. For other tools, read their migration records. A successful restore discards writes made after the chosen time. The reserved HTTP action `apply_migration` returns 501 `not_yet_provisioned`. [What a promote does to production's database](/cloud/guides/turn-on-development-and-promote/#what-a-promote-does-to-production-s-database) explains what the [migration walk](/cloud/concepts/glossary/#migration-walk) does when the version starts.

### The version history

`tzcloud_list_versions` returns the application's history newest first, with `kind` set to `"deploy"`, `"promote"` or `"restart"`. A [platform redeploy](/cloud/concepts/glossary/#platform-redeploy) appears as `"restart"`. Use `environment` to limit the response to one environment. Use `limit` and `cursor` to read it in pages. On every page, the response's `serving` names the number of the version each environment serves. `tzcloud_read_status` also names it, without the history. The [`tzcloud_list_versions` reference](/cloud/reference/actions/list-versions/) lists each row's members.

Two members say what a row can be used for:

- `serving` is true on the row of the version each environment runs.
- `promotable` is true on an unretired deployed row whose build and any published client files are still kept, unless the platform has marked the build for deletion under its retention rules. Use it to choose a version for `tzcloud_promote` or `tzcloud_roll_back`. Decide separately whether to move production to that version.

For each server environment, the platform keeps the images of the twenty most recent deployed versions, including the serving version, and deletes older images once a day. Once retention marks an image for deletion, the row shows `promotable: false` and a promote or rollback is refused 409 `version_image_pruned`, even while the image is still present.

The daily cleanup keeps client files for three distinct deployed versions in each environment, with the serving version first. It keeps a version's files when either environment keeps it or a deploy or promote of it is in progress. Redeploying the same version does not take a separate place.

Once a version's client files are deleted, its row shows `promotable: false`. A promote or rollback is refused 409 `version_client_pruned` if its image or serverless deployment is still kept. A version that published no client files can still be eligible while its build is kept. The history leaves out the rows of a deleted environment.

For servers, two more members describe the [runtime harness](/cloud/concepts/glossary/#runtime-harness), the platform's code built into the image beside your application. `harness_hash` is the SHA-256 of the harness in the row's image, or null where the platform did not record it. `harness_current` is true where that harness is the one the platform builds into new images today. Only a new server deploy gives a version the current harness, because a promote reuses the image as it is.

`artifact_hash` is the SHA-256 of the deployed ZIP. After a command-line deploy, run `turnzero hash --origin https://dev.turnzero.ai` in the application folder to reproduce it with the same Node.js version and unchanged deployable files. If the first deploy adds `application` to `manifest.json` after making its ZIP, the folder's hash then differs; subsequent deploys include that member. For a serving version, `kept` lists file paths and hashes only when `tzcloud_deploy_files` supplied its files, and is null for other deployment routes.

A rollback and a promote both write a `"promote"` row with the number of the version they promote. On an application with one environment, each deploy writes a production row of kind `"deploy"`. So the history shows which version production served, and when. [The version history](/cloud/concepts/applications-and-environments/#the-version-history) explains how the serving version is determined.

A restart writes a `"restart"` row with the number it restarted, so a `"deploy"` row and a `"restart"` row can carry the same number. Read `environment` and `kind` beside the number. Use `serving: true` to find the row an environment runs now. For a server, both rows refer to the same image. For serverless, both refer to the same version's files and any function tree. On a rollback row, `rolled_back_from` gives the number it replaced, where one was serving.

Each ended row's `outcome` starts with `result`: `succeeded`, `failed`, `interrupted`, or `superseded`. Each row's `timings` lists the steps it went through, with when each began and ended.

For a server version, `succeeded` means the health path returned 200 three times in a row within the check's time limit. A server deploy or a server promote of a version production does not already serve also passes any configured smoke paths. A rollback sends no smoke requests. When a server version replaces one already serving, the platform waits briefly for its routers to pick up the switch before it reports success.

A serverless version runs no container health check or smoke check. Its finish write makes it the serving version. A newly serving version can still have work left, such as restarting schedules or revoking older credentials. Cloud retries those steps if they fail. Job setup gets one try. If a job cannot start because setup failed, restart that environment to try setting it up again.

No other path is checked, so a failing route shows in `tzcloud_read_status`'s `server_errors` once a request reaches it. A single request ended with `upstream_ended` (the router's answer when the application's own process ends before it responds) just after a switch may be retried where repeating it is safe.

After a failed first promote, or a failed first deploy of an application with one environment, production has no serving version. `tzcloud_list_applications` and `export_account` then return the application's own `state` as `failed`, the same value production's environment shows. The application page on the signed-in site shows it as Failed to reach production. Once a promote or a production deploy succeeds, the state is `deployed`. A promote or deploy that fails while a version is serving leaves the state `deployed`.

### Deploying a new version

Deploy the new build with `turnzero deploy --origin https://dev.turnzero.ai`, following [step 3](/cloud/getting-started/deploy-an-application/#3-build-and-upload-the-artifact) with a new build, followed by the `tzcloud_read_status` wait of [step 5](/cloud/getting-started/deploy-an-application/#5-read-the-status). On an application with two environments, a promote then moves the new version to production. For a server, a new deploy also builds an image with the platform's current runtime harness. A version-history row of kind `restart` is not a new deploy: it restarts the running copy from the same build.

A development deploy gives the new copy the same development platform credential and creates no new one.

### Restart an environment

`tzcloud_restart_application` re-creates a server's [running copy](/cloud/concepts/glossary/#running-copy) from the version it serves. A serverless restart keeps the same served version. If that version holds functions, the platform writes their settings again from the version's recorded bindings. Use it after you rotate a secret the serving version already binds, so the app gets the new value on restart. It builds nothing and writes a `restart` row for the same version. It does not count against the application's deploys per day.

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

With `wait_seconds`, 1 to 45, it returns once the restart ends, as a promote does; otherwise it returns status 202 at once. Without `wait_seconds`, or where the wait runs out, its `next` is the `tzcloud_read_status` call for the restarted environment. It is refused while a deploy, promote, or restart of the environment is in progress. The HTTP action route's `store_secret` call with `replace: true`, a new `value`, and `restart: true` under your own bearer token starts the same restart. It restarts the environment whose running copy holds the old value ([Store a secret](/cloud/getting-started/store-a-secret/#3-replace-a-value)).

A server restart probes `health_path` from the current manifest. It switches no sooner than 10 seconds after starting and records `deployed` 3 seconds after the switch. A copy that is ready early waits in `finish`. The `switching` step is those 3 seconds. Serverless restarts have no such check or switch wait.

When a server restart switches traffic, it lets existing requests finish within the old copy's retirement window. The old copy keeps running for about 15 seconds after the switch, while the routers move to the new copy. Where it runs as a container, its log lines are marked `[retiring]` ([Read logs and counters](/cloud/guides/read-logs-and-counters/)). When the old process ends, each request it holds that has no response header yet is cut off: the caller gets 502 `upstream_ended`, and the `router` source records it.

A response that is not the platform's own, such as a gateway's error page or a closed connection, says nothing about whether the restart was made. Read `tzcloud_read_status` first: a restart that started shows as a `restart` row begun after your call. Restart again only where none did.

Use restart to load a new value for a secret the serving version already uses. It reads current values for that version's recorded [settings](/cloud/concepts/glossary/#setting) bindings. To apply a new binding, deploy or promote. A rollback re-applies the bindings its version last had in production, or those its deploy recorded where production never ran it ([Changing the manifest](/cloud/concepts/the-manifest/#changing-the-manifest)).

A bound setting is left out where its stored name no longer exists or a later rule rejects it. The application's log then shows a warning. The restart or rollback is never refused for it. Where the secret store does not return a value, the restart or rollback ends as failed with `bound_setting_unreadable` before anything is applied, and the serving copy is unchanged; try it again.

So a restart brings a rotated bound value into a running copy that already has the binding. A binding added since the copy was made waits for the next deploy or promote ([Store a secret](/cloud/getting-started/store-a-secret/#bind-a-value-to-a-setting)). `tzcloud_read_status` reports these cases for each environment:

- `rotated_since_read` lists each setting whose secret was stored or rotated after the running copy started, which a restart brings up to date.
- `bound_not_applied` lists each setting the manifest binds that the running copy lacks, which only the next deploy or promote applies. It also lists each plain setting whose value in the manifest the running copy lacks, by its name alone and never with the value.
- `settings_mismatch` lists each secret whose stored value differs from the value the running copy received. The platform compares two fingerprints, short codes it makes from each value with a key of its own. An entry reads `different`, which a restart applies, or `not_comparable`, where the two fingerprints were made with different keys ([The running copy seems to use the old value](/cloud/troubleshooting/secrets/#the-running-copy-seems-to-use-the-old-value-after-a-rotation)).

The response's `summary` counts the settings in each of the first two lists and names the list. It does not repeat the settings. Where either of those lists has an entry, or a name in `settings_mismatch` reads `different`, the environment's `settings_apply` says which action applies each list.

The lists are computed at every read. An empty `rotated_since_read` alone cannot confirm that the running copy has the stored value. Use `tzcloud_list_secrets` to check that `applied_settings` names the setting and that the stored and applied fingerprints match. [Check that a rotation reached the running copy](/cloud/getting-started/store-a-secret/#check-that-a-rotation-reached-the-running-copy) gives the three calls that confirm a rotation.

A restart sets each [declared upstream](/cloud/concepts/glossary/#declared-upstream)'s `sdk_settings` from the current declarations, with a new [egress key](/cloud/concepts/glossary/#egress-key) for each `key` setting that a provider's software development kit (SDK) reads ([An unchanged SDK](/cloud/guides/call-an-external-api-with-an-api-key/#an-unchanged-sdk)).

A server restart keeps serving requests on the old copy until the platform switches traffic. After the switch, requests still waiting for response headers can be cut off when the old copy stops.

### Halt and resume

On the signed-in site, open the application's page. With two environments, choose one with **Environment** below the heading. Beside its state, choose **Pause app** or **Resume app**, check the named application and environment, and confirm.

**Pause app** halts the selected environment. **Resume app** lifts that halt. An account pause blocks deploy, promote, rollback, restart, and resume. Use [the account pause checks](/cloud/troubleshooting/status-and-logs/#my-app-stopped-answering) if the visitor sees **This app is paused**.

Both controls need a sign-in within the last eight hours. Past that window, follow **Sign in again** in the control's place, then retry.

Pausing stops new scheduled runs. The application stops accepting new requests through each router after it refreshes. Work already running may be interrupted. The environment keeps its deployed version, data, files, and settings. On resume, schedules start from that instant. Runs due during the halt are skipped.

Your AI assistant asks you and waits for your yes before halting production, unless you already asked for the halt. With no prior approval and nobody to ask, it stops and reports. Halting development and resuming either environment need no question. A resume before a promote or rollback you agreed to needs no second ask.

Call `tzcloud_halt_environment` to halt an environment. Set `resume: true` to lift the halt. Both forms take the application identifier and the environment. The platform records the halt or resume before the call returns. Check the app's route to confirm whether it is serving.

```json
{ "application": "<application id>", "environment": "development" }
```

If `grain` is `pod` in `tzcloud_list_applications`, the app runs on a cluster shared with other applications. The halt returns after the platform records it and before the pod stops. Both the halt and resume calls return the environment's `halted` member and an `outcome` of `halted`, `resumed`, or `unchanged`.

After a resume, check the app's route if you need to confirm it is serving. `halted: false` confirms the halt cleared. A cold development copy can start on its next request or scheduled run. If the response reports that compute could not start, give the owner that detail.

A [halted environment](/cloud/concepts/glossary/#halted-environment) keeps its version, data, and credentials. Once a router refreshes, its hostname returns 503 `environment_halted` on every path. A router that cannot refresh can keep using the previous address. A deploy to development clears its halt after the start checks pass. The environment stays resumed even if the build or health check later fails. You can also resume it with `tzcloud_halt_environment` and `resume: true`. A production halt ends only at `tzcloud_halt_environment` with `resume: true`. Until then a promote or rollback to production is refused 409 `target_environment_halted`, and so is a deploy on an application with one environment.

Which credential can halt or resume:

- A production halt needs your signed-in session or a token minted for the whole account. A token limited to one application is refused 403 `account_credential_required`.
- `tzcloud_halt_environment` on development, and its `resume: true` form on either environment, accept your signed-in session, a token minted for the whole account, or a token limited to one application.

`tzcloud_halt_environment` refuses an environment with no deployed version, 409 `environment_never_deployed`. It also refuses one with a deploy, promote, or platform redeploy in progress, 409 `deploy_in_flight`. One case differs: on an application with one environment, halting production while a deploy is still building is accepted. It ends that deploy, which `tzcloud_read_status` then shows as failed, and nothing reaches production. Once the build is done, the halt is refused `deploy_in_flight` until the deploy ends, so call it again then.

The platform also halts an unused development environment itself. [The halted state](/cloud/concepts/applications-and-environments/#the-halted-state) says what each halt stops and when the platform halts an environment.

### Rename the application

`tzcloud_rename_application` requires the application identifier and a new valid name that differs from the current one. [Create the application](/cloud/getting-started/deploy-an-application/#1-create-the-application) gives the rules for a name. The call asks for a browser approval. The approval says both old hostnames will stop working for good. It also counts the passkeys and the invitation links that stop working with them.

When the approved rename runs, it retires both previous hostnames, and the [serving router](/cloud/concepts/glossary/#serving-router) starts serving both new ones within its refresh interval. Each new hostname combines the new name with a new key that the platform chooses at that moment. So read the exact new hostnames in the outcome with `read_approval_status`.

The rename has these effects:

- Both previous hostnames, production's and development's, stop working for good. A request to either is refused `unknown_application` and is never redirected to the new hostname. The platform never gives a retired hostname to any application again. Renaming the application back to its old name gives it new hostnames, not the old ones.
- The previous name is freed, so another application in the account can take it.
- Each passkey that an [end user](/cloud/concepts/glossary/#end-user) registered on a previous hostname becomes a [stranded passkey](/cloud/concepts/glossary/#stranded-passkey) and stops working. The person registers a new passkey on the new hostname. While a domain of your own is attached, the rename still retires the passkeys registered on the old managed hostname, and its approval counts them. Detaching the domain afterwards brings none of them back ([Attach your own domain](/cloud/guides/attach-your-own-domain/#what-changes-for-your-users)).
- An end user who is signed in signs in again on the new hostname, because the browser keeps the sign-in cookie for the previous hostname only.
- A sign-in code requested on a previous hostname cannot be confirmed after the rename. The person requests a new code on the new hostname.
- Each `https` redirect URI a native client declares on a previous hostname stops working, while one on a domain of your own keeps working. Update the redirect URIs using [the tool that owns the environment's client list](/cloud/guides/sign-in-from-a-native-app/#1-declare-the-client-on-each-environment-s-realm). Do this before raising a client's minimum version. Until then, a call that repeats the old URIs is refused `invalid_redirect_uri`, and a submission whose manifest still lists them is refused naming that error ([Sign in from a native app](/cloud/guides/sign-in-from-a-native-app/#1-declare-the-client-on-each-environment-s-realm)).
- An invitation link using a previous hostname stops working. The invitation itself can still be redeemed. Send the link again with the new hostname in place of the previous one. Or revoke the invitation by calling `tzcloud_invite_end_user` with its identifier in `invitation`, leaving out `email` and `products`, and issue a new one.
- Each deployed environment restarts, so its running copy's `APP_PUBLIC_HOST` setting names the new hostname without a deploy.
- Where a restart is refused, the outcome's `container` member names the refusal. That running copy keeps the previous hostname in `APP_PUBLIC_HOST` until `tzcloud_restart_application`, or the next deploy or promote of its environment, writes the new one.
- The application keeps its identifier, size, manifest, deployed code, secrets, tokens, and usage.

[Renaming an application](/cloud/concepts/applications-and-environments/#renaming-an-application) explains the name rules and what happens when another change reaches the application before the rename runs.

### Turn the development environment on

[Test in development, then promote](/cloud/guides/turn-on-development-and-promote/) turns development on, deploys a version there, and promotes it to production.

### Delete the development environment

To turn development off, call `tzcloud_delete_environment` with the application ID, `environment: "development"`, and a `request_id` for this deletion. Give the owner the browser approval link. Keep the pending action ID and read it with `read_approval_status` until it ends. If a reply is lost, check the approval and the target before repeating the request. While the approval is open or running, the same `request_id` returns it. After it ends, the same ID can start a fresh request. Once deletion completes, the next deploy goes to production. Delete production only through `tzcloud_delete_application`.

On an application with one environment, the call removes the development database and the other records your [local runs](/cloud/concepts/glossary/#local-run) keep. It does so where a database setup exists, finished or stopped partway, where an earlier deletion of them stopped, or where development records remain. Production is untouched. Otherwise it is refused 409 `environment_not_created`.

The deletion ends development's schedules, and a later `tzcloud_create_environment` declares them again from the manifest. The next `tzcloud_submit_manifest` sets up development's records for local runs again, including its database and storage parts. It also creates development's credentials again, but creates no development realm. [Deleting the development environment](/cloud/concepts/applications-and-environments/#deleting-the-development-environment) lists what the deletion removes and what stays.

If you turn development on again with `tzcloud_create_environment`, call `tzcloud_submit_manifest` before the first deploy to development, so that development has its records again, its database among them. Its new realm takes the manifest's `realm` member where there is one, and otherwise the default sign-in methods, which [Manage end users](/cloud/guides/manage-end-users/) configures.

### Delete the application

If the application has a [deletion lock](#set-or-lift-an-application-deletion-lock), lift it before requesting deletion. If a lock is set between your request and approval, the deletion ends `declined` with `description_changed`.

`tzcloud_delete_application` removes the application with every environment it has, after a person approves it in the browser:

1. Your AI assistant calls it with the application identifier and a `request_id` for this deletion. It prints the approval link.
2. You open the link and approve on the browser page, which shows the platform's description of what the deletion removes. It lists each kind and counts the storage areas, secrets, upstreams, and outstanding transfer grants. The page also links to this section for what the deletion keeps. Above its buttons, it says the deletion cannot be undone and that Turn Zero offers no way to restore what it deletes.
3. Your AI assistant keeps the pending action ID and reads the outcome with `read_approval_status`. If a reply is lost, check the approval and the application before repeating the request. The same `request_id` returns an approval that is still open or running. After it ends, the same ID can start a fresh request. If an approved deletion fails partway through, earlier removals stay in place. Request fresh browser approval only if you still intend to finish the deletion.

You can also start the deletion from the application's page on the signed-in site. Under **Application deletion**, choose **Request application deletion**. The **Application deletion request** dialog names the application. Choose **Cancel** to close it or **Start request** to open the same approval page. If you see **Sign in again to request deletion**, sign in and return.

While deletion runs, **Request application deletion** is disabled and the page says deletion is under way. **Pause app** and **Resume app** are absent. Once it finishes, the page shows no such application.

The deletion removes, one kind at a time:

- each environment's compute, the image repository, and the published assets;
- every end-user [realm](/cloud/concepts/glossary/#realm) with every user, identity, session, passkey, and invitation in them;
- the push configurations, the queued deliveries, and the month's counts;
- both databases with their roles and credentials;
- its [issue-tracking space](/cloud/concepts/glossary/#issue-tracking-space), or both spaces of an application with one for each environment, each deleted at the issue service with every record in it;
- the daily copies of its own space (a copy being written at that moment is deleted at the next daily run);
- its binding to an issue space of your account's own, which keeps its records;
- the secrets stored at the application's scopes, both platform credentials, the tokens minted for the application, and the [transfer grants](/cloud/concepts/glossary/#transfer-grant);
- the schedule rows, the upstream declarations bound to the application, and the [storage areas](/cloud/concepts/glossary/#storage-area) bound to it with their files;
- the log entries and counter totals;
- last, the application row with its version history, its label retired and never reused.

Secrets stored for the whole account stay. The usage meters keep their rows. The secret store keeps deleted secret values for ninety days before it purges them, and no action of yours can read or restore them ([Secrets](/cloud/backend-packages/secrets/)). The deletion does not revoke a key at the service that issued it, so replace the key there if it should stop working.

When you delete an application that served, it leaves an anonymous monthly record of its whole days served and deployment counts, naming no application or account.

Console output from container hosting stays in the hosting provider's log store for up to thirty days; deletion and `tzcloud_purge_logs` do not remove it. Saved console excerpts from ended pods are part of the environment's log stream and are deleted with it. An approved deletion cannot be undone.

A deletion that stops because one kind fails to be removed ends `execution_failed`, and the Refusals table below gives its remedy. [The pending action](/cloud/concepts/what-happens-without-asking/#the-pending-action) explains the pending action and its outcomes.

#### Set or lift an application deletion lock

A deletion lock protects your application against accidental deletion. It also blocks deletion of the account that owns the application. You can still deploy, change settings, or delete its development environment under the usual approval rules. The lock moves with the application.

On the dashboard, open the application's page and find deletion protection above **Application deletion**.

- If you see **Deletion protection is off**, the page says you can request deletion. Choose **Turn on deletion lock**. Enter a reason of 1 to 200 characters on one line, then choose **Turn on lock**. The lock takes effect without a separate approval.
- If you see **Deletion protection is on**, the page says the lock prevents deletion and shows the reason and when it was set. **Request application deletion** is hidden. Choose **Remove lock** to open the approval page. The lock stays in place until you approve its removal there.

If you signed in more than eight hours ago, choose **Sign in again to turn on the lock** or **Sign in again to remove the lock**. Return to the application's page to continue.

To set the lock with your AI assistant, ask it to call `tzcloud_set_application_delete_lock` with the application ID and a nonblank `reason` of 1 to 200 characters on one line. Leave out control characters, Unicode format characters such as zero-width characters, and personal details.

Use your signed-in session or a token that can reach the application. A token scoped to one application can set or lift only that application's lock. Setting the lock takes effect without browser approval. Applications on synthetic accounts cannot take a lock.

The answer gives `changed` and `delete_lock`, with its `reason` and UTC `set_at`. A second set leaves the reason and time in place and returns `changed: false`. Check the lock in `tzcloud_list_applications` or in `tzcloud_read_status` under `application.delete_lock`. An unlocked application has `delete_lock: null`.

To lift the lock, ask your AI assistant to call `tzcloud_lift_application_delete_lock` with the application ID. Use your signed-in session or a token minted with `destructive`. Open the approval link in a browser signed in to the owning account. On the **Remove the deletion lock?** page, check the application, account ID, and the lock's reason and time. Choose **Keep lock** to decline or **Remove lock** to approve the lift.

If the lock changes or disappears before the approval check, the action ends `declined` with `description_changed`. If it changes or disappears after the check, the lift ends `failed` with `not_locked`. A new request to lift an absent lock returns `not_locked` before it creates a pending action.

You have 24 hours by default to decide. Check the request's `expires_at` for its deadline. Check the outcome with `read_approval_status`. A successful lift removes the lock. Request and approve application deletion separately.

## Expected result

- After a rollback, `tzcloud_read_status` shows production's `deploy.state` as `deployed` and its `version` as the number you named. `tzcloud_list_versions` shows a new `"promote"` row for production with `serving: true`.
- After a halt, the environment's `halted` member contains `at` and `by`, and its hostname returns 503 `environment_halted`. After a resume, `halted` is `false`.
- After an approved rename, `read_approval_status` shows the record `completed`, and its outcome gives the new hostname.
- After an approved deletion, `read_approval_status` shows the record `completed`, and its outcome lists what was removed. After the development environment's deletion, `tzcloud_read_status` lists production alone.

## Refusals

See the [refusals reference](/cloud/reference/refusals/) for other platform errors.

The refusals page holds the approval page's own refusals too. A refusal changes nothing on the platform. The status is the one the HTTP route returns, and the MCP tool returns the same refusal name. One row, `execution_failed`, is an outcome a pending action records, which `read_approval_status` shows, and not a response to the call. Two more, `cell_not_configured` and `cell_unavailable`, refuse a deletion after its approval, so `read_approval_status` shows them too, on a record that ended `failed`.

| Refusal | Status | Cause | Remedy |
| --- | --- | --- | --- |
| `version_already_serving` | 409 | `tzcloud_roll_back` named production's serving version. | For rollback, name an earlier eligible version. For a server on an app with two environments, promote the serving version to get a new production platform credential. For a server with one environment, deploy again. For functions on an app with two environments, deploy a new version and promote it from development. For functions on an app with one environment, use `tzcloud_deploy` or `tzcloud_deploy_command` with `rotate_database_credential: true`. This replaces the existing production platform credential and database password. Without that option, the deploy keeps the existing platform credential. For the chat route, see [Rotate the production credential](/cloud/guides/add-a-database/#3-rotate-the-production-credential). |
| `version_newer_than_serving` | 409 | `tzcloud_roll_back` named a version newer than production's serving one. | Call `tzcloud_promote` on an application with two environments to apply its checks; on one, deploy that code again. |
| `no_such_version` | 404 | `tzcloud_roll_back`: the version is not a deployed row of the application, or its environment was deleted. | Use `tzcloud_list_versions` to choose a row with `state: "deployed"` and `promotable: true`. If production serves a version, choose an earlier one. With production alone, choose a production version. |
| `version_image_pruned` | 409 | Retention has marked the named version's build for deletion or already removed it. | Choose a version `tzcloud_list_versions` marks `promotable`, or deploy that version's artifact again as a new version, and promote it where the application has two environments. |
| `version_client_pruned` | 409 | The named version's client files were deleted while its image or serverless deployment is still kept. | Choose a version `tzcloud_list_versions` marks `promotable`, or deploy the earlier artifact again as a new version. With two environments, promote that new version. |
| `target_environment_halted` | 409 | `tzcloud_roll_back` while production is halted, or `tzcloud_restart_application` on a halted environment. | Call `tzcloud_halt_environment` with `resume: true`, then call again. |
| `deploy_in_flight` | 409 | A version is in flight. This can include a rollback as well as a deploy, promote or restart. | Use `tzcloud_read_status` with `wait_seconds`, up to 45, or read `tzcloud_list_versions` until that version ends. Then repeat the refused request. |
| `account_paused` | 409 | An account pause blocks deploy, promote, rollback, restart, and resume. | Check the pause's end time in `detail`. Follow [Confirm the app is serving again](/cloud/troubleshooting/status-and-logs/#confirm-the-app-is-serving-again) before retrying. You can still check status or halt an environment. |
| `environment_never_deployed` | 409 | A halt found no deployed version, or a restart found no serving version or no server compute to re-create. | If a halt found no version, leave it as it is. For a restart, use `tzcloud_read_status` to check the serving version and the outcome of any failed restart. If nothing serves and the environment should serve, deploy to it or promote to production on an application with two environments. If a server version is named as serving but has no compute, give the owner the refusal. If the owner wants service restored, deploy or promote as applicable. Report a repeated failure with its detail and reference. |
| `account_credential_required` | 403 | `tzcloud_halt_environment` on production under a token limited to one application. | Call it under your signed-in session or a token minted for the whole account. |
| `name_taken` | 409 | `tzcloud_rename_application`: the account already has a live application with that name. | Choose another name. |
| `cell_not_configured` | 503 | `tzcloud_delete_environment`, after the approval: The platform has no record of where the development environment runs. No registered or open hosting cell is available to record its location. Nothing was deleted. | Nothing on your side corrects this. Report the refusal with its `detail`, and request the deletion again once platform staff have opened a hosting cell. |
| `cell_unavailable` | 503 | `tzcloud_delete_environment`, after the approval: the platform has no record of where the development environment is hosted, and every open hosting cell is full. Nothing was deleted. | Nothing on your side corrects this. Report the refusal with its `detail`, and request the deletion again once platform staff have added room for it. |
| `deletion_in_progress` | 409 | A deletion of the application or one of its environments is running. A request to set a lock during application deletion is refused. Reads, `read_approval_status`, and a repeat of the same deletion are accepted. If you approve a deletion while another deletion of the same application is in progress, the approved request fails with this refusal. The `detail` gives the time when the other deletion's hold ends. If the operation stopped, request deletion again after that time. An account deletion waits for a running deletion of one of its applications, about six minutes at most. | Wait for the deletion to finish; `read_approval_status` shows whether it completed. If it failed, request the same deletion again to complete it. |
| `delete_locked` | 409 | A standing lock blocks application deletion before an approval request is created. If teardown first meets the lock after approval, the action ends `failed` with this error. The refusal gives the lock's reason and time. | [Lift the lock](#set-or-lift-an-application-deletion-lock), approve the lift, then request deletion again. |
| `not_locked` | 409 | The application has no matching lock for the lift. | Read the current lock with `tzcloud_read_status`. For a lift already requested, read its outcome with `read_approval_status`. |
| `application_other_account` | 403 | The application ID belongs to another account. | Call from the owning account or use an ID that `tzcloud_list_applications` returns for your account. |
| `no_such_application` | 404 | No current application matches the ID. | Check the ID against `tzcloud_list_applications`. |
| `token_scope_refused` | 403 | The token reaches only one application and the request names another. | Use the owning account's session or a token that reaches the named application. |
| `destructive_class_required` | 403 | The credential lacks the `destructive` grant for an application lock lift, a deletion, or a rename. No pending action is created. | Call it from the connected session, or under a token minted with the `destructive` grant. |
| `execution_failed` | none | The pending action failed without a named refusal. A deletion's outcome includes `receipts` for what it removed before the failure. | Read the receipts and the current state, then request the deletion again. A kind already removed reports zero removals. |

## Related

- [Deploy from your computer](/cloud/getting-started/deploy-an-application/) creates the application and deploys it to production, and [Test in development, then promote](/cloud/guides/turn-on-development-and-promote/) covers the promote of an application with two environments.
- [Applications and environments](/cloud/concepts/applications-and-environments/) explains the version history, the halted state, renaming, and the two deletions.
- [What happens without asking](/cloud/concepts/what-happens-without-asking/) explains the browser approval and the pending action.
- [tzcloud_roll_back](/cloud/reference/actions/roll-back/), [tzcloud_list_versions](/cloud/reference/actions/list-versions/), [tzcloud_halt_environment](/cloud/reference/actions/halt-environment/), [tzcloud_restart_application](/cloud/reference/actions/restart-application/), [tzcloud_rename_application](/cloud/reference/actions/rename-application/), [tzcloud_delete_environment](/cloud/reference/actions/delete-environment/), and [tzcloud_delete_application](/cloud/reference/actions/delete-application/) are the actions' generated reference entries.
