# Change a rental's settings

> PATCH /v1/rentals/{rental_id}. Changes what a member may change on a rental after it was created: auto_resume, for an interruptible rental its bid max_price_per_gpu_hour, auto_backup…

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

`PATCH https://api.legion.ambient.xyz/v1/rentals/{rental_id}`

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

Changes what a member may change on a rental after it was created: `auto_resume`, for an
`interruptible` rental its bid `max_price_per_gpu_hour`, `auto_backup`,
`terminal_access` and its SSH key `ssh_public_key`. Everything else about a rental, its `interruption_behavior` included, is fixed at
creation. Setting a value a rental already has succeeds and changes nothing. Requires `rentals.manage`.

**Who may open the web terminal.** `terminal_access` may be changed only by the person who created the
rental (`created_by`) or an owner of the organization: anyone else is 403 `terminal_access_forbidden`, answered
before any other field of the request is changed. A rental with no `created_by` can be changed by owners only. Each change emits `rental.terminal_access_changed` with the person and the request's `client`. A change applies
to open terminal sessions at their next lease, within 60 seconds.

**Automatic backup.** `auto_backup` `{"retention_days": 7}` or `30` turns it on (or changes
the retention), `null` turns it off; only an `interruptible` rental that keeps its data has one (400
`auto_backup_not_applicable` otherwise, and for a `deleting`, `deleted` or `failed` rental 409
`rental_<state>`). It applies to the next time Legion stops the rental: a stop that already happened is
not backed up by turning it on. Each automatic backup is charged as a backup (`createRentalBackup`), and
while one runs the rental does not resume by itself; see `createRental`.

**The bid.** The renter may raise or lower the limit at any time, running or waiting. A limit
under the host's floor is 409 `bid_below_floor` (`current_price_per_gpu_hour` is the floor); a rental of
another tier is 400 `bid_not_applicable`; a rental on a host of the renter's own organization is 409
`own_host`; a `deleting`, `deleted` or `failed` rental is 409 `rental_<state>`. Raising the limit makes
it a new bid (it ranks after earlier bids at the same limit) and counts from the host's next clearing,
at most 2 minutes away. Lowering it under what the rental pays now lowers its price at once, from that
moment; the next clearing may then give its GPUs to a higher bid. Each change emits
`rental.bid_changed`.

**The price to win.** A rental waiting as a bid (`stopped`, `stop_reason` `outbid` or `preempted`,
`auto_resume`) that changes its limit makes a new bid, held to the price to win like a create: a new limit
under the rental's `spot_price_to_win_per_gpu_hour` is 409 `bid_too_low` with it in `current_price_per_gpu_hour`,
and nothing changes. While no bid can win the host's GPUs (`spot_win_status` `unavailable`) it may wait at any
limit from the floor up. A rental that holds GPUs changes its limit as before.

**Limits on the bid.** A rental's limit changes at most 6 times an hour (429
`limit_rate_limited` with `Retry-After`), and not at all while the rental is under a preemption notice
(a future `preempt_at`): 409 `notice_open`. A raise that displaces an incumbent is cleared at once
and pays the displacement bond (see `createRental`). A host of an organization linked to the renter's
by legion-risk counts as the renter's own: 409 `own_host`. The limit is at most the host's on-demand
`price_per_gpu_hour`: above it is 400 `max_above_on_demand`.

**The SSH key.** `ssh_public_key` replaces the key that may connect to the rental, read and
limited exactly as `createRental`'s: one OpenSSH public key, kept as `type base64` without its comment;
a private key is 400 `private_key_refused`, anything else that is not one public key 400
`invalid_ssh_key`. The rental's `ssh_key_fingerprint` is the new key's. A `deleting`, `deleted` or
`failed` rental is 409 `rental_<state>`. The rental is not restarted: the platform SSH gateway accepts
only the new key from the host agent's next sync (at most 30 seconds) and closes the open gateway
sessions of the replaced key within 10 seconds after that, and the host agent rewrites the
container's `authorized_keys` in place. A rental whose container may be running (any state but
`stopped`) on a host whose agent cannot rewrite it in place yet is 409 `host_unsupported` and keeps
its key: stop it, change the key, and start it again. Each change emits `rental.ssh_key_changed`
(who, from where, the old and new fingerprints); the same key again changes nothing.

## Path parameters

- `rental_id`, string (uuid), required

## Request body

- `resume_after_maintenance`, boolean: . `false`: maintenance never starts this rental again, neither at the end of the window that stopped it nor at the end of the window open on its host (both are recorded); only a member starts it. It stays stopped, its files kept for the usual 72 hours counted from the window's end. `true` undoes it for both windows. 400 `resume_after_maintenance_not_applicable` when the host has no open window and the rental was not stopped by one, and for a service replica.
- `auto_resume`, boolean: Whether a rental `stopped` because it was preempted starts again by itself when GPUs on its host are free within 72 hours of the stop; after that its files are deleted. Only an `interruptible` rental that keeps its data has one: for any other rental the request is 400 `auto_resume_not_applicable`. Turning it on for a rental whose bid Legion canceled is 409 `bid_cancelled`.
- `max_price_per_gpu_hour`, Money: . The new limit of an `interruptible` rental's bid on its host's spot auction: the most it pays per GPU-hour, all-in (: with the rental's own `renter_fee_bps`). At least the host's floor as the rental sees it, all-in (409 `bid_below_floor`, whose `current_price_per_gpu_hour` is that floor), and at most the host's on-demand price, all-in (400 `max_above_on_demand`). See `updateRental`.
- `auto_backup`, AutoBackup: . Turns the automatic backup on interruption on (`{"retention_days": 7}` or `30`) or off (`null`). Only an `interruptible` rental that keeps its data has one (400 `auto_backup_not_applicable`). See `updateRental` and `createRental`.
- `terminal_access`, TerminalAccess: . Who may open the web terminal on the rental. Only the rental's creator (`created_by`) or an owner of the organization may change it (403 `terminal_access_forbidden`). See `updateRental`.
- `ssh_public_key`, string: . The OpenSSH public key that replaces the rental's, as `createRental`'s `ssh_public_key`: one line, `type base64` with an optional comment, kept without the comment. Open SSH sessions through the gateway that used the replaced key are closed. See `updateRental`.
- `env`, array of EnvVarInput: . Replaces the rental's environment variables (`[]` removes them all); a secret sent without a value keeps its stored value. A rental whose container may be running is restarted with the new values: its container is created again, so files outside `/workspace` are reset. A stopped rental takes them at its next start. A running rental is changed only on a host whose agent supports it (409 `host_unsupported`).
  - `name`, string, required
  - `value`, string: Required except on an update that keeps a stored secret (see above).
  - `secret`, boolean
- `model_settings`, ModelSettings: . Replaces the model settings of a catalog model rental (`{}` returns to the image's defaults), with the restart `env` describes. Settings that need more GPU memory than the rental's GPUs have are 409 `model_settings_do_not_fit`; a rental on an older image of the model than the catalog's is 409 `model_settings_unavailable`.
- `command`, CommandOverride: . Replaces the entrypoint override of an own image (`[]` removes it), with the restart `env` describes.
- `args`, CommandOverride: . Replaces the CMD override of an own image (`[]` removes it), with the restart `env` describes.

Example:

```json
{
  "resume_after_maintenance": false,
  "auto_resume": false,
  "max_price_per_gpu_hour": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "auto_backup": {
    "retention_days": 7
  },
  "terminal_access": "organization",
  "ssh_public_key": "string",
  "env": [
    {
      "name": "HF_TOKEN",
      "value": "string",
      "secret": false
    }
  ],
  "model_settings": {},
  "command": [
    "string"
  ],
  "args": [
    "string"
  ]
}
```

## Responses

### 200

The rental.

- `maintenance`, RentalMaintenance: . The window of the rental's host, or the window that stopped the rental until it starts again: a `MaintenanceSummary` and `resume`. Absent for rentals under a preservation hold and for deleted and failed rentals.
  - `start`, string (date-time), required: When the window starts: the rental stops then (after a 5-minute notice).
  - `end`, string (date-time), required: The planned end. The provider may end the window earlier.
  - `reason`, MaintenanceReason, required: . Why a provider takes a host down, shown to the renters of rentals on it. The list grows: accept a value you do not know.
  - `state`, MaintenanceState, required: . `scheduled` (announced, renters told), `closing` (the last 5 minutes before the start: the penalty-free outcome is decided, nothing can start, rentals in their notice), `active` (the host is in maintenance, its rentals stopped), `overrun` (the planned end passed and the host has not synced back), `completed`, `cancelled`. The list grows: accept a value you do not know.
  - `resume`, boolean, required: Whether maintenance starts the rental again by itself when the window that stopped it, or the window shown, ends. `false` after `resume_after_maintenance` false on `updateRental`, for a stopped rental no window stopped (maintenance starts only what it stopped), and for one the resume queue gave up on (its host is under review).
- `id`, string (uuid), required
- `service_id`, string (uuid): The service that serves this rental: a rental created with `serve` gets a service with target `rental` (its URL `https://<rental name>.ambi.run`, keys access), and a replica of an autoscaled service names that service. Absent otherwise; a rental's exposed ports are listed by `listServices`.
- `service_managed`, boolean: True for a replica of an autoscaled service: only the autoscaler changes it, and stop, start, delete, update, exposed ports, backups and exports answer 409 `rental_managed_by_service`. Its `web_terminal` and `terminal_access` are the service's `replica_web_terminal`: change them on the service.
- `service_name`, string: . The name of the `service_id` service, so a replica can say whose setting it follows (for example "Web terminal: off, set by service chat"). Absent when `service_id` is.
- `service_initial_key`, ServiceKeyCreated: On `createRental` with `serve` only, the first key of the rental's service, its secret shown once (the answer carries `Cache-Control: no-store`). Never on a replay or a read.
- `name`, FriendlyName, required: The rental's friendly name, assigned at creation and never changed. It is the container's hostname (for a container created after it was assigned) and the SSH target: the gateway resolves `<name>` and `<name>.<zone>` as it resolves the rental ID, so `ssh -J <ssh.host>:<ssh.port> root@<name>` connects. Pin the rental's host key under the name (`HostKeyAlias <name>`).
- `host_id`, string (uuid), required
- `host_name`, FriendlyName: . The current friendly name of the host the rental runs on, as the marketplace shows it. Absent only for a host from before friendly names. `getRentalHost` has the rest.
- `host_score`, integer: . The host's current Legion score (`LegionScore.value`); absent until Legion scored it.
- `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.
- `ssh_key_fingerprint`, string: . The SHA256 fingerprint of the SSH public key that may connect to the rental, as `ssh-keygen -l` prints it (`SHA256:` and the unpadded base64 digest): the key of `createRental`, or the last one `updateRental` set. Absent when the stored key does not parse. The key itself is never returned.
- `tier`, RentalTier, required: The rental's tier, chosen at creation and never changed. `price_per_gpu_hour` is that tier's price at creation, except for an `interruptible` rental: its price follows the host's spot auction, and `price_per_gpu_hour` is the price of the last clearing it won. Own use (`own_use`) is always `on_demand`, and its `price_per_gpu_hour` is Ambient's own-use platform fee.
- `own_use`, boolean: (CONTRACTS.md "Own use of one's own host"). The rental is the organization's use of a host it owns. It pays only Ambient's own-use platform fee, `price_per_gpu_hour`: `own_use_fee_bps` of `own_use_reference_price` (the host's own listed price when the rental last started), charged from the organization's credit like any rental and never paid with promo credit. The organization earns nothing on it, its stopped workspace is not billed for storage, and any paid rental of the host (on demand, or a bid that wins the host's spot auction) takes its GPUs: it is then stopped with `stop_reason` `preempted` or `outbid` and does not start again by itself. It never takes GPUs from anybody. Absent or false for every other rental.
- `own_use_reference_price`, Money: On own use: the price per GPU-hour the fee was taken from, snapshotted at the rental's last start; a later change of the host's listing does not change it until the rental starts again.
- `own_use_reference_basis`, string: On own use: which price `own_use_reference_price` is. `on_demand`: the host's on-demand price (also its last one while it is not listed). `interruptible`: its interruptible floor, when the rental was asked for as interruptible. `advisor`: the price advisor's recommendation for a host that was never priced.
- `own_use_fee_bps`, integer: On own use, the platform fee's rate in basis points of `own_use_reference_price` (500 is 5%).
- `stop_reason`, RentalStopReason: Why Legion stopped this rental, while it is `stopping` or `stopped` because of it. Absent when a member, Legion or a lack of credit stopped it, and once it is started again. `start_timeout` stays on a `stopped` rental whose last start did not complete.
- `interruption_behavior`, InterruptionBehavior: What happens to the rental's data when it is preempted, chosen at creation and never changed. `keep` for every on-demand rental.
- `auto_resume`, boolean: . Whether the rental starts again by itself after it was preempted, when GPUs on its host are free within 72 hours of the stop; after that its files are deleted: the rental is `stopped` with `stop_reason` `preempted` (or `outbid`: it then starts when it wins a clearing of the host's spot auction, in bid order rather than oldest first), and neither a preservation hold, a suspended or unfunded organization, a full host disk nor missing free GPUs stops it from starting; these leave it queued, oldest preemption first. `true` for an `interruptible` rental that keeps its data unless it was set to `false` with `updateRental`. A member's `stopRental` of a rental that is already `stopped` and preempted sets it to `false`; any other stop or start leaves it. A resume never preempts anything and keeps the rental's tier and price.
- `preempt_at`, string (date-time): . While the rental is `stopping` or `stopped` because it was preempted: when its container is stopped. For a host whose agent advertised `preemption_notice_v1` it is 300 seconds (`PreemptionNoticeSeconds`) after the preemption, and the container keeps running, and billing, until then; else it is the moment of the preemption; billing ends at the agent's stop report and never runs past `preempt_at` plus 30 seconds. Absent otherwise, and once the rental is started again.
- `gpu_count`, integer, required
- `gpu_model`, string: The host's GPU model.
- `image`, string, required: The image reference as the renter wrote it. It is not what the host pulls: that is `registry.legion.ambient.xyz/<upstream>/<path>@<digest>` for an image of a mirrored registry, pinned to `image_digest`.
- `image_digest`, ImageDigest: The content digest of the image a rental is pinned to: of its manifest list for a multi-platform image, so the same digest runs on any platform the image offers. Absent on rentals created before images were pinned.
- `private_image`, boolean: . True when the image is private: its registry did not serve it anonymously and it was read with the organization's registry sign-in. The host pulls it straight from that registry with a short-lived token made from the sign-in; it never goes through Legion's mirror. Absent means false.
- `registry_credential_id`, string (uuid): . The registry credential a private image was read with, and the only one its host gets pull tokens from. Absent for a public image.
- `price_per_gpu_hour`, 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.
- `renter_fee_bps`, integer: . The renter platform fee, in basis points, this rental pays on top of the provider's price, fixed when it was created (500 is 5%). 0 for rentals created before and for own use (which pays its own-use fee in `price_per_gpu_hour`). Every price on the rental (`price_per_gpu_hour`, `max_price_per_gpu_hour`, `current_price_per_gpu_hour`, `storage_price_per_gib_month`) already includes it.
- `max_price_per_gpu_hour`, Money: . An `interruptible` rental's bid on its host's spot auction: the most it pays per GPU-hour, set at creation (the host's floor by default) and changed with `updateRental`. Absent for an on-demand rental. All-in, at the rental's `renter_fee_bps`: the stored bid is the provider's price it allows, so this is the all-in price of that, at most the limit the renter asked for.
- `spot_price_to_win_per_gpu_hour`, Money: . On a rental waiting as a bid (`stopped`, `stop_reason` `outbid` or `preempted`, `auto_resume`), the lowest limit that wins its host's GPUs back now, all-in at the rental's `renter_fee_bps`: the same number as an offer's `spot_price_to_win_per_gpu_hour`, with this rental's own bid left out. Raising `max_price_per_gpu_hour` to it with `updateRental` wins at the clearing that follows at once; a new limit under it is 409 `bid_too_low` with it. Absent on every other rental and when no bid can win now.
- `spot_win_status`, SpotWinStatus: . What a new interruptible bid on the host meets now. `free_gpus`: a bid at the spot price (`spot_price_per_gpu_hour`) wins. `outbid`: the GPUs are held by bids, or wanted by waiting ones, that a new bid must outbid, at `spot_price_to_win_per_gpu_hour`. `unavailable`: no bid can win now, the GPUs being held by on-demand rentals or by interruptible rentals in their first 10 minutes. Absent where `spot_price_to_win_per_gpu_hour` is not computed (not interruptible, own host).
- `current_price_per_gpu_hour`, Money: . What an `interruptible` rental that holds GPUs pays per GPU-hour now, all-in: the host's clearing price, never more than `max_price_per_gpu_hour`, never less than the floor unless the limit is (a limit set before the floor rose). Absent while it holds no GPUs (it is stopped or waiting to win), and for an on-demand rental.
- `resources`, Resources, required
  - `cpu_cores`, integer, required
  - `memory_mib`, integer (int64), required
  - `disk_gib`, integer (int64), required
- `ssh`, SSHEndpoint: On a `Rental`: the platform SSH gateway, a jump host, set by Legion from its own configuration and never from the host. Connect with `ssh -J <host>:<port> root@<rental id>`: the user on the rental is `root`. Absent until the host's agent reports the rental running and reachable through the gateway. In a `RentalReport`: the agent's view of the endpoint. It is read only as "reachable through the gateway"; a host or port other than the gateway's is ignored and counted (`controller_agent_ssh_endpoint_mismatch_total`), and never shown. `host_key_fingerprint` is ignored in a report.
  - `host`, string, required
  - `port`, integer, required
  - `host_key_fingerprint`, string: The SHA256 fingerprint of the gateway's SSH host key, as `ssh-keygen -lf` prints it, for the renter to compare on first connection. Absent when Legion is not configured with it.
- `failure_reason`, string: Why a `failed` rental failed, in words for the renter: what its host's agent reported, or what Legion decided. Among the latter: a new on-demand rental that took GPUs from interruptible rentals fails with "The GPUs weren't released in time:... You weren't charged." when they did not stop within 7 minutes (`rental.failed` with `reason` `preemption_timeout`); it was never billed.
- `storage_price_per_gib_month`, Money: What a `stopped` rental is charged per GiB per 730-hour month while its organization has credit, on the disk it uses as its host's agent reports it, at most `resources.disk_gib`, and on `resources.disk_gib` when the agent does not report it. The rate the rental's host charged when the rental was created, fixed for the rental like `price_per_gpu_hour`; for a rental created before, the platform's current rate. All-in with the renter platform fee. Absent when storage is free.
- `delete_after`, string (date-time): Legion deletes this rental, with the data in its workspace, no earlier than this; deletion also waits for a warning email sent at least 24 hours earlier. 72 hours after the rental failed, or, for a `stopped` rental, 72 hours after its organization ran out of credit or its host was removed (a stopped rental of an organization with credit is billed for storage instead). Absent while the rental is in any other state, on hold, or its organization is suspended. : a `stopped` rental is deleted 72 hours after it stopped (the latest of its stop, the release of its last hold, and the Terms 1.2 effective date, 2026-10-23), whether or not its organization has credit, and while its organization is suspended; a warning email goes out 12 hours before (24 for a failed rental). While a backup or export of the rental is queued or uploading the deletion waits for it to end, with no extra time after a failed one.
- `data_status`, DataStatus: Where a rental's files are. `on_host`: on its host (running, or stopped and kept until `delete_after`). `deleting`: their deletion was decided (`data_deleted_reason`) and the host's agent has not confirmed it yet. `deleted`: gone (`data_deleted_at`). The list may grow: treat an unknown value as `deleting`.
- `data_protected_until`, string (date-time): . For a `stopped` rental: until when its files are kept and never reclaimed for another renter, 24 hours after the stop completed. For a rental a maintenance window stopped, 24 hours after the window's end (absent while the window is open: never reclaimed then). Absent in any other state.
- `data_reclaimable`, boolean: . Whether the files of this `stopped` rental may be reclaimed right now for another renter's rental on the host: past `data_protected_until`, with no backup or export queued or uploading, not on hold, and the reclaim not switched off. False in any other state.
- `data_deleted_at`, string (date-time): . When the rental's files were deleted, as the host's agent confirmed (or the host left Legion).
- `data_deleted_reason`, DataDeletedReason: . Why the files were (`deleted`) or are being (`deleting`) deleted. Kept for ever.
- `delete_attempts`, integer: . While the rental is `deleting`: how many times its host's agent failed to delete it so far (agents with `delete_report_v1`); the agent keeps retrying. 3 or more is a stuck delete. Absent otherwise.
- `delete_error`, string: . With `delete_attempts`: the agent's fixed sentence naming the step that failed (never the container engine's text), safe to show.
- `latest_backup`, Backup: . The rental's newest backup, whatever its state, so a page can resume after a reload. Absent when it has none. Its other backups are on `listRentalBackups`.
- `auto_backup`, RentalAutoBackup: . The rental's automatic backup on interruption; absent when it is off. See `createRental`.
- `created_at`, string (date-time), required
- `web_terminal`, boolean, required: Whether the Legion web terminal was allowed at creation. Immutable.
- `ssh_agent_forwarding`, boolean, required: Whether `ssh -A` agent forwarding was allowed at creation. Immutable. Applies to rentals with `runtime`; a rental without it uses its image's own sshd configuration.
- `image_phase`, ImagePhase, required: Whether the rental's image is in Legion's registry. `fetching`: the mirror is still copying it in, which can take many minutes the first time, and the host's agent is not told about the rental yet; the rental is `starting` meanwhile. `ready`: the agent has been told to run it. A rental whose image has not arrived two hours after it was created fails.
- `runtime`, RentalRuntime: What the host's agent last reported for a rental created with the Legion runtime: the base bundle its container mounted and the sshd set that serves it. Absent for a rental created without the runtime. It is the provider's report, not proof.
  - `version`, RuntimeVersion, required: A release of the Legion runtime bundle: `x.y.z`, no prefix, no suffix, no leading zeros, at most four digits a part. Compare numerically: `1.10.0` is above `1.9.0`.
  - `sshd_set`, string, required
  - `sshd_version`, RuntimeVersion, required: A release of the Legion runtime bundle: `x.y.z`, no prefix, no suffix, no leading zeros, at most four digits a part. Compare numerically: `1.10.0` is above `1.9.0`.
  - `sshd_state`, RuntimeSshdState, required: `current`: the sshd set the agent last proved by banner is the newest one it could apply. `swapping`: a hot-swap to a newer set is in progress. `swap_failed`: it failed and the container serves its previous set (see `swap_error`).
  - `swap_error`, RuntimeSwapError
  - `restart_after`, string (date-time): Present only while the rental's base `version` is below the forced-restart floor: after this time the host's agent restarts the rental (same container, workspace kept) onto a newer base. The renter's banner reads it.
- `terminal`, TerminalAvailability, required: Whether the caller can open the web terminal on the rental now, and if not, the first reason that applies (CONTRACTS.md "Web terminal", Availability). Since it is the caller's own answer: with the rental's `terminal_access` `creator_and_owners`, a person who may not open it reads `not_allowed`.
  - `available`, boolean, required
  - `reason`, TerminalUnavailableReason: `platform_disabled`: the kill switch is off. `not_running`: the rental is not running. `disabled`: the rental was created with `web_terminal: false`. `agent_outdated`: the host's agent does not report terminal data. `restart_required`: the container started before the Legion CA lines were written; restart the rental. `host_keys_unknown`: the agent has not yet reported a host-key scan for the current container. `image_unsupported`: the sshd answering for the rental does not meet the web-terminal requirements. Read it with the rental's `runtime`. Without `runtime` the rental was created before Legion's built-in SSH server and runs its image's own sshd, which is too old or has no usable host key. With `runtime` Legion's SSH server is the one that should answer, so this means something else answers on the rental's SSH port (it may have been replaced from inside the container): restart the rental, or connect with SSH. `not_allowed`: the rental's `terminal_access` is `creator_and_owners` and the caller is neither the person who created it nor an owner of the organization. It is the caller's own answer: another person reading the same rental may see it available. The list grows: treat a value you do not know as unavailable.
- `terminal_access`, TerminalAccess, required: . Who may open the web terminal on the rental. `organization` for every rental created before it.
- `created_by`, string (uuid): . The person who created the rental: the signed-in person, or the person an API key or a connected app's token belongs to. Absent for a rental created before; it is never guessed after the fact.
- `startup`, Startup: . How far the rental's start has come, step by step, from when it was created or last started: `preparing_image` (only when Legion's mirror had to copy the image in), `pulling_image`, `starting_container`, and for a rental with `serve` `downloading_weights`, `loading_model`, `health_check`, then `ready`. Each step is `done`, `current`, `next` or `failed`, with when it started and ended; a step a start did not need (an image already on the host, weights already downloaded) is left out once a later step began. The current step of a pull or a download carries its `progress`. A `failed` step is where the start stopped: the reason is `failure_reason` on the rental, or `serve.failure` for the model service. Absent for a rental with no recorded steps (one created before and not started since).
- `serve`, RentalServeSummary: What the rental serves; absent for a rental created without `serve`. The key and the address are on `getRentalServe`.
- `env`, array of EnvVar: . The container's environment variables, secrets without their values. Absent when there are none.
  - `name`, string, required
  - `secret`, boolean, required
  - `value`, string: The value; absent when `secret` is true.
- `model_settings`, ModelSettings: . The model settings set on a catalog model rental; absent when none are.
- `command`, CommandOverride: . The entrypoint override; absent when the image's is used.
- `args`, CommandOverride: . The CMD override; absent when the image's is used.

Example:

```json
{
  "maintenance": {
    "start": "2026-10-15T12:00:00Z",
    "end": "2026-10-15T12:00:00Z",
    "reason": "hardware",
    "state": "scheduled",
    "resume": false
  },
  "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "service_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "service_managed": false,
  "service_name": "string",
  "service_initial_key": {
    "key": {
      "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "kind": "service",
      "name": "string",
      "prefix": "string",
      "status": "active",
      "created_at": "2026-10-15T12:00:00Z",
      "created_by": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "expires_at": "2026-10-15T12:00:00Z",
      "last_used_at": "2026-10-15T12:00:00Z",
      "revoked_at": "2026-10-15T12:00:00Z",
      "rate_limit_per_minute": 0,
      "direct_url": "string"
    },
    "secret": "string"
  },
  "name": "quiet-river-7k2f",
  "host_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "host_name": "quiet-river-7k2f",
  "host_score": 0,
  "state": "starting",
  "ssh_key_fingerprint": "string",
  "tier": "on_demand",
  "own_use": false,
  "own_use_reference_price": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "own_use_reference_basis": "on_demand",
  "own_use_fee_bps": 0,
  "stop_reason": "preempted",
  "interruption_behavior": "keep",
  "auto_resume": false,
  "preempt_at": "2026-10-15T12:00:00Z",
  "gpu_count": 0,
  "gpu_model": "string",
  "image": "string",
  "image_digest": "sha256:3f2a9c1d5b7e8f40a6c3d2b19e0f7a845c6d1e2f3a4b5c6d7e8f9a0b1c2d3e4f",
  "private_image": false,
  "registry_credential_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "price_per_gpu_hour": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "renter_fee_bps": 0,
  "max_price_per_gpu_hour": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "spot_price_to_win_per_gpu_hour": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "spot_win_status": "free_gpus",
  "current_price_per_gpu_hour": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "resources": {
    "cpu_cores": 0,
    "memory_mib": 0,
    "disk_gib": 0
  },
  "ssh": {
    "host": "string",
    "port": 1,
    "host_key_fingerprint": "SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU"
  },
  "failure_reason": "string",
  "storage_price_per_gib_month": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "delete_after": "2026-10-15T12:00:00Z",
  "data_status": "on_host",
  "data_protected_until": "2026-10-15T12:00:00Z",
  "data_reclaimable": false,
  "data_deleted_at": "2026-10-15T12:00:00Z",
  "data_deleted_reason": "renter_deleted",
  "delete_attempts": 1,
  "delete_error": "string",
  "latest_backup": {
    "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
    "rental_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
    "rental_name": "quiet-river-7k2f",
    "state": "queued",
    "retention_days": 7,
    "requested_at": "2026-10-15T12:00:00Z",
    "upload_started_at": "2026-10-15T12:00:00Z",
    "ready_at": "2026-10-15T12:00:00Z",
    "expires_at": "2026-10-15T12:00:00Z",
    "ended_at": "2026-10-15T12:00:00Z",
    "purge_at": "2026-10-15T12:00:00Z",
    "size_bytes": 0,
    "estimated_size_bytes": 0,
    "estimate_basis": "disk_used",
    "total_bytes": 0,
    "uploaded_bytes": 0,
    "upload_rate_bytes_per_second": 0,
    "estimated_completion_at": "2026-10-15T12:00:00Z",
    "upload_deadline": "2026-10-15T12:00:00Z",
    "price": {
      "quoted": {
        "amount_minor": 250,
        "currency": "USD"
      },
      "charged": {
        "amount_minor": 250,
        "currency": "USD"
      },
      "refunded": {
        "amount_minor": 250,
        "currency": "USD"
      },
      "storage": {
        "amount_minor": 250,
        "currency": "USD"
      },
      "download": {
        "amount_minor": 250,
        "currency": "USD"
      }
    },
    "delete_rental_after": false,
    "download_links": 0,
    "error": "string",
    "automatic": false,
    "origin": "member"
  },
  "auto_backup": {
    "retention_days": 7,
    "last_skipped_at": "2026-10-15T12:00:00Z",
    "last_skipped_reason": "no_credit"
  },
  "created_at": "2026-10-15T12:00:00Z",
  "web_terminal": false,
  "ssh_agent_forwarding": false,
  "image_phase": "fetching",
  "runtime": {
    "version": "1.3.0",
    "sshd_set": "string",
    "sshd_version": "1.3.0",
    "sshd_state": "current",
    "swap_error": "verify_failed",
    "restart_after": "2026-10-15T12:00:00Z"
  },
  "terminal": {
    "available": false,
    "reason": "platform_disabled"
  },
  "terminal_access": "organization",
  "created_by": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "startup": {
    "steps": [
      {
        "step": "finding_host",
        "state": "done",
        "started_at": "2026-10-15T12:00:00Z",
        "ended_at": "2026-10-15T12:00:00Z",
        "progress": {
          "done_bytes": 0,
          "total_bytes": 0,
          "bytes_per_second": 0,
          "eta_seconds": 0,
          "fraction": 0,
          "reported_at": "2026-10-15T12:00:00Z"
        },
        "reason": "string",
        "detail": "string",
        "facts": {
          "gpu_model": "string",
          "gpu_count": 1,
          "price_per_gpu_hour": {
            "amount_minor": 250
          },
          "country": "string",
          "hosts_checked": 0,
          "hosts_busy": 0,
          "hosts_over_price": 0,
          "cached": false,
          "items_done": 0,
          "items_total": 0,
          "load_fraction": 0,
          "gpu_memory_used_bytes": 0,
          "gpu_memory_total_bytes": 0,
          "kv_cache_bytes": 0,
          "compile_fraction": 0,
          "health_path": "string",
          "attempts": 0,
          "last_status_code": 0,
          "latency_ms": 0
        }
      }
    ]
  },
  "serve": {
    "kind": "openai",
    "model": "string",
    "catalog_id": "string",
    "readiness": {
      "phase": "pulling",
      "progress": 0,
      "since": "2026-10-15T12:00:00Z",
      "reported_at": "2026-10-15T12:00:00Z"
    },
    "failure": {
      "reason": "string",
      "message": "string",
      "reported_at": "2026-10-15T12:00:00Z"
    }
  },
  "env": [
    {
      "name": "HF_TOKEN",
      "secret": false,
      "value": "string"
    }
  ],
  "model_settings": {},
  "command": [
    "string"
  ],
  "args": [
    "string"
  ]
}
```

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

### 409

The resource's current state does not allow the operation. `legal_versions_stale`: a legal document version sent is not the current one; the
problem's `legal` holds the current documents.

### 429

Rate limited (`code` is `rate_limited`), or the organization asked the
pull-through mirror to copy in too many different tags or digests of one
repository today (`mirror_quota_exceeded`). Retry after the `Retry-After`
seconds.

### 500

An unexpected server error. Safe to retry.

### 503

A dependency is unavailable (`terminal_signing_unavailable`;
`image_registry_unavailable` when the image's registry did not answer in
time or failed; `secrets_unavailable` when secret variables cannot be
stored or read). Safe to retry.

## Errors

- 400 [`auto_backup_not_applicable`](https://legion.ambient.xyz/docs/errors#auto_backup_not_applicable)
- 400 [`auto_resume_not_applicable`](https://legion.ambient.xyz/docs/errors#auto_resume_not_applicable)
- 400 [`bid_not_applicable`](https://legion.ambient.xyz/docs/errors#bid_not_applicable)
- 400 [`invalid_ssh_key`](https://legion.ambient.xyz/docs/errors#invalid_ssh_key)
- 400 [`max_above_on_demand`](https://legion.ambient.xyz/docs/errors#max_above_on_demand)
- 400 [`private_key_refused`](https://legion.ambient.xyz/docs/errors#private_key_refused)
- 400 [`env_reserved`](https://legion.ambient.xyz/docs/errors#env_reserved)
- 400 [`invalid_env`](https://legion.ambient.xyz/docs/errors#invalid_env)
- 400 [`invalid_command`](https://legion.ambient.xyz/docs/errors#invalid_command)
- 400 [`override_not_allowed`](https://legion.ambient.xyz/docs/errors#override_not_allowed)
- 400 [`invalid_model_setting`](https://legion.ambient.xyz/docs/errors#invalid_model_setting)
- 400 [`resume_after_maintenance_not_applicable`](https://legion.ambient.xyz/docs/errors#resume_after_maintenance_not_applicable)
- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 403 [`terminal_access_forbidden`](https://legion.ambient.xyz/docs/errors#terminal_access_forbidden)
- 409 [`bid_below_floor`](https://legion.ambient.xyz/docs/errors#bid_below_floor)
- 409 [`bid_cancelled`](https://legion.ambient.xyz/docs/errors#bid_cancelled)
- 409 [`bid_too_low`](https://legion.ambient.xyz/docs/errors#bid_too_low)
- 409 [`host_unsupported`](https://legion.ambient.xyz/docs/errors#host_unsupported)
- 409 [`notice_open`](https://legion.ambient.xyz/docs/errors#notice_open)
- 409 [`own_host`](https://legion.ambient.xyz/docs/errors#own_host)
- 409 [`rental_deleted`](https://legion.ambient.xyz/docs/errors#rental_deleted)
- 409 [`rental_deleting`](https://legion.ambient.xyz/docs/errors#rental_deleting)
- 409 [`rental_failed`](https://legion.ambient.xyz/docs/errors#rental_failed)
- 409 [`rental_managed_by_service`](https://legion.ambient.xyz/docs/errors#rental_managed_by_service)
- 409 [`model_settings_do_not_fit`](https://legion.ambient.xyz/docs/errors#model_settings_do_not_fit)
- 409 [`model_settings_unavailable`](https://legion.ambient.xyz/docs/errors#model_settings_unavailable)
- 429 [`limit_rate_limited`](https://legion.ambient.xyz/docs/errors#limit_rate_limited)
- 503 [`secrets_unavailable`](https://legion.ambient.xyz/docs/errors#secrets_unavailable)

## Example request

```sh
curl -s -X PATCH "https://api.legion.ambient.xyz/v1/rentals/$RENTAL_ID" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "resume_after_maintenance": false,
  "auto_resume": false,
  "max_price_per_gpu_hour": {
    "amount_minor": 250,
    "currency": "USD"
  },
  "auto_backup": {
    "retention_days": 7
  },
  "terminal_access": "organization",
  "ssh_public_key": "string",
  "env": [
    {
      "name": "HF_TOKEN",
      "value": "string",
      "secret": false
    }
  ],
  "model_settings": {},
  "command": [
    "string"
  ],
  "args": [
    "string"
  ]
}'
```
