English ← MyDocs

Get Environment

get /v1/environments/{environment_id}

通过 ID 获取特定环境。

Path Parameters

  • environment_id: string

Header Parameters

  • "anthropic-beta": optional array of AnthropicBeta

    可选的请求头,用于指定要使用的 beta 版本。

    • string

    • "message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 22 more

      • "message-batches-2024-09-24"

      • "prompt-caching-2024-07-31"

      • "computer-use-2024-10-22"

      • "computer-use-2025-01-24"

      • "pdfs-2024-09-25"

      • "token-counting-2024-11-01"

      • "token-efficient-tools-2025-02-19"

      • "output-128k-2025-02-19"

      • "files-api-2025-04-14"

      • "mcp-client-2025-04-04"

      • "mcp-client-2025-11-20"

      • "dev-full-thinking-2025-05-14"

      • "interleaved-thinking-2025-05-14"

      • "code-execution-2025-05-22"

      • "extended-cache-ttl-2025-04-11"

      • "context-1m-2025-08-07"

      • "context-management-2025-06-27"

      • "model-context-window-exceeded-2025-08-26"

      • "skills-2025-10-02"

      • "fast-mode-2026-02-01"

      • "output-300k-2026-03-24"

      • "user-profiles-2026-03-24"

      • "advisor-tool-2026-03-01"

      • "managed-agents-2026-04-01"

      • "cache-diagnosis-2026-04-07"

Returns

  • BetaEnvironment object { id, archived_at, config, 7 more }

    用于云环境和自托管环境的统一环境资源。

    • id: string

      环境标识符(例如 'env_...')

    • archived_at: string

      环境归档时的 RFC 3339 时间戳,如果未归档则为 null

    • config: BetaCloudConfig or BetaSelfHostedConfig

      环境配置(Anthropic Cloud 或自托管)

      • BetaCloudConfig object { networking, packages, type }

        cloud 环境配置。

        • networking: BetaUnrestrictedNetwork or BetaLimitedNetwork

          网络配置策略。

          • BetaUnrestrictedNetwork object { type }

            无限制的网络访问。

            • type: "unrestricted"

              网络策略类型

              • "unrestricted"
          • BetaLimitedNetwork object { allow_mcp_servers, allow_package_managers, allowed_hosts, type }

            有限的网络访问。

            • allow_mcp_servers: boolean

              允许出站访问代理上配置的 MCP 服务器端点,超出 allowed_hosts 数组中列出的范围。

            • allow_package_managers: boolean

              允许出站访问公共包注册中心(PyPI、npm 等),超出 allowed_hosts 数组中列出的范围。

            • allowed_hosts: array of string

              指定容器可以访问的域名。

            • type: "limited"

              网络策略类型

              • "limited"
        • packages: BetaPackages

          包管理器配置。

          • apt: array of string

            要安装的 Ubuntu/Debian 包

          • cargo: array of string

            要安装的 Rust 包

          • gem: array of string

            要安装的 Ruby 包

          • go: array of string

            要安装的 Go 包

          • npm: array of string

            要安装的 Node.js 包

          • pip: array of string

            要安装的 Python 包

          • type: optional "packages"

            包配置类型

            • "packages"
        • type: "cloud"

          环境类型

          • "cloud"
      • BetaSelfHostedConfig object { type }

        自托管环境的配置。

        • type: "self_hosted"

          环境类型

          • "self_hosted"
    • created_at: string

      环境创建时的 RFC 3339 时间戳

    • description: string

      用户提供的环境描述

    • metadata: map[string]

      用户提供的元数据键值对

    • name: string

      环境的可读名称

    • type: "environment"

      对象类型(始终为 'environment')

      • "environment"
    • updated_at: string

      环境最后更新时的 RFC 3339 时间戳

    • scope: optional "organization" or "account"

      此环境的可见范围。'organization' 表示对所有账户可见。'account' 表示仅对拥有账户可见。

      • "organization"

      • "account"

Example

curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID \
    -H 'anthropic-version: 2023-06-01' \
    -H 'anthropic-beta: managed-agents-2026-04-01' \
    -H "X-Api-Key: $ANTHROPIC_API_KEY"

Response

{
  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "archived_at": null,
  "config": {
    "networking": {
      "allow_mcp_servers": false,
      "allow_package_managers": true,
      "allowed_hosts": [
        "api.example.com"
      ],
      "type": "limited"
    },
    "packages": {
      "apt": [
        "string"
      ],
      "cargo": [
        "string"
      ],
      "gem": [
        "string"
      ],
      "go": [
        "string"
      ],
      "npm": [
        "string"
      ],
      "pip": [
        "pandas",
        "numpy"
      ],
      "type": "packages"
    },
    "type": "cloud"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "description": "Python environment with data-analysis packages.",
  "metadata": {},
  "name": "python-data-analysis",
  "type": "environment",
  "updated_at": "2026-03-15T10:00:00Z",
  "scope": "organization"
}