# What a backup of this rental would cost

> GET /v1/rentals/{rental_id}/backup-estimate. The quote a backup of the rental would be charged now: its estimated size is the disk the rental's host last reported it uses (disk_used_gib), else its…

Source: https://legion.ambient.xyz/docs/api/rentals/estimate-rental-backup

`GET https://api.legion.ambient.xyz/v1/rentals/{rental_id}/backup-estimate`

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

The quote a backup of the rental would be charged now: its estimated size is the disk the
rental's host last reported it uses (`disk_used_gib`), else its whole share (`resources.disk_gib`). The
price is the storage for `retention_days` plus one download. `createRentalBackup` charges this quote
when it is accepted; when the backup is ready the price is computed again from the real size and any
difference is refunded (the charge never exceeds the quote). Requires `rentals.manage`.

## Path parameters

- `rental_id`, string (uuid), required

## Query parameters

- `retention_days`, BackupRetentionDays

## Responses

### 200

The estimate.

- `retention_days`, BackupRetentionDays, required: How many days a backup is kept once it is ready. 7 by default.
- `estimated_size_bytes`, integer (int64), required
- `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.
- `price`, Money, required: The quote, what `createRentalBackup` charges now. With `estimate_basis` `disk_share` it is an upper bound ("up to"), trued down to the real size when the backup is ready. Zero while backup charges are switched off.
- `estimated_upload_seconds`, integer (int64): How long the upload should take at the host's measured upload speed (its recent backups and exports, else its last network benchmark, halved). Absent when the host's speed is not known.
- `fits_upload_window`, boolean, required: False when, with `estimate_basis` `disk_used`, `estimated_upload_seconds` exceeds the 12-hour upload limit: `createRentalBackup` then refuses with 409 `backup_too_slow`. Always true with `disk_share` (the real size is not known, so the backup is tried) and when the speed is not known.
- `storage`, Money, required
  - `amount_minor`, integer (int64), required: Amount in minor units (cents for USD).
  - `currency`, MoneyCurrency, required: ISO 4217 currency code. Only USD is supported.
- `download`, Money, required
  - `amount_minor`, integer (int64), required: Amount in minor units (cents for USD).
  - `currency`, MoneyCurrency, required: ISO 4217 currency code. Only USD is supported.
- `expires_after_days`, integer, required: Days from ready to expiry: `retention_days`.

Example:

```json
{
  "retention_days": 7,
  "estimated_size_bytes": 0,
  "estimate_basis": "disk_used",
  "price": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "estimated_upload_seconds": 0,
  "fits_upload_window": false,
  "storage": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "download": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "expires_after_days": 0
}
```

### 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/rentals/$RENTAL_ID/backup-estimate" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
