# Preview what is on a host before removing it

> GET /v1/hosts/{host_id}/removal-preview. .

Source: https://legion.ambient.xyz/docs/api/hosts/get-host-removal-preview

`GET https://api.legion.ambient.xyz/v1/hosts/{host_id}/removal-preview`

Authenticate with an API key: `Authorization: Bearer $LEGION_API_KEY`.

. What keeps `removeHost` from removing the host now: the rentals that block it
(`blocking_rentals`, as on 409 `host_has_active_rentals`) and the renters' files still stored on it
(`stored_data_rentals`, as on 409 `host_has_stored_data`), each with its size and when it is
deleted. Changes nothing. Needs the `hosts.manage` permission.

## Path parameters

- `host_id`, string (uuid), required

## Responses

### 200

The preview.

- `blocking_rentals`, array of HostRemovalBlockingRental, required: The rentals that keep the host from any removal, as on 409 `host_has_active_rentals`.
  - `id`, string (uuid), required
  - `name`, FriendlyName: A host's or rental's friendly name: a lowercase DNS label that starts with a letter and does not end with a hyphen. Unique across all hosts and rentals and never reused. A host's is generated as adjective-noun (`amber-falcon`) and can be changed by its owner; a rental's is generated as adjective-noun plus four base36 characters (`quiet-river-7k2f`) and never changes.
  - `state`, RentalState, required: `starting`: GPUs allocated, waiting for the agent to start the container. Not billed. While the rental's `image_phase` is `fetching` the agent does not know it yet. `running`: the container runs. Billed per second. `exited`: the host reports the container is not running, for example after a crash; the host is restarting it. GPUs stay reserved. Not billed; returns to `running` when the host reports it running again. `stopping`: stop requested, waiting for the agent. Not billed. Becomes `stopped` without the agent once the host has been offline for 90 seconds. `stopped`: GPUs released, workspace kept on the host. GPU time is not billed. Storage is billed per GiB while the organization has credit, except for an `interruption_behavior: delete` rental, which never stops with data. `host_offline`: the host stopped syncing. Not billed; returns to `running` when the host syncs again, and becomes `failed` once the host has not synced for `HOST_STALE_AFTER` (24 hours;). `deleting`: delete requested, waiting for the agent. Not billed. Becomes `deleted` without the agent once the host has been offline for 90 seconds. `deleted`: container and workspace removed. Final. `failed`: the agent could not start or keep running the container. GPUs released. The rental can only be deleted.
  - `endable`, boolean, required: Removing the host anyway (`removeHost` with `force` true) would end it: it is `host_offline` on a host that is offline, and not on a preservation hold. A rental that runs, or that the host still has to act on, is never endable.
  - `held`, boolean: On a preservation hold.
  - `rented_by_you`, boolean: The caller's own organization rented it, so the caller can open it (`getRental`). Only from `removeHost`; absent means false.
- `stored_data_rentals`, array of HostStoredDataRental, required: The renters' files on the host, as on 409 `host_has_stored_data`.
  - `id`, string (uuid), required
  - `name`, FriendlyName: A host's or rental's friendly name: a lowercase DNS label that starts with a letter and does not end with a hyphen. Unique across all hosts and rentals and never reused. A host's is generated as adjective-noun (`amber-falcon`) and can be changed by its owner; a rental's is generated as adjective-noun plus four base36 characters (`quiet-river-7k2f`) and never changes.
  - `state`, RentalState, required: `starting`: GPUs allocated, waiting for the agent to start the container. Not billed. While the rental's `image_phase` is `fetching` the agent does not know it yet. `running`: the container runs. Billed per second. `exited`: the host reports the container is not running, for example after a crash; the host is restarting it. GPUs stay reserved. Not billed; returns to `running` when the host reports it running again. `stopping`: stop requested, waiting for the agent. Not billed. Becomes `stopped` without the agent once the host has been offline for 90 seconds. `stopped`: GPUs released, workspace kept on the host. GPU time is not billed. Storage is billed per GiB while the organization has credit, except for an `interruption_behavior: delete` rental, which never stops with data. `host_offline`: the host stopped syncing. Not billed; returns to `running` when the host syncs again, and becomes `failed` once the host has not synced for `HOST_STALE_AFTER` (24 hours;). `deleting`: delete requested, waiting for the agent. Not billed. Becomes `deleted` without the agent once the host has been offline for 90 seconds. `deleted`: container and workspace removed. Final. `failed`: the agent could not start or keep running the container. GPUs released. The rental can only be deleted.
  - `estimated_size_bytes`, integer (int64), required: The size of its files on the host; with `estimate_basis` `disk_share` an upper bound.
  - `estimate_basis`, BackupEstimateBasis, required: . What a backup's quote was computed on. `disk_used`: the size the rental's host last reported its workspace uses (`disk_used_gib`). `disk_share`: the host does not report it (a host whose disk quota is not enforced, for example not on XFS), so the quote is the rental's whole disk share (`resources.disk_gib`): an upper bound, "up to" this price, trued down to the real size when the backup is ready. Either way the charge never exceeds the quote: a backup larger than its estimate (a stale `disk_used_gib`) is charged the quote, not more.
  - `delete_after`, string (date-time): When its files are deleted (its `delete_after`); absent while held.
  - `backup_state`, BackupState: Its renter's newest backup, when it has one.
  - `rented_by_you`, boolean: The caller's own organization rented it. Only on the public listener; absent means false.

Example:

```json
{
  "blocking_rentals": [
    {
      "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "name": "quiet-river-7k2f",
      "state": "starting",
      "endable": false,
      "held": false,
      "rented_by_you": false
    }
  ],
  "stored_data_rentals": [
    {
      "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "name": "quiet-river-7k2f",
      "state": "starting",
      "estimated_size_bytes": 0,
      "estimate_basis": "disk_used",
      "delete_after": "2026-10-15T12:00:00Z",
      "backup_state": "queued",
      "rented_by_you": false
    }
  ]
}
```

### 400

The request is malformed or fails validation. An image reference that
is not a container image reference answers `invalid_image_reference`.

### 401

Missing, unknown, expired or revoked credentials.

### 403

The caller lacks the permission this operation requires (`forbidden`),
or signed in without having joined an organization yet
(`no_organization`; `getOnboarding` and the invitation and
organization operations under it work), or could not sign in
(`email_unverified`, `account_conflict`, and `domain_not_allowed`). `not_invited` is no longer returned to
session tokens.

`access_not_approved`: a signed-in person who is not approved
for the beta yet. Every operation that takes a credential answers it to
them, except `getMe` and `joinMyWaitlist`; the problem carries
`access` (`waitlisted` or `not_requested`, and the email). Approved
means a member of an organization, holding a pending invitation, or Legion; an API key always belongs to a member.

`oauth_token_mcp_only`: the caller sent an OAuth access token (`lgo_`), which is accepted
only by `mcpMessage` and the tool calls it dispatches. Every other operation answers it, whatever
the token's scope. Use an API key or the Legion web app.

`org_suspended`: the caller's organization is suspended. Every operation that takes a
credential answers it, by session or API key, except `getMe` (which shows `org.suspended_at` and
`org.suspension_reason`) and the support operations under `/v1/support/`.

`terms_not_accepted`: an approved caller who has not accepted
the current version of the Terms of Use and the Acceptable Use Policy. Every operation that takes a credential answers it, except `getMe`,
`acceptLegalDocuments`, `joinMyWaitlist` and the wind-down operations
(`listRentals`, `stopRental`, `deleteRental`, `listHosts`,
`updateListing` with `listed` false, `removeHost`); the problem
carries `legal`. An API key acts for the person who created it, so it
is refused until that person accepts. Terminal
operations also return
`session_required` (called with an API key) and `step_up_required`
(neither a sign-in nor a step-up challenge within the step-up window).

### 404

The resource does not exist or belongs to another organization.

### 500

An unexpected server error. Safe to retry.

## Errors

- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)

## Example request

```sh
curl -s "https://api.legion.ambient.xyz/v1/hosts/$HOST_ID/removal-preview" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
