Loading...
    • 開發者指南
    • API 參考
    • MCP
    • 資源
    • 發行說明
    Search...
    ⌘K
    開始使用
    Claude 簡介快速開始
    模型與定價
    模型概覽選擇模型Claude 4.5 新功能遷移至 Claude 4.5模型棄用定價
    使用 Claude 構建
    功能概覽使用 Messages API上下文窗口提示詞最佳實踐
    功能
    提示詞快取上下文編輯擴展思考努力串流消息批次處理引用多語言支援Token 計數嵌入視覺PDF 支援Files API搜尋結果結構化輸出
    工具
    概覽如何實現工具使用細粒度工具串流Bash 工具代碼執行工具程式化工具調用計算機使用工具文字編輯器工具網頁擷取工具網頁搜尋工具記憶體工具工具搜尋工具
    Agent Skills
    概覽快速開始最佳實踐使用 API 的 Skills
    Agent SDK
    概覽快速開始TypeScript SDKTypeScript V2 (預覽)Python SDK遷移指南
    API 中的 MCP
    MCP 連接器遠端 MCP 伺服器
    第三方平台上的 Claude
    Amazon BedrockMicrosoft FoundryVertex AI
    提示詞工程
    概覽提示詞生成器使用提示詞範本提示詞改進器清晰直接使用範例 (多次提示)讓 Claude 思考 (CoT)使用 XML 標籤給 Claude 一個角色 (系統提示詞)預填 Claude 的回應鏈接複雜提示詞長上下文提示擴展思考提示
    測試與評估
    定義成功標準開發測試案例使用評估工具降低延遲
    加強防護欄
    減少幻覺增加輸出一致性緩解越獄串流拒絕減少提示詞洩露保持 Claude 的角色
    管理和監控
    Admin API 概覽使用量和成本 APIClaude Code Analytics API
    Console
    Log in
    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

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • 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
    • Catalog
    • 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 允許您以程式方式管理組織的資源,包括組織成員、工作區和 API 金鑰。
    • Admin API 如何運作
    • API 金鑰
    • 存取 Claude Code 分析

    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 金鑰。這提供了對管理任務的程式控制,否則需要在 Claude Console 中進行手動配置。

    Admin API 需要特殊存取權限

    Admin API 需要特殊的 Admin API 金鑰(以 sk-ant-admin... 開頭),與標準 API 金鑰不同。只有具有管理員角色的組織成員才能透過 Claude Console 配置 Admin API 金鑰。

    Admin API 如何運作

    當您使用 Admin API 時:

    1. 您在 x-api-key 標頭中使用您的 Admin API 金鑰發出請求
    2. API 允許您管理:
      • 組織成員及其角色
      • 組織成員邀請
      • 工作區及其成員
      • API 金鑰

    這對以下情況很有用:

    • 自動化使用者上線/離線
    • 以程式方式管理工作區存取
    • 監控和管理 API 金鑰使用情況

    組織角色和權限

    有五個組織級別的角色。查看更多詳情 此處。

    角色權限
    user可以使用 Workbench
    claude_code_user可以使用 Workbench 和 Claude Code
    developer可以使用 Workbench 和管理 API 金鑰
    billing可以使用 Workbench 和管理帳單詳情
    admin可以執行上述所有操作,加上管理使用者

    關鍵概念

    組織成員

    您可以列出 組織成員、更新成員角色和移除成員。

    Shell
    # 列出組織成員
    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"

    組織邀請

    您可以邀請使用者加入組織並管理這些 邀請。

    Shell
    # 建立邀請
    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": "[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"

    工作區

    建立和管理 工作區(主控台)以組織您的資源:

    Shell
    # 建立工作區
    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"

    工作區成員

    管理 使用者對特定工作區的存取:

    Shell
    # 將成員新增到工作區
    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 金鑰:

    Shell
    # 列出 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"
      }'

    存取組織資訊

    使用 /v1/organizations/me 端點以程式方式取得有關您的組織的資訊。

    例如:

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

    此端點對於以程式方式確定 Admin API 金鑰所屬的組織很有用。

    如需完整的參數詳情和回應架構,請參閱 組織資訊 API 參考。

    存取使用情況和成本報告

    若要存取組織的使用情況和成本報告,請使用使用情況和成本 API 端點:

    • 使用情況端點(/v1/organizations/usage_report/messages)提供詳細的使用情況資料,包括權杖計數和請求指標,按工作區、使用者和模型等各種維度分組。
    • 成本端點(/v1/organizations/cost_report)提供與組織使用情況相關的成本資料,允許您追蹤支出並按工作區或描述分配成本。

    這些端點提供了對組織使用情況和相關成本的詳細見解。

    存取 Claude Code 分析

    對於使用 Claude Code 的組織,Claude Code 分析 API 提供詳細的生產力指標和使用見解:

    • Claude Code 分析端點(/v1/organizations/usage_report/claude_code)提供 Claude Code 使用情況的每日彙總指標,包括工作階段、程式碼行數、提交、拉取請求、工具使用統計資料,以及按使用者和模型細分的成本資料。

    此 API 使您能夠追蹤開發人員生產力、分析 Claude Code 採用情況,以及為組織建立自訂儀表板。

    最佳實踐

    若要有效使用 Admin API:

    • 為工作區和 API 金鑰使用有意義的名稱和描述
    • 為失敗的操作實施適當的錯誤處理
    • 定期審計成員角色和權限
    • 清理未使用的工作區和過期的邀請
    • 監控 API 金鑰使用情況並定期輪換金鑰

    常見問題