Loading...
    • 開發者指南
    • API 參考
    • MCP
    • 資源
    • 發行說明
    Search...
    ⌘K
    入門
    Claude 簡介快速開始
    模型與定價
    模型概覽選擇模型Claude 4.6 新功能遷移指南模型棄用定價
    使用 Claude 構建
    功能概覽使用 Messages API處理停止原因提示詞最佳實踐
    上下文管理
    上下文視窗壓縮上下文編輯
    功能
    提示詞快取延伸思考自適應思考思考力度串流訊息批次處理引用多語言支援Token 計數嵌入視覺PDF 支援Files API搜尋結果結構化輸出
    工具
    概覽如何實作工具使用細粒度工具串流Bash 工具程式碼執行工具程式化工具呼叫電腦使用工具文字編輯器工具網頁擷取工具網頁搜尋工具記憶工具工具搜尋工具
    Agent Skills
    概覽快速開始最佳實踐企業級 Skills透過 API 使用 Skills
    Agent SDK
    概覽快速開始TypeScript SDKTypeScript V2(預覽版)Python SDK遷移指南
    API 中的 MCP
    MCP 連接器遠端 MCP 伺服器
    第三方平台上的 Claude
    Amazon BedrockMicrosoft FoundryVertex AI
    提示詞工程
    概覽提示詞產生器使用提示詞範本提示詞改進器清晰直接使用範例(多範例提示)讓 Claude 思考(CoT)使用 XML 標籤賦予 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 概覽

    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. 您使用 Admin API 金鑰在 x-api-key 標頭中發送請求
    2. API 允許您管理:
      • 組織成員及其角色
      • 組織成員邀請
      • 工作區及其成員
      • API 金鑰

    這適用於:

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

    組織角色和權限

    共有五個組織層級的角色。請參閱更多詳細資訊此處。

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

    關鍵概念

    組織成員

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

    Shell
    # List organization members
    curl "https://api.anthropic.com/v1/organizations/users?limit=10" \
      --header "anthropic-version: 2023-06-01" \
      --header "x-api-key: $ANTHROPIC_ADMIN_KEY"
    
    # Update member role
    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"}'
    
    # Remove member
    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
    # Create invite
    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"
      }'
    
    # List invites
    curl "https://api.anthropic.com/v1/organizations/invites?limit=10" \
      --header "anthropic-version: 2023-06-01" \
      --header "x-api-key: $ANTHROPIC_ADMIN_KEY"
    
    # Delete invite
    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
    # Create workspace
    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"}'
    
    # List workspaces
    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"
    
    # Archive workspace
    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
    # Add member to workspace
    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"
      }'
    
    # List workspace members
    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"
    
    # Update member role
    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"
      }'
    
    # Remove member from workspace
    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
    # List API keys
    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"
    
    # Update API key
    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)提供詳細的使用量資料,包括 token 計數和請求指標,按工作區、使用者和模型等各種維度分組。
    • 費用端點(/v1/organizations/cost_report)提供與組織使用量相關的費用資料,讓您能夠按工作區或描述追蹤支出和分配成本。

    這些端點提供了對組織使用量和相關費用的詳細洞察。

    存取 Claude Code 分析

    對於使用 Claude Code 的組織,Claude Code Analytics API 提供詳細的生產力指標和使用量洞察:

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

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

    最佳實踐

    為了有效使用 Admin API:

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

    常見問題

    Was this page helpful?

    • Admin API 的運作方式
    • API 金鑰
    • 存取 Claude Code 分析