
# tdx api-keys

Manage API keys (tokedex_ik_).

Create, list, view, disable, enable, rotate and revoke API keys. Issued and rotated tokens go only to a new owner-only --token-file, never stdout, JSON or jq. --owner maps the gateway owner object; another personal holder requires --secretless and gateway authorization. Session-only pickup is unavailable; use the dashboard as the holder. Dry-run creates no credential file.

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 api-keys list](/cli/reference/api-keys#tdx-api-keys-list) | List API keys. | Read |
| [tdx api-keys view](/cli/reference/api-keys#tdx-api-keys-view) | Read an API key by public id. | Read |
| [tdx api-keys create](/cli/reference/api-keys#tdx-api-keys-create) | Create an API key or a secretless offer. | Write |
| [tdx api-keys edit](/cli/reference/api-keys#tdx-api-keys-edit) | Update an API key provider restriction. | Write |
| [tdx api-keys enable](/cli/reference/api-keys#tdx-api-keys-enable) | Enable an API key. | Write |
| [tdx api-keys disable](/cli/reference/api-keys#tdx-api-keys-disable) | Disable an API key. | Write |
| [tdx api-keys rotate](/cli/reference/api-keys#tdx-api-keys-rotate) | Issue a new secret generation. | Write |
| [tdx api-keys revoke](/cli/reference/api-keys#tdx-api-keys-revoke) | Revoke an API key. | Write |
| [tdx api-keys pickup](/cli/reference/api-keys#tdx-api-keys-pickup) | Claim a secretless offer as its signed-in holder. | Not available yet |

## tdx api-keys list

List API keys.

**Reads**

Read one gateway page of public key metadata. hasMore and nextCursor report truncation; tokens, grants, extensions and secret generations are withheld. See [Masked read output](/cli/reference#masked-read-output). Large pages can exceed these limits; tdx api GET /control/v1/inference-keys --field limit=20 --json reads a smaller page through the generic api command, masked by the same policy.

```bash
# GET /control/v1/inference-keys
tdx api-keys list [flags]
```

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

| Field | Type | Description |
|---|---|---|
| `keys` | public-key[] | Key id, name, status, creation and expiry only. |
| `hasMore` | boolean | Whether the gateway has another page. |
| `nextCursor` | string\|null | Gateway continuation cursor; null on the final page. |

## tdx api-keys view

Read an API key by public id.

**Reads**

Requires inference_keys.read. Read one key's public metadata: id, name, status, creation, expiry, allowed models and providers, and each secret generation's number and state (current, grace or retired). Tokens, verifiers, owners, grants, extensions and secret-generation timestamps are withheld. Reads are read-only and --dry-run still reads. See [Masked read output](/cli/reference#masked-read-output).

```bash
# GET /control/v1/inference-keys/:keyId
tdx api-keys view --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Public resource id; never a credential. |

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

| Field | Type | Description |
|---|---|---|
| `key` | public-key-detail | Key id, name, status, creation, expiry, allowedModels and allowedProviders (null for no additional restriction) and generations (number and state only). |

## tdx api-keys create

Create an API key or a secretless offer.

**Writes**

The gateway mints the credential only into a new --token-file (exclusive owner-only 0600 file; existing safe parent required), never stdout, JSON or jq. --owner sends the existing gateway owner object; when omitted the gateway defaults ownership. A personal key for another holder requires --secretless; gateway permissions and workspace policy still apply. Without --owner, user/PAT callers default to their own personal key, while master-key and admin-key callers default to unowned keys. Secretless offers require a personal owner; master-key and admin-key callers can name a personal owner with --owner. Pickup requires an interactive dashboard session and is unavailable to this bearer-only CLI. File preflight happens before POST; a committed mint with failed delivery is reported explicitly, never retried or printed as a fallback. Dry-run reads no secret files or profiles, makes no request and creates no files; the gateway has not checked the requested policy and may reject or adjust it. See [Checked request values](/cli/reference#checked-request-values) and [Masked write output](/cli/reference#masked-write-output).

```bash
# POST /control/v1/inference-keys
tdx api-keys create --name <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--name` | string |  | Display name. |

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--allowed-model` | string |  | Exact public model id from tdx models list; repeat for multiple ids. Repeatable. |
| `--all-models` | boolean | `false` | Request every model allowed by workspace policy. |
| `--allowed-provider` | string |  | Exact catalogue provider id; repeat for multiple ids. Repeatable. |
| `--all-providers` | boolean | `false` | Remove the additional key restriction; workspace provider policy still applies. |
| `--description` | string |  | Non-secret description. |
| `--expires-at` | datetime |  | Absolute ISO-8601 expiry; omitted uses gateway policy. |
| `--secretless` | boolean | `false` | Create an offer without issuing a token. |
| `--token-file` | path |  | New owner-only token file; never overwrite an existing path. |
| `--owner` | json |  | Owner JSON: kind personal\|service\|none, userId and workspaceId strings or null; omitted ids become null. |

**Constraints**

- Exactly one of `--allowed-model`, `--all-models`
- At most one of `--allowed-provider`, `--all-providers`
- At most one of `--secretless`, `--token-file`
- `--token-file` is required unless `--secretless` or `--dry-run`

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

| Field | Type | Description |
|---|---|---|
| `key` | public-key | Key id, name, status, creation and expiry only. |
| `credential` | delivery-metadata | Delivery status and destination kind only; never a token or path. |
| `preview` | write-preview | Requested changes, unchecked by the gateway; never credentials. |

## tdx api-keys edit

Update an API key provider restriction.

**Writes**

Change only the additional provider restriction. All providers remains bounded by workspace policy. See [Masked write output](/cli/reference#masked-write-output).

```bash
# PATCH /control/v1/inference-keys/:keyId
tdx api-keys edit --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Public resource id; never a credential. |

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--allowed-provider` | string |  | Exact catalogue provider id; repeat for multiple ids. Repeatable. |
| `--all-providers` | boolean | `false` | Remove the additional key restriction; workspace provider policy still applies. |

**Constraints**

- Exactly one of `--allowed-provider`, `--all-providers`

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

| Field | Type | Description |
|---|---|---|
| `key` | public-key-detail\|null | Public key metadata and provider restriction; null during dry-run. |
| `preview` | write-preview\|null | Requested changes only; null after execution. |

## tdx api-keys enable

Enable an API key.

**Writes**

Requires inference_keys.manage. Enable a disabled key by public id; revoked keys stay refused with KEY_REVOKED and expired keys with CONFLICT (exit 6). No request body is sent. A key already in that state is answered unchanged. Dry-run reports the requested change only without reading secret files or profiles, sending requests or creating files. See [Checked request values](/cli/reference#checked-request-values) and [Masked write output](/cli/reference#masked-write-output).

```bash
# POST /control/v1/inference-keys/:keyId/enable
tdx api-keys enable --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Public resource id; never a credential. |

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

| Field | Type | Description |
|---|---|---|
| `key` | public-key | Key id, name, status, creation and expiry only. |
| `preview` | write-preview\|null | Requested change, unchecked by the gateway; null after execution. |

## tdx api-keys disable

Disable an API key.

**Writes**

Requires inference_keys.manage. Disable by public id: the key stops authenticating within the gateway's propagation bound, and tdx api-keys enable reverses it. No request body is sent. A key already in that state is answered unchanged. Dry-run reports the requested change only without reading secret files or profiles, sending requests or creating files. See [Checked request values](/cli/reference#checked-request-values) and [Masked write output](/cli/reference#masked-write-output).

```bash
# POST /control/v1/inference-keys/:keyId/disable
tdx api-keys disable --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Public resource id; never a credential. |

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

| Field | Type | Description |
|---|---|---|
| `key` | public-key | Key id, name, status, creation and expiry only. |
| `preview` | write-preview\|null | Requested change, unchecked by the gateway; null after execution. |

## tdx api-keys rotate

Issue a new secret generation.

**Writes**

Requires inference_keys.manage; a personal key can be rotated only by its holder (otherwise forbidden, exit 4). Issue a new secret generation by public id. The gateway reveals the new token once: it goes only to a new --token-file (exclusive owner-only 0600 file reserved before POST; existing safe parent required; existing files and symlinks are never overwritten), never stdout, JSON, jq, hints or fallbacks. --grace sets how long the previous secret keeps working; omitted, nothing is sent and the gateway default (24h) applies. While an earlier superseded secret is still in grace, the gateway refuses another rotation with ROTATION_IN_PROGRESS (exit 6) unless --end-previous-grace ends that grace now. A committed rotation whose delivery failed or could not be confirmed, including an accepted reply that could not be read, fails with KEY_ROTATED_DELIVERY_FAILED (exit 1) and no token: do not repeat it blindly. A timeout leaves the outcome unknown (REQUEST_TIMEOUT, exit 7): inspect the key with tdx api-keys view before rotating again. Dry-run reads no secret files or profiles, makes no request and creates no files. See [Checked request values](/cli/reference#checked-request-values) and [Masked write output](/cli/reference#masked-write-output).

```bash
# POST /control/v1/inference-keys/:keyId/rotate
tdx api-keys rotate --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Public resource id; never a credential. |

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--token-file` | path |  | New owner-only token file; never overwrite an existing path. |
| `--grace` | one of `now`, `1h`, `24h`, `7d` |  | How long the previous secret keeps working; omitted uses the gateway default (24h). |
| `--end-previous-grace` | boolean | `false` | End the grace of an earlier secret that is still in grace instead of being refused. |

**Constraints**

- `--token-file` is required unless `--dry-run`

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

| Field | Type | Description |
|---|---|---|
| `key` | public-key | Key id, name, status, creation and expiry only. |
| `rotation` | rotation-metadata | New generation, previous generation and previous grace end (previousNotAfter); never a token. |
| `credential` | delivery-metadata | Delivery status and destination kind only; never a token or path. |
| `preview` | write-preview\|null | Requested change, unchecked by the gateway; null after execution. |

## tdx api-keys revoke

Revoke an API key.

**Writes**

Revoke by public id using the gateway default operator reason. Dry-run reports requested revocation only without reading secret files or profiles, sending requests or creating files. See [Checked request values](/cli/reference#checked-request-values) and [Masked write output](/cli/reference#masked-write-output).

```bash
# POST /control/v1/inference-keys/:keyId/revoke
tdx api-keys revoke --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Public resource id; never a credential. |

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

| Field | Type | Description |
|---|---|---|
| `key` | public-key | Key id, name, status, creation and expiry only. |
| `preview` | write-preview\|null | Requested change, unchecked by the gateway; null after execution. |

## tdx api-keys pickup

Claim a secretless offer as its signed-in holder.

**Not available yet.** Running it exits 7 with `NOT_IMPLEMENTED`.

Unavailable: pickup requires the holder's interactive dashboard session. This bearer-only CLI cannot call the session-only route; use the dashboard. No request or local credential read is performed.

```bash
# POST /control/v1/inference-keys/:keyId/pickup
tdx api-keys pickup --id <string> [flags]
```

**Required flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--id` | string |  | Public resource id; never a credential. |

**Optional flags**

| Flag | Type | Default | Description |
|---|---|---|---|
| `--token-file` | path |  | New owner-only token file; never overwrite an existing path. |
