# Rentals API reference

> Rent GPUs, then list, stop, start and delete rentals, back them up and read their network.

Source: https://legion.ambient.xyz/docs/api/rentals

- [List the organization's rentals](https://legion.ambient.xyz/docs/api/rentals/list-rentals): `GET /v1/rentals`. Lists rentals newest first, including deleted ones.
- [Rent GPUs on a host](https://legion.ambient.xyz/docs/api/rentals/create-rental): `POST /v1/rentals`. Allocates gpu_count GPUs on the host at the host's current price and asks its agent to start the container.
- [Get a rental](https://legion.ambient.xyz/docs/api/rentals/get-rental): `GET /v1/rentals/{rental_id}`.
- [Change a rental's settings](https://legion.ambient.xyz/docs/api/rentals/update-rental): `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…
- [Delete a rental and its workspace](https://legion.ambient.xyz/docs/api/rentals/delete-rental): `DELETE /v1/rentals/{rental_id}`. Stops the container if it is running and deletes the workspace on the host.
- [How to reach the model a rental serves](https://legion.ambient.xyz/docs/api/rentals/get-rental-serve): `GET /v1/rentals/{rental_id}/serve`. For a rental created with serve: the service Legion exposed for it, the API key the container checks (LEGION_API_KEY) and whether the service is ready.
- [Create the rental's model service if it has none](https://legion.ambient.xyz/docs/api/rentals/expose-rental-serve): `POST /v1/rentals/{rental_id}/serve/expose`. Creates the exposed-port rule of the rental's serve port when there is none (the organization had not enabled exposed ports when the rental was created…
- [The rental's effective network policy and whether its host applied it](https://legion.ambient.xyz/docs/api/rentals/get-rental-network): `GET /v1/rentals/{rental_id}/network`. What the rental can reach and whether its host's agent has applied it.
- [The host a rental runs on, its health and its GPUs' live telemetry](https://legion.ambient.xyz/docs/api/rentals/get-rental-host): `GET /v1/rentals/{rental_id}/host`. .
- [What the rental's network blocked or would have blocked in the last 24 hours](https://legion.ambient.xyz/docs/api/rentals/get-rental-network-activity): `GET /v1/rentals/{rental_id}/network/activity`. The rental's own outbound traffic as its host's agent reported it over the last 24 hours of stored windows (at most 5000 windows are summed: truncated…
- [Read a rental's logs](https://legion.ambient.xyz/docs/api/rentals/get-rental-logs): `GET /v1/rentals/{rental_id}/logs`. .
- [Stop a rental](https://legion.ambient.xyz/docs/api/rentals/stop-rental): `POST /v1/rentals/{rental_id}/stop`. Stops the container and releases its GPUs, which go back on the market for other renters.
- [Restart a stopped rental](https://legion.ambient.xyz/docs/api/rentals/start-rental): `POST /v1/rentals/{rental_id}/start`. Allocates the same number of GPUs on the same host again and restarts the container on the retained workspace, in the rental's own tier and at its own…
- [List a rental's recent workspace exports](https://legion.ambient.xyz/docs/api/rentals/list-workspace-exports): `GET /v1/rentals/{rental_id}/workspace-exports`. The rental's workspace exports requested in the last 72 hours (the 24 hours one may stay pending plus the up to 48 hours its file is kept), newest first…
- [Export a stopped rental's workspace](https://legion.ambient.xyz/docs/api/rentals/create-workspace-export): `POST /v1/rentals/{rental_id}/workspace-exports`. Asks the host's agent to upload the workspace of a stopped rental (/workspace in the container) as one tar file, so the data of a rental that was…
- [Get a workspace export](https://legion.ambient.xyz/docs/api/rentals/get-workspace-export): `GET /v1/rentals/{rental_id}/workspace-exports/{export_id}`. The state of an export createWorkspaceExport started.
- [Cancel a pending workspace export](https://legion.ambient.xyz/docs/api/rentals/cancel-workspace-export): `POST /v1/rentals/{rental_id}/workspace-exports/{export_id}/cancel`. Cancels an export that is still pending: it becomes cancelled, what was uploaded is discarded (the S3 multipart upload is aborted), and the host's agent…
- [What downloading a rental's workspace export will cost](https://legion.ambient.xyz/docs/api/rentals/estimate-workspace-export): `GET /v1/rentals/{rental_id}/workspace-exports/estimate`. Shown before an export is started and again before a download link is made.
- [Make a single-use download link for a ready workspace export](https://legion.ambient.xyz/docs/api/rentals/create-workspace-export-download-link): `POST /v1/rentals/{rental_id}/workspace-exports/{export_id}/download-links`. Charges the download and answers a link: url is a Legion address (/v1/downloads/<token>) that works once, until expires_at (download_link_ttl_seconds).
- [How long a stopped rental's files are kept, and what backups cost](https://legion.ambient.xyz/docs/api/rentals/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.
- [Data this rental sent out through Legion's relays, and what it cost](https://legion.ambient.xyz/docs/api/rentals/get-rental-transfer): `GET /v1/rentals/{rental_id}/transfer`. The bytes sent toward the renter by this rental through the SSH gateway (ssh), exposed ports (ports) and the web terminal (terminal), this UTC month and…
- [The organization's relay traffic this month, its free allowance and the rentals that used most](https://legion.ambient.xyz/docs/api/rentals/get-org-transfer): `GET /v1/transfer`. The organization-level figures of getRentalTransfer for the current UTC month, with the 20 rentals that sent the most bytes this month.
- [What a backup of this rental would cost](https://legion.ambient.xyz/docs/api/rentals/estimate-rental-backup): `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…
- [A rental's backups, newest first](https://legion.ambient.xyz/docs/api/rentals/list-rental-backups): `GET /v1/rentals/{rental_id}/backups`. Every backup of the rental, whatever its state, newest first.
- [Back up a stopped or failed rental's workspace](https://legion.ambient.xyz/docs/api/rentals/create-rental-backup): `POST /v1/rentals/{rental_id}/backups`. Asks the host's agent to upload the rental's /workspace (only /workspace) as one tar file to Legion's backup storage, where it is kept retention_days (7…
- [The organization's backups, newest first](https://legion.ambient.xyz/docs/api/rentals/list-backups): `GET /v1/backups`. Every backup of the organization's rentals, newest first; state filters.
- [Get a backup](https://legion.ambient.xyz/docs/api/rentals/get-backup): `GET /v1/backups/{backup_id}`. A backup of one of the organization's rentals.
- [Delete a ready backup early](https://legion.ambient.xyz/docs/api/rentals/delete-backup): `DELETE /v1/backups/{backup_id}`. Deletes a ready backup before it expires: it is deleted at once, can no longer be downloaded, and its file is purged 24 hours later.
- [Cancel a queued or uploading backup](https://legion.ambient.xyz/docs/api/rentals/cancel-backup): `POST /v1/backups/{backup_id}/cancel`. Cancels a backup that is queued or uploading, as cancelWorkspaceExport cancels an export: it becomes cancelled, what was uploaded is discarded (the…
- [Mint a download link for a ready backup](https://legion.ambient.xyz/docs/api/rentals/create-backup-download-link): `POST /v1/backups/{backup_id}/download-links`. A single-use link to the backup's tar file: url is a Legion address (/v1/downloads/<token>) that works once, until expires_at (download_link_ttl_seconds…
