
# Deleting and restoring an app

The app's owner or an organization owner deletes an app in the console, at the link `agc delete` gives, and its traffic and sign-in stop at once. Agents get `app.deleted`, and its address answers 410 Gone. Either of them can restore it for 30 days; then its data is purged and only its history stays.

```text
Console → app → Settings → Danger zone → Delete this app → type the app's name → Delete camp-bookings
```

## Ask your agent

```text
Delete the camp-bookings app.
```

The agent runs `agc delete`, which deletes nothing: it returns the console link to the app's delete form, who can use it, and what deleting removes and keeps. You open the link, type the app's name and press **Delete camp-bookings**. If you build the app but don't own it and aren't an organization owner, the agent gets `delete.not_owner` and tells you whom to ask, with the same link to pass on.

## Steps

**Get the link (agent).** In the app's folder:

```bash
agc delete
```

It exits 10 with `delete.person_required`. `data.approval.url` is the delete form's console link; relay it exactly as printed. `data.who_can_delete` names who can use it, and `data.will_remove` and `data.kept` say what deleting does.

**Delete (person).** In the app's settings, **Danger zone**, **Delete this app**: type the app's name and press **Delete <app>**. Organization owners also have it in the organization's Apps area. Two kinds of people can delete: the app's owner (whoever made it, or whoever it was transferred to, while still a member of the organization) and the organization's owners. Other members can't, even ones who build the app, because deleting takes production data with it. Claim an unclaimed app first, through its claim link, then delete it.

**Confirm (agent).** Run `agc delete` again: exit 0 with `data.state` (`deleted`, or `purged`), who deleted it and when, `data.removed`, `data.pending` (anything its runner hasn't reported yet; run it again later) and `data.kept`, with `data.restore_until` and `data.restore_url` while it can be restored.

**Wait for any release.** An app with a release building, rehearsing, waiting for approval, migrating or releasing can't be deleted (`app.busy`). Wait for it, or decline its approval, then delete.

**Restore.** Within 30 days, an organization owner presses **Restore** in the **Deleted** section of the organization's home, or the app's owner presses it on the deleted app's settings page. The app is live again with its last live release redeployed, sign-in and connection grants back, the repo un-archived, and its agents working without a new `agc init`. An app that was held at its private preview, with no release yet, starts that preview again behind the gate instead of going live.

## How it works

**At once.** The app is marked deleted. Every `agc` command and `/v1` route for it answers `app.deleted` to its agents, saying who deleted it, when, and until when it can be restored. Anyone else gets the same 404 as for a name that never existed. The app's sign-in broker refuses its routes, so every user's next recheck ends their session. Connection grants are suspended, not revoked.

**Then the workloads.** A runner task removes the app's namespace (deployments, services, secrets), its routes and its certificate, and is retried until the runner reports it. On Agent Cloud that takes seconds, and on a private target as long as its runner takes. Where Agent Cloud serves the address (`<app>.ac0.app`, or a platform target), it answers 410 with a page saying the app was deleted and its name stays reserved.

**Then the copies.** Every mirror, snapshot and rehearsal branch is deleted. Production's database branch is kept. A mirror still running on a laptop loses its database. Its next command reports `app.deleted`, and `agc down` cleans up.

**Kept until the purge:** production's database, the suspended grants, the app's assets and its last live image. The GitHub repo is archived (read-only), not deleted.

**The purge,** 30 days after the deletion was recorded (an hourly sweep), deletes the database project, the app's sign-in organization, assets and snapshots, and revokes the grants. Receipts, releases, approvals, events and activity stay, and receipt links keep working for owners. A purged app can't be restored.

**The name** stays reserved: `agc init --name camp-bookings` answers `app.name_reserved`, so a link in a document can't come to mean another app. Today the reservation lasts as long as the record.

Activity records `app.deleted`, `app.restored` and `app.purged`.

## Errors

What agents see:

| Code | Exit | Cause | Fix |
|---|---|---|---|
| `delete.person_required` | 10 | `agc delete` on a live app; nothing was deleted | Relay `data.approval.url` to the person as printed; run `agc delete` again once they have |
| `delete.not_owner` | 12 | The agent's person isn't the app's owner or an organization owner | Give the same link to someone in `data.who_can_delete` |
| `delete.not_this_app` | 2 | `agc delete <name>` names an app other than this folder's | Run `agc delete` in that app's own folder |
| `delete.unclaimed` | 1 | Nobody has claimed the app yet | A person claims it with its claim link, then deletes it |
| `app.deleted` | 12 | The app was deleted | Ask its owner or an organization owner to restore it within 30 days, or `agc init --name <another-name>` |
| `app.name_reserved` | 1 | `agc init` with a deleted app's name | Pick another name |

What owners see in the console:

| Code | Cause |
|---|---|
| `app.busy` | A release is in flight |
| `app.unclaimed` | The app isn't claimed yet |
| `app.purged` | Restore after the 30 days, or of a staging e2e app |
| `app.target_removed` | Restore of an app whose private target was removed |
| `app.not_deleted` | Restore of an app that isn't deleted |
| `app.changed` | The app's ownership or runtime changed since the page loaded; refresh, then restore |

```json
{
  "ok": false, "product": "agent.cloud", "command": "status",
  "error": { "code": "app.deleted",
             "message": "camp-bookings was deleted by owner@example.test on 2026-10-20. An organization owner can restore it until 2026-11-19.",
             "fix": "Ask its owner or an organization owner to restore it in the console, or run `agc init --name <another-name>` for a new app.", "retryable": false },
  "next": [{ "cmd": "agc init --name <another-name>", "why": "a new app, if the work goes on" }]
}
```

## Limits

- Restore window: 30 days from the deletion. Name reservation: kept for as long as the record exists.

## Agent notes

- Don't run `agc init` again in the same folder to "fix" `app.deleted`; that won't bring the app back, and the name is taken.
- Relay the `app.deleted` message as written: it names who deleted it and the restore deadline.
- `delete.person_required` (exit 10) isn't a failure to retry: relay the link as printed and wait for the person, then run `agc delete` again.

## Related

- [The app's GitHub repo](/docs/ship/the-apps-github-repo.md)
- [Activity log](/docs/owners/activity-log.md)
- [Setting up an organization](/docs/owners/setting-up-an-organization.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "ship/deleting-and-restoring-an-app: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
