# Get a workspace export

> GET /v1/rentals/{rental_id}/workspace-exports/{export_id}. The state of an export createWorkspaceExport started.

Source: https://legion.ambient.xyz/docs/api/rentals/get-workspace-export

`GET https://api.legion.ambient.xyz/v1/rentals/{rental_id}/workspace-exports/{export_id}`

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

The state of an export `createWorkspaceExport` started. `ready`: the tar file is there with its
`size_bytes`; since a read carries no download address: make a single-use, charged link with
`createWorkspaceExportDownloadLink`. `failed`: the agent could not export (`error`), the export
was pending for more than 24 hours, or the file was removed 24 hours after it was written. `cancelled`: a
member cancelled it (`cancelWorkspaceExport`). Requires `rentals.manage`.

While it is `pending` it shows the upload's progress: `uploaded_bytes` (the parts the agent has
finished), `total_bytes` (the host's agent measures the workspace while it uploads; absent until it has,
and always for an agent without `workspace_size_v1`), `upload_rate_bytes_per_second` (over the last 5
parts, from the second part on) and `estimated_completion_at` (with both). The estimate is the host's
upload speed so far: a home connection can take hours, and an export still pending 24 hours after it was
requested is failed.

## Path parameters

- `rental_id`, string (uuid), required
- `export_id`, string (uuid), required

## Responses

### 200

The export.

- `id`, string (uuid), required
- `state`, WorkspaceExportState, required: `pending`: the agent has not finished uploading. `ready`: download it. `failed`: see `error`. `cancelled`: a member cancelled it while it was pending; nothing was kept.
- `size_bytes`, integer (int64): The size of the tar file; with `ready`.
- `download_url`, string: Removed in: never present. A ready export is downloaded through a single-use, charged link: `createWorkspaceExportDownloadLink`. Kept in the schema so generated clients keep compiling.
- `expires_at`, string (date-time): Removed in: never present (it was when `download_url` stopped working).
- `error`, string: Why a `failed` export failed.
- `total_bytes`, integer (int64): . The size the tar file is expected to have, measured by the host's agent (capability `workspace_size_v1`) while it uploads: the apparent size of every file under `/workspace` plus the tar headers. Absent until the agent has measured it. An estimate: files the workload changed, or that the engine adds, can make the file a little larger or smaller.
- `uploaded_bytes`, integer (int64): . With `pending`: the bytes of the parts the agent has finished uploading (0 before the first); the part in flight is not counted. With `ready`: `size_bytes`.
- `upload_rate_bytes_per_second`, integer (int64): . With `pending`: how fast the host has been uploading, in bytes per second, over its last 5 parts (fewer at the start). Absent until the agent has finished its first part.
- `estimated_completion_at`, string (date-time): . With `pending`, `total_bytes` and `upload_rate_bytes_per_second`: when the upload should finish at that rate. It may be more than 24 hours after `requested_at`; such an export fails at 24 hours unless the host speeds up.

Example:

```json
{
  "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "state": "pending",
  "size_bytes": 0,
  "download_url": "string",
  "expires_at": "2026-10-15T12:00:00Z",
  "error": "string",
  "total_bytes": 0,
  "uploaded_bytes": 0,
  "upload_rate_bytes_per_second": 0,
  "estimated_completion_at": "2026-10-15T12:00:00Z"
}
```

### 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/workspace-exports/$EXPORT_ID" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
