# Get what a rental has cost

> GET /v1/rentals/{rental_id}/charges. Billed time and the total charged for one of the organization's rentals.

Source: https://legion.ambient.xyz/docs/api/billing/get-rental-charges

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

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

Billed time and the total charged for one of the organization's
rentals. A rental that has not been billed yet (usage is billed 60 to
90 seconds after it starts running) returns zeros. A rental the
organization did not rent returns 404, including rentals on its own
hosts (see `getRentalEarnings`). Requires `billing.read`.

## Path parameters

- `rental_id`, string (uuid), required

## Responses

### 200

The rental's charges.

- `rental_id`, string (uuid), required
- `seconds`, integer (int64), required: Billed seconds across every usage segment.
- `charged`, SignedMoney, required: An amount of money in minor units (cents for USD) that may be negative: a debit, a balance below zero, or an overpaid provider.
  - `amount_minor`, integer (int64), required
  - `currency`, MoneyCurrency, required: ISO 4217 currency code. Only USD is supported.
- `renter_fee`, SignedMoney: . The renter platform fee the rental paid on its GPU time. `charged` is what the renter paid for the GPU time, all-in: the usage charges plus this fee. Zero for rentals created before and for own use.
- `storage_charged`, SignedMoney, required: What the rental was charged, apart from `charged`, for the disk it kept while stopped (ledger cause `storage`), all-in with `storage_renter_fee`. Zero for a rental never billed for storage.
- `storage_renter_fee`, SignedMoney: . The renter platform fee on the rental's storage, included in `storage_charged`.
- `backup_charged`, SignedMoney: . What the rental's backups were charged, net of their refunds, and further download links (ledger cause `backup`), apart from `charged` and `storage_charged`. Zero for none.

Example:

```json
{
  "rental_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "seconds": 0,
  "charged": {
    "amount_minor": -250,
    "currency": "USD"
  },
  "renter_fee": {
    "amount_minor": -250,
    "currency": "USD"
  },
  "storage_charged": {
    "amount_minor": -250,
    "currency": "USD"
  },
  "storage_renter_fee": {
    "amount_minor": -250,
    "currency": "USD"
  },
  "backup_charged": {
    "amount_minor": -250,
    "currency": "USD"
  }
}
```

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

### 503

The billing service failed or did not answer within 3 seconds
(`billing_unavailable`). Nothing changed; retry with backoff.

## Errors

- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 503 [`billing_unavailable`](https://legion.ambient.xyz/docs/errors#billing_unavailable)

## Example request

```sh
curl -s "https://api.legion.ambient.xyz/v1/rentals/$RENTAL_ID/charges" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
