
# tdx spend

Read spend counters and settlements.

Read spend counters, series and settlements by exactly one selector. Read-only.

Every command also takes the [global flags](/cli/reference#global-flags) and reads the [environment variables](/cli/reference#environment-variables) that the command reference lists once.

## Commands

| Command | Description | Type |
|---|---|---|
| [tdx spend subject](/cli/reference/spend#tdx-spend-subject) | Read a scope's budgets, rate limits and spend. | Read |
| [tdx spend series](/cli/reference/spend#tdx-spend-series) | Read a scope's spend per window. | Read |
| [tdx spend settlements](/cli/reference/spend#tdx-spend-settlements) | Read recent settlements. | Read |

## tdx spend subject

Read a scope's budgets, rate limits and spend.

**Reads**

Read the budgets binding one key, user, workspace or the org, the constraining one, rate limits, spend per window and ledger state. Requests are not subjects. Budgets set to --on-limit alert never bind, so budgets leaves them out; when any target exactly this subject, alertOnlyBudgets counts them and names the budgets list command that shows them, from one more read (GET /control/v1/budgets, budgets.read). Only budgets whose target is this key, user, workspace or the org count: not budgets on the rest of a key's chain, nor a user's budgets within a workspace. alertOnlyBudgets is null both when there are none and when that read is refused or fails; a null never means the subject read failed. Requires spend.read on the selected scope; the gateway refuses scopes outside the reader's reach (403) and shows amounts through its money view (null when hidden). Exactly one selector is enforced locally before any request. Uses auth status host-bound bearer rules; reads are read-only and --dry-run still reads.

```bash
# GET /control/v1/spend/subject
# GET /control/v1/budgets
tdx spend subject [flags]
```

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--key-id` | string |  | Select one API key scope by public key id. |
| `--user-id` | string |  | Select one person scope by user id. |
| `--workspace-id` | string |  | Select one workspace scope by id. |
| `--scope-kind` | one of `key`, `user`, `workspace`, `org` |  | Select a scope by kind; key, user and workspace need --scope-id; org takes none. |
| `--scope-id` | string |  | Scope id for --scope-kind key, user or workspace. |

**Constraints**

- Exactly one of `--key-id`, `--user-id`, `--workspace-id`, `--scope-kind`
- `--scope-id` requires `--scope-kind`

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `subject` | spend-subject | Selected subject ids. |
| `effective` | effective-budget\|null | Tightest visible budget. |
| `budgets` | subject-budget[] | Visible binding budgets with Money limit, spent and remaining. |
| `rateLimits` | rate-limit[] | Key rate limits with per-minute rate, burst and enforcement scope. |
| `spend` | window-money | Money spent per window: day, week, month and total. |
| `ledger` | ledger-state | Spend ledger state. |
| `alertOnlyBudgets` | alert-only-budgets\|null | Count of alert-only budgets targeting exactly this subject (not its key chain or a workspace member scope) and the budgets list command that shows them; null when there are none, and also when they could not be read. |

## tdx spend series

Read a scope's spend per window.

**Reads**

Read one point per window between --from and --to; the gateway refuses more than 400 points. Requests have no series. Requires spend.read on the selected scope; the gateway refuses scopes outside the reader's reach (403) and shows amounts through its money view (null when hidden). Exactly one selector is enforced locally before any request. Uses auth status host-bound bearer rules; reads are read-only and --dry-run still reads.

```bash
# GET /control/v1/spend/series
tdx spend series [flags]
```

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--key-id` | string |  | Select one API key scope by public key id. |
| `--user-id` | string |  | Select one person scope by user id. |
| `--workspace-id` | string |  | Select one workspace scope by id. |
| `--scope-kind` | one of `key`, `user`, `workspace`, `org` |  | Select a scope by kind; key, user and workspace need --scope-id; org takes none. |
| `--scope-id` | string |  | Scope id for --scope-kind key, user or workspace. |
| `--window` | one of `day`, `week`, `month` |  | Window size; the gateway default is day. |
| `--from` | datetime |  | Series start; the gateway default is 30 days before --to. |
| `--to` | datetime |  | Series end; the gateway default is now. |

**Constraints**

- Exactly one of `--key-id`, `--user-id`, `--workspace-id`, `--scope-kind`
- `--scope-id` requires `--scope-kind`

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `scope` | spend-scope | Selected scope. |
| `window` | string | Window size. |
| `points` | spend-point[] | Window start, spent Money, call and token counts. |

## tdx spend settlements

Read recent settlements.

**Reads**

Read recent settlements of one scope or one request; a request id needs an install-wide reader. Requires spend.read on the selected scope; the gateway refuses scopes outside the reader's reach (403) and shows amounts through its money view (null when hidden). Exactly one selector is enforced locally before any request. Uses auth status host-bound bearer rules; reads are read-only and --dry-run still reads.

```bash
# GET /control/v1/spend/settlements
tdx spend settlements [flags]
```

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--key-id` | string |  | Select one API key scope by public key id. |
| `--user-id` | string |  | Select one person scope by user id. |
| `--workspace-id` | string |  | Select one workspace scope by id. |
| `--scope-kind` | one of `key`, `user`, `workspace`, `org` |  | Select a scope by kind; key, user and workspace need --scope-id; org takes none. |
| `--scope-id` | string |  | Scope id for --scope-kind key, user or workspace. |
| `--request-id` | string |  | Select one request's settlements; install-wide readers only. |
| `--limit` | integer |  | Positive integer; the gateway clamps it to 1-200 (default 50) and reports no truncation. |
| `--since` | datetime |  | Only settlements since this time. |

**Constraints**

- Exactly one of `--key-id`, `--user-id`, `--workspace-id`, `--scope-kind`, `--request-id`
- `--scope-id` requires `--scope-kind`

**Output fields** (inside `data`)

| Field | Type | Description |
|---|---|---|
| `settlements` | settlement[] | Id, kind, request id, times, cost Money (null when hidden), pricing, provider, model, price source and usage. |
