
# Command reference

Manage a running gateway through its management endpoints with a token, such as an admin key: API keys, budgets and spend, people, workspaces, models, observability and the audit log. Run any command with --help, or schema --json for every command at once. To administer a gateway's own store on its machine, without the server, see `tokedex-gateway --help`.

Each page here is built from the same schema as `tdx <command> --help`; `tdx <command> --help --json` prints it as JSON.

## Command groups

| Command | Description | Type |
|---|---|---|
| [tdx admin](/cli/reference/admin) | Inspect gateway administration capabilities. | Group |
| [tdx alert-channels](/cli/reference/alert-channels) | Alert destinations and Slack setup (dashboard only). | Group |
| [tdx alerts](/cli/reference/alerts) | Read and mark spend alerts in your inbox. | Group |
| [tdx api](/cli/reference/api) | Send an admin HTTP request. | Read or write |
| [tdx api-keys](/cli/reference/api-keys) | Manage API keys (tokedex_ik_). | Group |
| [tdx audit](/cli/reference/audit) | Read and follow the audit log (the dashboard's Events tab). | Group |
| [tdx auth](/cli/reference/auth) | Sign in with the browser or a token, and manage saved profiles. | Group |
| [tdx budgets](/cli/reference/budgets) | Manage spend budgets. | Group |
| [tdx completion](/cli/reference/completion) | Generate shell completion. | Local |
| [tdx config](/cli/reference/config) | Inspect compiled gateway configuration. | Group |
| [tdx doctor](/cli/reference/doctor) | Check connection, auth, catalogue and backend information. | Read |
| [tdx guide](/cli/reference/guide) | Print bundled agent getting-started material. | Local |
| [tdx identity-settings](/cli/reference/identity-settings) | Inspect sign-in and session settings. | Group |
| [tdx invites](/cli/reference/invites) | Manage one-shot invitation links. | Group |
| [tdx limits](/cli/reference/limits) | Read the calling API key's budgets and rate limits. | Read |
| [tdx models](/cli/reference/models) | Models callers can request from this gateway. | Group |
| [tdx observability](/cli/reference/observability) | Read inference traces and calls, the store status and its switch. | Group |
| [tdx open](/cli/reference/open) | Print or open the logged-in host dashboard. | Write |
| [tdx pricing](/cli/reference/pricing) | Inspect prices and manage price overrides. | Group |
| [tdx profile](/cli/reference/profile) | Your own gateway account profile (not a local connection profile). | Group |
| [tdx providers](/cli/reference/providers) | Manage provider credentials. | Group |
| [tdx schema](/cli/reference/schema) | Print the command tree. | Local |
| [tdx sessions](/cli/reference/sessions) | Inspect sessions; interactive revocation is unavailable. | Group |
| [tdx spend](/cli/reference/spend) | Read spend counters and settlements. | Group |
| [tdx sso-providers](/cli/reference/sso-providers) | Inspect SSO (OIDC sign-in) providers. | Group |
| [tdx usage](/cli/reference/usage) | Read usage reports. | Group |
| [tdx users](/cli/reference/users) | Manage people and their role assignments. | Group |
| [tdx workspaces](/cli/reference/workspaces) | Manage workspaces, their policy and spend. | Group |

## Global flags

Every command takes these flags.

| Flag | Type | Default | Description |
|---|---|---|---|
| `-h`, `--help` | boolean | `false` | Show help; runs nothing. |
| `--version` | boolean | `false` | Print the CLI version; reads no profile, credential or host. |
| `--host` | url |  | Gateway address: an HTTPS origin, or HTTP on localhost, 127.0.0.1 or [::1]. Also read from `TOKEDEX_HOST`. |
| `--profile` | string | `default` | Profile: 1-64 lowercase ASCII letters, digits, dots, underscores or hyphens; start with a letter or digit. Also read from `TOKEDEX_PROFILE`. |
| `--json` | field-list |  | Print versioned JSON; optionally keep only these comma-separated fields of data. |
| `--jq` | string |  | Filter the masked JSON with your installed jq; requires --json. A command that is not a read checks that the filter compiles before it sends anything. A filter that fails after a write exits 1 with CHANGE_APPLIED_JQ_FAILED and the unfiltered JSON on stdout: the change was applied. Under --dry-run the same failure is PREVIEW_JQ_FAILED, with nothing applied. |
| `--dry-run` | boolean | `false` | Show what a write would send without sending it; reads still run. |

## Environment variables

| Variable | Description |
|---|---|
| `TOKEDEX_HOST` | Gateway address; --host takes precedence. |
| `TOKEDEX_PROFILE` | Profile name; --profile takes precedence. |
| `TOKEDEX_TOKEN` | Token for this run only, such as an admin key; requires --host or TOKEDEX_HOST; never printed, and saved only by auth login. |
| `XDG_CONFIG_HOME` | Existing absolute directory whose tokedex/ folder holds saved profiles; unset, $HOME/.config is used (HOME must exist). |
| `HTTP_PROXY` | Always honored for HTTP and as HTTPS fallback without Node proxy opt-in; lowercase http_proxy takes precedence. |
| `HTTPS_PROXY` | Always honored for HTTPS regardless of NODE_USE_ENV_PROXY or NODE_OPTIONS; lowercase https_proxy takes precedence. |
| `NO_PROXY` | Direct-host exclusions for CLI transport, independent of Node proxy opt-in; lowercase no_proxy takes precedence. |

## Exit codes

| Code | Meaning |
|---|---|
| `0` | success |
| `1` | internal |
| `2` | usage |
| `3` | authentication |
| `4` | forbidden |
| `5` | not found |
| `6` | conflict |
| `7` | unavailable |

## Output and errors

A command that succeeds prints one JSON object to stdout, `{"schemaVersion": "tokedex.cli.v1", "command": …, "data": …}`, and exits 0. Help printed with `--help --json` uses `tokedex.cli-help.v1`. A command that fails prints `{"error": {"code": …, "hint": …, "fix": …}}` to stderr and exits with one of the codes above. [Scripts and agents](/cli/scripts-and-agents) shows how to read both.

## Shared behaviour

Many commands behave the same way in these respects. Their sections link here instead of repeating the text.

### Masked read output

Secrets in the output are masked, judged against the whole request and gateway reply, before --json selects fields or --jq runs; █ marks a masked value. Checked booleans, values the CLI sets itself and its source field (where present) print unmasked; source is only checked to exclude the token. A reply that exceeds the masking limits fails with OUTPUT_MASK_LIMIT (exit 7) and prints no values.

### Masked write output

Secrets in the output are masked, judged against the whole request and gateway reply, before --json selects fields or --jq runs; █ marks a masked value. Checked booleans, values the CLI sets itself and its source field (where present) print unmasked; source is only checked to exclude the token. The request is masked on its own first; if it exceeds the masking limits, the command fails with OUTPUT_MASK_LIMIT (exit 7) and sends nothing. A --dry-run preview has no reply, so it is masked against the request and TOKEDEX_TOKEN (when set) only. If the gateway accepts a write but its reply exceeds the limits, the command exits 1 with its applied-but-invalid error and prints no values; a preview that exceeds them fails with OUTPUT_MASK_LIMIT (exit 7).

### Checked request values

Values you pass are checked against TOKEDEX_TOKEN (when set) and the gateway's token prefixes; under --dry-run a token saved only in a profile cannot be compared, because the profile is not read.

### Values too long to print

A value the CLI cannot print safely is withheld on its own and the rest of the reply still prints: text longer than 4096 characters, such as a tag, title, project, agent name or a client-chosen id, prints as [withheld: too long], and a trace, trajectory or request id containing a control character such as a TAB prints as [withheld: control character]. Masking still sees the full value. A withheld id cannot be looked up. A client can also send the marker text itself, which then reads the same as a withheld value.

### People and role commands

Every value in the reply is masked before --json, --jq or any other output, and masking fails closed; a secret under an ordinary-looking name cannot be recognised. Under --dry-run a write shows its method, path and body with no diff, unchecked by the gateway, and sends no request, reads no credential or profile and writes no file. Invalid input is refused before anything happens. The gateway still decides permissions, which roles you may grant and which people an identity provider owns; changes to admin-level people need a dashboard session with a fresh sign-in, which this token-only CLI cannot provide. The CLI never escalates or retries.

### Invitation links

The gateway reveals a raw invitation URL once. Reserve a NEW owner-only 0600 --token-file before minting; existing files are never overwritten. The file contains the complete invitation link, never stdout, JSON, jq, hints or previews. Alternatively --secretless explicitly discards that link locally: the gateway still mints it, and no secretless field is sent. Masked or malformed links are never reported as delivered. Delivery failure or an uncertain write requires private state inspection, never blind repetition; no credential fallback is printed. See [People and role commands](/cli/reference#people-and-role-commands).

### Workspace reads

Uses auth status host-bound bearer rules; the gateway decides what this credential may read, and the CLI enforces no permission itself. --dry-run still performs this read. See [Masked read output](/cli/reference#masked-read-output). Key ids and names, an access review's key summaries, and budget, rate and lifetime settings in the gateway's own shapes print in clear unless they show too much of a token body. Other values the reply carries under key-like names (such as the source guardrail of a limit the guardrail sets, which masks key-preview adjustment reasons naming it) are learned as aliases, so matching public values may print as █ too. See [Checked request values](/cli/reference#checked-request-values).

### Workspace changes

Uses auth status host-bound bearer rules; the gateway authorizes and validates every change, and the CLI enforces no permission itself. Only the options you supply are sent. Structured inputs are inline JSON options, never files or stdin, whose object keys must be the gateway's field names for that option: a layer's models, maxKeyLifetimeDays, keyRpmMax and keyBudgetMax, and a budget's window and limit. Invalid local input is refused before any profile, credential or gateway access. --dry-run sends no request and reads no profile, credential, stdin or file; it shows only a local preview of the requested method, path and body, without current state, review or gateway checks. One request, never retried. See [Masked write output](/cli/reference#masked-write-output). Outside a --dry-run preview, key ids and names, a review's key summaries, and budgets (`{"window": day, week, month or total, "limit": a USD amount}`) and rate and lifetime settings in the gateway's own shapes print in clear unless they show too much of a token body. Other values sent or returned under key-like names (such as a budget in any other shape, or the source guardrail of a limit the guardrail sets, which masks the review kind) are learned as aliases, so matching public values may print as █ too. A --dry-run preview shows --key-budget-default and a layer's keyBudgetMax, and any string a layer holds under a key-like name, as █; a layer's number and null limits usually print as sent, but a number sharing digits with a whole-number budget limit prints as █ (write limits with a decimal point). See [Checked request values](/cli/reference#checked-request-values).

### Catalogue reads

Uses auth status host-bound bearer rules. The response shape is checked, then recursively masked like api output, so fields named like token, key, secret or credential (for example contextWindowTokens) are intentionally shown as █. Gateway error bodies are never displayed; --dry-run performs the same read.

### Catalogue changes

Input, including any definition file, is validated before any profile or gateway access. --dry-run reads only an explicit definition file, sends no request, reads no profile or credential and creates nothing; it shows the masked requested method, path and body, unchecked by the gateway. A completed write prints the masked, shape-checked response; gateway error bodies are never displayed and nothing is retried. Ids and other public values are 1-512 characters without control or format characters, line separators or whitespace at either end; an --id is also never . or .., and is percent-encoded into the route. See [Checked request values](/cli/reference#checked-request-values).

### Catalogue republishing

The gateway republishes the catalogue for this change, which can take several seconds on a large catalogue; the request deadline is 30 seconds, and a timeout means the outcome is unknown.

### Observability filters and output

Filter values are at most 512 characters without control characters and are refused before any request if they contain the bearer or a registered gateway token prefix; they are never echoed. Only supplied filters are sent. Output is a validated projection under fixed names; anything unexpected in the reply fails with INVALID_RESPONSE. Values pass the same fail-closed masking as api, with aliases learned from the request and the whole raw reply, dropped fields included; masked values print as █. Key metadata in the gateway's own forms prints in clear as JSON fields: ULID key ids (keyId), key labels (master key, virtual key and 6 lowercase hex digits, or a key id), key fingerprints (key_ and 16 lowercase hex digits), key kinds, key display names (keyName), key directories as calls list describes, the key lists and counts of an access review in the gateway's exact summary shapes, whose entries are judged by their own field names, and key budget, rate and lifetime settings. Where a command offers --key-id, a ULID key id prints in its own request path; a key-like query parameter or name=value text anywhere else is secret. When the request, whole raw reply and output of one command together show more positions of a known or learned gateway token's random body than leave 128 bits unseen with its checksum known, 17 or more for tokedex_ik_, tokedex_mk_, tokedex_ss_, tokedex_iv_ and tokedex_rs_ tokens and 22 or more for tokedex_vk_ tokens, each position counted once and only in runs of 8 or more consecutive characters, also when spaces or other separators split a run, every value showing any of them prints as █, a key display name included. Pieces shorter than 8 characters are not counted, so this covers previews and accidental pastes, not a key deliberately split into short pieces. Any other string of 8 or more characters under a secret-like name, except an RFC 3339 timestamp or a gateway entity id, prints as █ wherever it appears; this over-masking is intentional. A cursor that masking would change is refused (INVALID_RESPONSE), because a masked cursor cannot be passed back. A reply too large to mask fails with OUTPUT_MASK_LIMIT (exit 7); retry with a smaller --limit. --dry-run still performs this read.

### Alert output

Output values pass the same fail-closed masking as api, with aliases learned from the request and the whole reply; masked values print as █. A key alert's gateway key id, its drill-down link (/spend/?…&spendKey=\<id>) and its fallback link (/api-keys/?…&key=\<id>) print in clear when the link names that alert's own key; only these commands vouch for those links, so the same parameters anywhere else, such as in api output or in a link naming another key, are secret. Public values may still be over-masked: a key id that is not a gateway key id is treated as a secret, so it and its links print as █, and once such an alert is on the page, links sharing any query part of 8 or more characters with its drill-down link (such as the month or by=model) may print as █ too. Body positions of a known or learned gateway token are counted across the whole page, every alert and nextCursor included, so once the page shows too many of one token's positions every alert value showing any of them prints as █ and a nextCursor showing any of them is refused; each alert keeps its own work budget, so a large valid page lists whole. nextCursor is not masked but is refused if it echoes the bearer or a learned alias. A reply too large to mask (for list, retry with a smaller --limit) or too deep to mask, or one carrying a malformed cursor, a credential prefix in its cursor or a link that is not origin-relative, is refused.

### Audit event fields

Each event is projected under fixed names: envelope ids, times, category, severity, source, node, scope, actor (kind, id, auth method; the credential id is withheld), correlation, resource, revisions, and data as an array of { field, value } from a fixed list of the gateway's data field names; unknown data fields and idempotency key hashes are withheld.

### Sign-in settings output

Every reply value, including booleans, integers, sync and discovery.state, is masked; only the CLI constant source (always file) is added back afterwards. Values are masked under neutral CLI names and printed under the gateway's field names, so passwordLogin, minPasswordLength and allowLocalPasswordForSsoUsers are not erased by name and normally print real values; a number that echoes a secret elsewhere in the reply prints as █.
