---
title: api-keys
description: WorkspaceのAPIキーを作成・更新・失効する。
canonical_url: https://orchestor.io/docs/cli/api-keys
markdown_url: https://orchestor.io/docs/cli/api-keys.md
contentType: reference
---

# api-keys

`orc api-keys` は、選択したWorkspaceのAPIキーを作成し、メタデータや権限を確認・変更し、不要なキーを失効させるコマンドです。作成時に一度だけ返る秘密値は新しい非公開ファイルへ保存し、通常の出力にはメタデータだけを表示します。

[`orc auth login`](https://orchestor.io/docs/cli/auth.md) で取得したCLI認証を使用します。ブラウザーAPIのセッション認証も利用できますが、APIキー自身ではキーを管理できません。CLIが作成できるのはWorkspaceスコープのキーです。

## 使い方

```bash title="terminal"
orc api-keys list --json
```

*APIキーのメタデータを一覧にします。*

## サブコマンド

### `list`

キーのメタデータを一覧にします。`--limit` と `--cursor` でページを指定できます。応答に秘密値は含まれません。

```bash title="terminal"
orc api-keys list [options]
```

### `create`

`--name` と新しい保存先の `--output` を指定してキーを作成します。`--mode` は `live` または `test`、`--type` は `read_only` または `read_write` です。`--scope organization` と `workspace_id: null` はAPIを呼ぶ前に拒否されます。

```bash title="terminal"
orc api-keys create [options]
```

#### 固有のオプション

##### `--idempotency-key`

Retry identity for operations that support idempotency. Use a unique key for each new operation, and reuse it only when retrying the same HTTP method, path, query values and exact request body. JSON whitespace changes can count as a different body. Keys contain 1–255 characters after trimming and expire after 24 hours. A completed JSON response is replayed without repeating the operation. A different request using the same key returns 409 idempotency_error. An in-progress request returns 409 idempotency_in_progress with Retry-After: 2. Whether this header is required depends on the operation.

型: `string`。任意。

```bash title="terminal"
orc api-keys create --idempotency-key <value>
```

##### `--mode`

Key mode. `live` consumes credits, `test` uses sandbox.; enum: live|test

型: `string`。任意。

```bash title="terminal"
orc api-keys create --mode <value>
```

##### `--name`

(required) Required human-readable name.

型: `string`。任意。

```bash title="terminal"
orc api-keys create --name <value>
```

##### `--scope`

Credential binding scope. Organization scope creates a key without a Workspace binding.; enum: workspace|organization

型: `string`。任意。

```bash title="terminal"
orc api-keys create --scope <value>
```

##### `--type`

Permission type. `read_only` grants read access; `read_write` grants read and write access.; enum: read_only|read_write

型: `string`。任意。

```bash title="terminal"
orc api-keys create --type <value>
```

##### `--workspace-id`

Optional explicit Workspace binding. Omit for the current Workspace; use null with organization scope.; (use "null" or "reset" to clear)

型: `string`。任意。

```bash title="terminal"
orc api-keys create --workspace-id <value>
```

### `update`

キーIDを指定し、`--name`、`--type`、またはJSONオブジェクトの `--permissions` を更新します。秘密値の再取得ではありません。

```bash title="terminal"
orc api-keys update <key-id> [options]
```

#### 固有のオプション

##### `--name`

New display name.

型: `string`。任意。

```bash title="terminal"
orc api-keys update <key-id> --name <value>
```

##### `--permissions`

Endpoint-group permission map. Each key is an endpoint group name,
value is the access level. Unspecified groups default to `none`.; (JSON object, e.g. '{"custom_id":"x"}')

型: `string`。任意。

```bash title="terminal"
orc api-keys update <key-id> --permissions <value>
```

##### `--type`

Permission preset for a user-owned key.; enum: read_only|read_write

型: `string`。任意。

```bash title="terminal"
orc api-keys update <key-id> --type <value>
```

### `delete`

キーIDを指定して失効させます。失効は取り消せません。非対話環境では `--yes` が必要です。

```bash title="terminal"
orc api-keys delete <key-id> [options]
```

## 使用例

### 秘密値を新しい非公開ファイルへ保存して作成します。

```bash title="terminal"
orc api-keys create --workspace WORKSPACE_ID --name "Automation key" --scope workspace --output /secure/path/api-key --json
```

*秘密値を新しい非公開ファイルへ保存して作成します。*

### キーの名前を変更します。

```bash title="terminal"
orc api-keys update KEY_ID --workspace WORKSPACE_ID --name "Renamed key" --json
```

*キーの名前を変更します。*

### 不要になったキーを失効させます。

```bash title="terminal"
orc api-keys delete KEY_ID --workspace WORKSPACE_ID --yes --json
```

*不要になったキーを失効させます。*

## 秘密値の保存

`--output` には存在しないファイルを指定してください。CLIは所有者だけが読める権限 (`0600`) で原子的に保存し、既存ファイルを上書きしません。保存先の親ディレクトリを用意し、ソース管理外の場所を使用してください。標準出力は秘密値を除いたメタデータです。

## グローバルオプション

`orc api-keys` では、次の[グローバルオプション](https://orchestor.io/docs/cli/global-flags.md)を使用できます。

- [`--help`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%98%E3%83%AB%E3%83%97)
- [`--workspace`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%AF%E3%83%BC%E3%82%AF%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9)
- [`--json`](https://orchestor.io/docs/cli/global-flags.md#json-%E5%87%BA%E5%8A%9B)
- [`--pretty`](https://orchestor.io/docs/cli/global-flags.md#json-%E5%87%BA%E5%8A%9B)
- [`--format`](https://orchestor.io/docs/cli/global-flags.md#%E5%87%BA%E5%8A%9B%E5%BD%A2%E5%BC%8F)
- [`--field`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB%E3%83%89%E3%81%AE%E6%8A%BD%E5%87%BA)
- [`--fields`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%95%E3%82%A3%E3%83%BC%E3%83%AB%E3%83%89%E3%81%AE%E6%8A%BD%E5%87%BA)
- [`--raw`](https://orchestor.io/docs/cli/global-flags.md#%E5%80%A4%E3%81%A0%E3%81%91%E3%82%92%E5%87%BA%E5%8A%9B)
- [`--output`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%B8%E3%81%AE%E5%87%BA%E5%8A%9B)
- [`--no-pager`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%9A%E3%83%BC%E3%82%B8%E9%80%81%E3%82%8A)
- [`--dry-run`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E3%81%AE%E4%BA%8B%E5%89%8D%E7%A2%BA%E8%AA%8D)
- [`--yes`](https://orchestor.io/docs/cli/global-flags.md#%E7%A2%BA%E8%AA%8D%E3%81%AE%E7%9C%81%E7%95%A5)
- [`--limit`](https://orchestor.io/docs/cli/global-flags.md)
- [`--cursor`](https://orchestor.io/docs/cli/global-flags.md)
- [`--stdin`](https://orchestor.io/docs/cli/global-flags.md#%E6%A8%99%E6%BA%96%E5%85%A5%E5%8A%9B)
- [`--from-stdin`](https://orchestor.io/docs/cli/global-flags.md#%E6%A8%99%E6%BA%96%E5%85%A5%E5%8A%9B)
- [`--page-all`](https://orchestor.io/docs/cli/global-flags.md#%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E3%83%9A%E3%83%BC%E3%82%B8%E3%82%92%E5%8F%96%E5%BE%97)
- [`--timing`](https://orchestor.io/docs/cli/global-flags.md#%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E6%99%82%E9%96%93)
- [`--readonly`](https://orchestor.io/docs/cli/global-flags.md#%E8%AA%AD%E3%81%BF%E5%8F%96%E3%82%8A%E5%B0%82%E7%94%A8%E3%83%A2%E3%83%BC%E3%83%89)
- [`--wrap-untrusted`](https://orchestor.io/docs/cli/global-flags.md#%E5%A4%96%E9%83%A8%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%AE%E7%9B%AE%E5%8D%B0%E4%BB%98%E3%81%91)

各オプションの詳細と使用例は、[グローバルオプション](https://orchestor.io/docs/cli/global-flags.md)を参照してください。

---

[Documentation index](https://orchestor.io/docs/llms.txt)
