---
title: service-accounts
description: サービスアカウントを管理し、キーを安全に発行する。
canonical_url: https://orchestor.io/docs/cli/service-accounts
markdown_url: https://orchestor.io/docs/cli/service-accounts.md
contentType: reference
---

# service-accounts

`orc service-accounts` は、Workspaceに紐付く機械認証の主体を作成し、ロールや状態を参照・更新し、APIキーを発行するコマンドです。サービスアカウントを停止すると既存キーを無効にでき、再び有効にすることもできます。

CLIが管理できるのはWorkspaceに紐付くサービスアカウントだけです。作成・更新・キー発行には `project:update` 権限が必要です。キー発行前に、ソース管理外の新しい保存先ファイルを用意してください。

## 使い方

```bash title="terminal"
orc service-accounts list --workspace WORKSPACE_ID --json
```

*サービスアカウントを一覧にします。*

## サブコマンド

### `list`

ID、ロール、状態、Workspace IDを一覧にします。`--limit` と `--cursor` でページを指定します。

```bash title="terminal"
orc service-accounts list [options]
```

### `create`

名前を指定してWorkspaceスコープのサービスアカウントを作成します。CLIでは `--scope workspace` のみ対応し、`--scope organization` は拒否されます。

```bash title="terminal"
orc service-accounts 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 service-accounts create --idempotency-key <value>
```

##### `--name`

(required) Display name for the service account.

型: `string`。任意。

```bash title="terminal"
orc service-accounts create --name <value>
```

##### `--scope`

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

型: `string`。任意。

```bash title="terminal"
orc service-accounts create --scope <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 service-accounts create --workspace-id <value>
```

### `get`

サービスアカウントIDを指定して現在の情報を取得します。対象のWorkspaceを選択して実行してください。

```bash title="terminal"
orc service-accounts get <id> [options]
```

### `update`

名前や状態を更新します。`status` は `active`、`suspended`、`deleted` です。`suspended` は既存キーを無効にし、`active` に戻すと再び利用できます。`deleted` は恒久的な削除です。

```bash title="terminal"
orc service-accounts update <id> [options]
```

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

##### `--name`

Updated display name.

型: `string`。任意。

```bash title="terminal"
orc service-accounts update <id> --name <value>
```

##### `--status`

`active` — normal operation.
`suspended` — all keys disabled, can be reactivated.
`deleted` — permanent removal, all keys revoked.; enum: active|suspended|deleted

型: `string`。任意。

```bash title="terminal"
orc service-accounts update <id> --status <value>
```

### `keys create`

サービスアカウントID、キー名、権限と新しい `--output` を指定してキーを発行します。キーは一度だけ返り、所有者だけが読めるファイルへ保存されます。既存ファイルは上書きしません。

```bash title="terminal"
orc service-accounts keys create <id> [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 service-accounts keys create <id> --idempotency-key <value>
```

##### `--name`

(required) Required display name for the key.

型: `string`。任意。

```bash title="terminal"
orc service-accounts keys create <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 service-accounts keys create <id> --permissions <value>
```

## 使用例

### Workspaceのサービスアカウントを作成します。

```bash title="terminal"
orc service-accounts create --workspace WORKSPACE_ID --name "CI bot" --scope workspace --json
```

*Workspaceのサービスアカウントを作成します。*

### サービスアカウントを停止します。

```bash title="terminal"
orc service-accounts update SERVICE_ACCOUNT_ID --workspace WORKSPACE_ID --status suspended --json
```

*サービスアカウントを停止します。*

### 読み取り用のキーを安全なファイルへ保存します。

```bash title="terminal"
orc service-accounts keys create SERVICE_ACCOUNT_ID --workspace WORKSPACE_ID --name "CI read key" --permissions '{"answers":"read"}' --output /secure/path/service-account-key --json
```

*読み取り用のキーを安全なファイルへ保存します。*

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

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

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

## 発行したキーの管理

キーは標準出力や標準エラーに表示されません。ログ、チャット、Issue、ソースコードに秘密値を貼り付けないでください。通常出力のキーIDと [`orc api-keys list`](https://orchestor.io/docs/cli/api-keys.md) の `service_account_id` を使って対象を識別し、不要なキーは `orc api-keys delete` で失効させます。

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

`orc service-accounts` では、次の[グローバルオプション](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)
