# List billing activity

> GET /v1/billing/activity. The organization's activity on one side of its ledger, newest first, folded for people to read.

Source: https://legion.ambient.xyz/docs/api/billing/list-billing-activity

`GET https://api.legion.ambient.xyz/v1/billing/activity`

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

The organization's activity on one side of its ledger, newest first,
folded for people to read. Usage is metered in segments of
about a minute, each a ledger entry; here the segments of a rental's
run, from start to stop, are one `rental_session` item with its
rental and host, GPUs, start, end (absent while it runs), billed
seconds and amount. Every other ledger entry (top-ups, adjustments,
refunds, chargebacks, payouts, earnings recoveries) is its own
`ledger_entry` item. Items are ordered by `at`, the session's start
or the entry's time.

`account=balance` lists the rentals the organization rented and what
they charged (negative), with the balance's money entries. `account=earnings` lists the rentals on the organization's hosts and
what they earned it, with payouts and recoveries; a rental another
organization rented is identified by its ID only, without its name.

A session's amount is the sum of its segments' entries, so the
sessions add up, to the cent, to the usage entries of
`listLedgerEntries`. A session appears once its first segment is
billed (60 to 90 seconds after the rental starts running) and grows
while the rental runs; a page is a number of items, and paging never
skips or repeats one. With `rental_id`, only that rental's sessions
(a rental the organization did not rent, or that is not on its
hosts for `earnings`, is 404). Requires `billing.read`.

## Query parameters

- `cursor`, string: Opaque cursor from a previous page's `next_cursor`.
- `limit`, integer
- `account`, LedgerAccount, required: Which side of the ledger.
- `rental_id`, string (uuid): Only this rental's sessions.

## Responses

### 200

A page of activity.

- `items`, array of BillingActivityItem, required
  - `id`, string, required: Opaque and stable. A session keeps its ID while it grows.
  - `kind`, BillingActivityKind, required: `rental_session`: one run of a rental, its usage segments folded (`session`). `ledger_entry`: a ledger entry that is not usage (`entry`).
  - `at`, string (date-time), required: The session's start, or the entry's `occurred_at`. The list's order.
  - `amount`, SignedMoney, required: What it did to the account: a session's charge (negative, on `balance`) or earnings (on `earnings`), the sum of its segments' entries; an entry's amount. On `balance` a session's charge includes the renter platform fee posted on its segments.
  - `session`, RentalSession: A run of a rental, from when it started running to when it stopped, its host went offline or it was deleted: the usage segments Legion metered for it, one after another without a gap. A rental stopped and started again has a session for each run. `price_per_gpu_hour` is all-in for the renter (on `balance`, with the rental's renter platform fee) and the provider's own price for the provider (on `earnings`).
    - `rental_id`, string (uuid), required
    - `rental_name`, FriendlyName: The rental's friendly name. Present when the caller's organization rented it.
    - `host_id`, string (uuid), required
    - `host_name`, FriendlyName, required: A host's or rental's friendly name: a lowercase DNS label that starts with a letter and does not end with a hyphen. Unique across all hosts and rentals and never reused. A host's is generated as adjective-noun (`amber-falcon`) and can be changed by its owner; a rental's is generated as adjective-noun plus four base36 characters (`quiet-river-7k2f`) and never changes.
    - `gpu_model`, string, required
    - `gpu_count`, integer, required
    - `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.
    - `started_at`, string (date-time), required
    - `ended_at`, string (date-time): The end of the session's last billed segment. Absent while the session runs.
    - `seconds`, integer (int64), required: Billed seconds so far. GPU-hours are `seconds × gpu_count / 3600`.
    - `running`, boolean, required: The rental is running in this session now, so it is still billed and grows.
  - `entry`, LedgerEntry: Present on `ledger_entry` items. Its cause is never `usage`.
- `next_cursor`, string

Example:

```json
{
  "items": [
    {
      "id": "string",
      "kind": "rental_session",
      "at": "2026-10-15T12:00:00Z",
      "amount": {
        "amount_minor": -250,
        "currency": "USD"
      },
      "session": {
        "rental_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
        "rental_name": "quiet-river-7k2f",
        "host_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
        "host_name": "quiet-river-7k2f",
        "gpu_model": "NVIDIA GeForce RTX 4090",
        "gpu_count": 1,
        "price_per_gpu_hour": {
          "amount_minor": 250,
          "currency": "USD"
        },
        "started_at": "2026-10-15T12:00:00Z",
        "ended_at": "2026-10-15T12:00:00Z",
        "seconds": 1,
        "running": false
      },
      "entry": {
        "id": "string",
        "account": "balance",
        "amount": {
          "amount_minor": -250,
          "currency": "USD"
        },
        "cause": "usage",
        "rental_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
        "label": "string",
        "reason": "string",
        "occurred_at": "2026-10-15T12:00:00Z",
        "recorded_at": "2026-10-15T12:00:00Z",
        "promo": {
          "amount_minor": -250
        }
      }
    }
  ],
  "next_cursor": "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.

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

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

## Example request

```sh
curl -s "https://api.legion.ambient.xyz/v1/billing/activity?account=balance" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
