The Admin API is unavailable for individual accounts. To collaborate with teammates and add members, set up your organization in Console → Settings → Organization.

Admin APIを使用すると、組織メンバー、ワークスペース、APIキーなど、組織のリソースをプログラムで管理できます。これにより、Anthropic Consoleで手動設定が必要な管理タスクをプログラムで制御できます。

Admin APIには特別なアクセスが必要です

Admin APIには、標準のAPIキーとは異なる特別なAdmin APIキー(sk-ant-admin...で始まる)が必要です。管理者ロールを持つ組織メンバーのみが、Anthropic Consoleを通じてAdmin APIキーをプロビジョニングできます。

Admin APIの仕組み

Admin APIを使用する場合:

  1. x-api-keyヘッダーでAdmin APIキーを使用してリクエストを行います
  2. APIでは以下を管理できます:
    • 組織メンバーとその役割
    • 組織メンバーの招待
    • ワークスペースとそのメンバー
    • APIキー

これは以下の用途に便利です:

  • ユーザーのオンボーディング/オフボーディングの自動化
  • ワークスペースアクセスのプログラム管理
  • APIキー使用量の監視と管理

組織の役割と権限

組織レベルの役割は5つあります。詳細はこちらをご覧ください。

役割権限
userWorkbenchを使用可能
claude_code_userWorkbenchとClaude Codeを使用可能
developerWorkbenchを使用し、APIキーを管理可能
billingWorkbenchを使用し、請求詳細を管理可能
admin上記すべてに加えて、ユーザーを管理可能

主要概念

組織メンバー

組織メンバーの一覧表示、メンバーの役割更新、メンバーの削除ができます。

# 組織メンバーの一覧表示
curl "https://api.anthropic.com/v1/organizations/users?limit=10" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

# メンバーの役割更新
curl "https://api.anthropic.com/v1/organizations/users/{user_id}" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{"role": "developer"}'

# メンバーの削除
curl --request DELETE "https://api.anthropic.com/v1/organizations/users/{user_id}" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

組織への招待

ユーザーを組織に招待し、その招待を管理できます。

# 招待の作成
curl --request POST "https://api.anthropic.com/v1/organizations/invites" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{
    "email": "newuser@domain.com",
    "role": "developer"
  }'

# 招待の一覧表示
curl "https://api.anthropic.com/v1/organizations/invites?limit=10" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

# 招待の削除
curl --request DELETE "https://api.anthropic.com/v1/organizations/invites/{invite_id}" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

ワークスペース

リソースを整理するためにワークスペースコンソール)を作成・管理します:

# ワークスペースの作成
curl --request POST "https://api.anthropic.com/v1/organizations/workspaces" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{"name": "Production"}'

# ワークスペースの一覧表示
curl "https://api.anthropic.com/v1/organizations/workspaces?limit=10&include_archived=false" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

# ワークスペースのアーカイブ
curl --request POST "https://api.anthropic.com/v1/organizations/workspaces/{workspace_id}/archive" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

ワークスペースメンバー

特定のワークスペースへのユーザーアクセスを管理します:

# ワークスペースへのメンバー追加
curl --request POST "https://api.anthropic.com/v1/organizations/workspaces/{workspace_id}/members" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{
    "user_id": "user_xxx",
    "workspace_role": "workspace_developer"
  }'

# ワークスペースメンバーの一覧表示
curl "https://api.anthropic.com/v1/organizations/workspaces/{workspace_id}/members?limit=10" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

# メンバーの役割更新
curl --request POST "https://api.anthropic.com/v1/organizations/workspaces/{workspace_id}/members/{user_id}" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{
    "workspace_role": "workspace_admin"
  }'

# ワークスペースからのメンバー削除
curl --request DELETE "https://api.anthropic.com/v1/organizations/workspaces/{workspace_id}/members/{user_id}" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

APIキー

APIキーの監視と管理:

# APIキーの一覧表示
curl "https://api.anthropic.com/v1/organizations/api_keys?limit=10&status=active&workspace_id=wrkspc_xxx" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

# APIキーの更新
curl --request POST "https://api.anthropic.com/v1/organizations/api_keys/{api_key_id}" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{
    "status": "inactive",
    "name": "New Key Name"
  }'

ベストプラクティス

Admin APIを効果的に使用するには:

  • ワークスペースとAPIキーに意味のある名前と説明を使用する
  • 失敗した操作に対する適切なエラーハンドリングを実装する
  • メンバーの役割と権限を定期的に監査する
  • 未使用のワークスペースと期限切れの招待をクリーンアップする
  • APIキーの使用量を監視し、定期的にキーをローテーションする

FAQ