• 消息
  • 托管智能体
  • 管理

Search...
⌘K
组织
Admin API工作区
身份验证
概览工作负载身份联合通过 API 管理 WIFWIF 参考
监控
用量与成本 API速率限制 APIClaude Code 分析 API
数据与合规
数据驻留API 与数据保留访问透明度
合规 API
概览获取访问权限活动动态聊天、文件和项目组织、用户、角色、群组和设置设计您的集成错误常见问题

Log in
Admin API
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Solutions

  • AI agents
  • Code modernization
  • Coding
  • Customer support
  • Education
  • Financial services
  • Government
  • Life sciences

Partners

  • Claude on AWS
  • Google Cloud's Vertex AI

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Company

  • Anthropic
  • Careers
  • Economic Futures
  • Research
  • News
  • Responsible Scaling Policy
  • Security and compliance
  • Transparency

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Help and security

  • Availability
  • Status
  • Support
  • Discord

Terms and policies

  • Privacy policy
  • Responsible disclosure policy
  • Terms of service: Commercial
  • Terms of service: Consumer
  • Usage policy
管理/组织

Admin API



Admin API 不适用于个人账户。 如需与团队成员协作并添加成员,请在 Console → Settings → Organization 中设置您的组织。

Admin API 允许您以编程方式管理组织的资源,包括组织成员、工作区和 API 密钥。这为管理任务提供了编程控制能力,否则这些任务需要在 Claude Console 中手动配置。



Admin API 需要特殊访问权限

Admin API 接受两种凭据:通过 x-api-key 标头发送的 Admin API 密钥(以 sk-ant-admin... 开头),或通过 authorization: Bearer 标头发送的具有 org:admin 作用域的 OAuth 不记名令牌。只有具有 admin 角色的组织成员才能通过 Claude Console 配置 Admin API 密钥,并且只有具有 admin、owner 或 primary owner 角色的成员才能获取 org:admin 令牌。



AWS 上的 Claude Platform: Admin API 的大部分功能在 AWS 上的 Claude Platform 中不可用。工作区端点(在 /v1/organizations/workspaces 上的创建、获取、列出、更新和归档)可用。其他端点(包括组织成员、工作区成员、邀请、API 密钥、使用情况报告、成本报告和速率限制报告)不可用。详情请参阅 AWS 上的 Claude Platform。

身份验证

使用任一凭据进行身份验证。以下示例以两种方式调用组织信息端点:

OAuth 不记名令牌:

cURL
curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/me" \
  --header "anthropic-version: 2023-06-01" \
  --header "authorization: Bearer $ANTHROPIC_OAUTH_TOKEN"

org:admin 令牌授予对整个组织的访问权限,无论底层配置文件或联合规则绑定到哪个工作区。要获取该令牌,请参阅使用 Admin API 管理 WIF 中的先决条件。

Admin API 密钥:

cURL
curl --fail-with-body -sS "https://api.anthropic.com/v1/organizations/me" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"

Admin API 的工作原理

当您使用 Admin API 时:

  1. 您使用身份验证部分中的任一凭据发出请求
  2. 该 API 允许您管理:
    • 组织成员及其角色
    • 组织成员邀请
    • 工作区及其成员
    • API 密钥
    • 服务账户、联合颁发者和联合规则(这些端点需要 org:admin OAuth 令牌;不接受 Admin API 密钥)

这适用于:

  • 自动化用户入职/离职流程
  • 以编程方式管理工作区访问权限
  • 监控和管理 API 密钥使用情况

组织角色和权限

共有五种组织级别的角色。更多详情请参阅 API Console 角色和权限一文。

角色权限
user可以使用 Workbench
claude_code_user可以使用 Workbench 和 Claude Code
developer可以使用 Workbench 并管理 API 密钥
billing可以使用 Workbench 并管理账单详情
admin可以执行上述所有操作,并管理用户

组织 owner 和 primary owner 拥有所有 admin 权限,并且还可以管理 admin。本页面中所有对 admin 角色的引用同样适用于 owner 和 primary owner。

关键概念

组织成员

您可以列出组织成员、更新成员角色以及移除成员。

cURL
# 列出组织成员
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 "content-type: application/json" \
  --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
# 创建邀请
curl --request POST "https://api.anthropic.com/v1/organizations/invites" \
  --header "anthropic-version: 2023-06-01" \
  --header "content-type: application/json" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{
    "email": "[email protected]",
    "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"

工作区

有关工作区的全面指南(包括 Console 和 API 示例),请参阅工作区。

工作区成员

管理用户对特定工作区的访问权限:

cURL
# 将成员添加到工作区
curl --request POST "https://api.anthropic.com/v1/organizations/workspaces/{workspace_id}/members" \
  --header "anthropic-version: 2023-06-01" \
  --header "content-type: application/json" \
  --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 "content-type: application/json" \
  --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 密钥:

cURL
# 列出 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 "content-type: application/json" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY" \
  --data '{
    "status": "inactive",
    "name": "New Key Name"
  }'

服务账户

创建和管理服务账户(svac_...),即 Workload Identity Federation(工作负载身份联合)令牌所代表的非人类身份。服务账户、联合颁发者或联合规则端点不接受 Admin API 密钥;请使用 org:admin OAuth 令牌。请参阅使用 Admin API 管理 WIF。

联合颁发者

注册 OIDC 身份提供商(fdis_...),其令牌可为您的组织声明工作负载身份。请参阅使用 Admin API 管理 WIF。

联合规则

管理将颁发者令牌映射到服务账户和作用域的规则(fdrl_...)。请参阅使用 Admin API 管理 WIF。

访问组织信息

使用 /v1/organizations/me 端点以编程方式获取有关您组织的信息。

例如:

cURL
curl "https://api.anthropic.com/v1/organizations/me" \
  --header "anthropic-version: 2023-06-01" \
  --header "x-api-key: $ANTHROPIC_ADMIN_KEY"
{
  "id": "12345678-1234-5678-1234-567812345678",
  "type": "organization",
  "name": "Organization Name"
}

此端点可用于以编程方式确定 Admin API 密钥所属的组织。

有关完整的参数详情和响应架构,请参阅组织信息 API 参考。

使用情况和成本报告

使用使用情况和成本 API 跟踪您组织的使用情况和成本。

Claude Code 分析

使用 Claude Code 分析 API 监控开发者生产力和 Claude Code 采用情况。

速率限制

使用速率限制 API 读取为您的组织及其工作区配置的速率限制。

合规 API

使用合规 API 检索您组织的审计和活动数据。Admin API 密钥只能读取活动动态;如需完整访问权限,请参阅获取合规 API 访问权限。

最佳实践

为了有效使用 Admin API:

  • 为工作区和 API 密钥使用有意义的名称和描述
  • 为失败的操作实施适当的错误处理
  • 定期审核成员角色和权限
  • 清理未使用的工作区和过期的邀请
  • 监控 API 密钥使用情况并定期轮换密钥

常见问题

有关工作区的具体问题,请参阅工作区常见问题。

Was this page helpful?

  • 身份验证
  • Admin API 的工作原理
  • 组织角色和权限
  • 关键概念
  • 组织成员
  • 组织邀请
  • 工作区
  • 工作区成员
  • API 密钥
  • 服务账户
  • 联合颁发者
  • 联合规则
  • 访问组织信息
  • 使用情况和成本报告
  • Claude Code 分析
  • 速率限制
  • 合规 API
  • 最佳实践
  • 常见问题