# 管理者向けREST API

## 概要

Keeper管理コンソールのREST APIを使用すると、トークンを生成し、SIEMなどのサードパーティ統合に向けてKeeperのREST APIと連携できます。ボルトおよび管理機能に関連するAPIについては、[サービスモードREST API](/keeperpam/jp/commander-cli/service-mode-rest-api.md)のページをご参照ください。

{% hint style="info" %}
CSPMおよびMSP課金連携への対応は、近日中に提供予定です。
{% endhint %}

## 要件

* エンタープライズ**ルート管理者権限** (APIトークンを作成するために必須)
* CLIでトークンを管理するための**Keeperコマンダー**がインストール済み

## コマンダー (CLI) でAPIトークンを管理する

コマンダーCLIには、`public-api-key` コマンドグループがあり、`list`、`generate`、`revoke` の各操作を実行できます。以下のコードでよく使用される操作手順を記載しました。

### 1. APIトークンの一覧表示

```bash
# テーブル形式で表示
public-api-key list

# JSON 形式でファイルに出力
public-api-key list --format json --output api_keys.json

# CSV 形式でエクスポート
public-api-key list --format csv --output api_keys.csv
```

### 2. APIトークンの生成

```bash
# 30日間有効の SIEM キー (読み取り)
public-api-key generate --name "SIEM Integration" --roles "SIEM:1" --expires 30d

# 永続キー (有効期限なし) を JSON 形式で出力
public-api-key generate --name "Permanent Tool" --roles "SIEM:1" --expires never --format json --output backup_key.json
```

#### ロールとアクションコード

* **ロール:** `SIEM`
* **アクション:** `1 = READ`、`2 = READ_WRITE`
* **有効期限のオプション:** `24h`、`7d`、`30d`、`1y`、`never`

{% hint style="info" %}
例: `--roles "SIEM:1"` は、SIEM (読み取り) を意味します。
{% endhint %}

#### 3. APIトークンの取り消し

```bash
# 対話式で確認して取り消し
public-api-key revoke <token_value>

# 強制的に取り消し (確認なし)
public-api-key revoke <token_value> --force
```

#### セキュリティに関する注意事項

* APIトークンはパスワードと同様に扱い、定期的にローテーションしてください。
* 必要最小限のロールと操作に権限を制限してください。
* 有効期限はできるだけ短く設定し、無期限は特別な自動化用途に限って使用してください。
* トークンは安全な場所 (例: Keeperボルト) に保管してください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/commander-cli/admin-rest-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
