# Get storage policy

> GET /v1/storage-policy. The numbers behind stopping, deletion and backups, from the one place Legion keeps them, so the app, the docs and agents never hard-code them.

Source: https://legion.ambient.xyz/docs/api/rentals/get-storage-policy

`GET https://api.legion.ambient.xyz/v1/storage-policy`

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

The numbers behind stopping, deletion and backups, from the one place Legion keeps them, so the
app, the docs and agents never hard-code them. A stopped rental's files
stay on its host, kept and never reclaimed, for `protected_hours` after the stop completes; after that its disk may be
reclaimed for another renter's new or restarted rental on the host; at `retained_hours` they are deleted
unless the rental was started again. A warning email goes out `warning_hours` before. A backup is kept
`backup_retention_days` (7 or 30, the renter's choice), then removed after `backup_purge_grace_hours`. Its
price is the storage for the chosen retention plus one download, and every further download link is
charged its transfer again. All of a backup's price goes to Ambient. The reclaim and the backup charges are
on by default; `reclaim_enabled` and `backup_charges_enabled` show when an operator has used their kill
switch.

## Responses

### 200

The policy.

- `protected_hours`, integer, required: A stopped rental's files are never reclaimed for this long after the stop (24).
- `retained_hours`, integer, required: A stopped rental's files are deleted this long after the stop (72).
- `warning_hours`, integer, required: The warning email goes out this long before (12).
- `backup_retention_days`, array of BackupRetentionDays, required
  
- `backup_default_retention_days`, BackupRetentionDays, required: How many days a backup is kept once it is ready. 7 by default.
- `backup_purge_grace_hours`, integer, required: An expired or deleted backup's file is purged this long after (24).
- `backup_queue_timeout_hours`, integer, required: A backup that has not started uploading this long after it was requested fails (24).
- `backup_upload_timeout_hours`, integer, required: A backup still uploading this long after the upload started fails (12).
- `backup_storage_price_per_gib_month`, Money, required: Per GiB per 730-hour month, prorated by the hour over the retention.
- `backup_download_price_per_gib`, 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.
- `backup_download_links_per_day`, integer, required: Download links a backup may have minted in 24 hours.
- `reclaim_enabled`, boolean, required: Whether disk reclaim is on (it is unless an operator used its kill switch).
- `backup_charges_enabled`, boolean, required: Whether backups are charged (they are unless an operator used its kill switch).
- `export_cents_per_gib`, integer (int64), required: . US cents per GiB of one download of a workspace export, rounded up to a whole cent, at least 1 cent.
- `relay_cents_per_gib`, integer (int64), required: . US cents per GiB of relay, exposed-port and terminal traffic above the free allowance.
- `relay_free_gib_per_month`, integer (int64), required: . GiB of that traffic per organization per UTC calendar month that is free.
- `exports_per_hour`, integer (int64), required: . Workspace exports an organization may start an hour.
- `download_link_ttl_seconds`, integer (int64), required: . How long a download link (export or backup) can be used before it expires.
- `auto_backup_default_retention_days`, BackupRetentionDays: . The automatic backup on interruption a new `interruptible` rental that keeps its data gets when `createRental` does not name `auto_backup`. Absent: off (today: it is opt-in, because each backup is charged and its size may be unmeasured). A rent form defaults its choice to this.

Example:

```json
{
  "protected_hours": 0,
  "retained_hours": 0,
  "warning_hours": 0,
  "backup_retention_days": [
    7
  ],
  "backup_default_retention_days": 7,
  "backup_purge_grace_hours": 0,
  "backup_queue_timeout_hours": 0,
  "backup_upload_timeout_hours": 0,
  "backup_storage_price_per_gib_month": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "backup_download_price_per_gib": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "backup_download_links_per_day": 0,
  "reclaim_enabled": false,
  "backup_charges_enabled": false,
  "export_cents_per_gib": 0,
  "relay_cents_per_gib": 0,
  "relay_free_gib_per_month": 0,
  "exports_per_hour": 0,
  "download_link_ttl_seconds": 0,
  "auto_backup_default_retention_days": 7
}
```

### 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).

### 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/storage-policy" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
