Claude Platform Docs

環境

建立環境
client.beta.environments.create(params, options?): BetaEnvironment
POST/v1/environments

使用指定的設定建立新環境。

列出環境
client.beta.environments.list(params?, options?): PageCursor<BetaEnvironment>
GET/v1/environments

列出環境,支援分頁。

取得環境
client.beta.environments.retrieve(environmentID, params?, options?): BetaEnvironment
GET/v1/environments/{environment_id}

依 ID 擷取特定環境。

更新環境
client.beta.environments.update(environmentID, params, options?): BetaEnvironment
POST/v1/environments/{environment_id}

更新現有環境的設定。

刪除環境
client.beta.environments.delete(environmentID, params?, options?): BetaEnvironmentDeleteResponse
DELETE/v1/environments/{environment_id}

依 ID 刪除環境。傳回刪除確認。

封存環境
client.beta.environments.archive(environmentID, params?, options?): BetaEnvironment
POST/v1/environments/{environment_id}/archive

依 ID 封存環境。已封存的環境無法用於建立新的工作階段。

Models
interface BetaCloudConfig { type: "cloud"; networking; packages }

cloud environment configuration.

interface BetaCloudConfigParams { type: "cloud"; networking; packages }

Request params for cloud environment configuration.

Fields default to null; on update, omitted fields preserve the existing value.

interface BetaEnvironment { type: "environment"; id; archived_at; /* 7 more */ }

Unified Environment resource for both cloud and self-hosted environments.

interface BetaEnvironmentDeleteResponse { type: "environment_deleted"; id }

Response after deleting an environment.

type: "environment_deleted"

The type of response

defaultenvironment_deleted
id: string

Environment identifier

interface BetaLimitedNetwork { type: "limited"; allow_mcp_servers; allow_package_managers; allowed_hosts }

Limited network access.

type: "limited"

Network policy type

allow_mcp_servers: boolean

Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the allowed_hosts array.

allow_package_managers: boolean

Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the allowed_hosts array.

allowed_hosts: Array<string>

Specifies domains the container can reach.

interface BetaLimitedNetworkParams { type: "limited"; allow_mcp_servers; allow_package_managers; allowed_hosts }

Limited network request params.

Fields default to null; on update, omitted fields preserve the existing value.

type: "limited"

Network policy type

allow_mcp_servers?: boolean | null

Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the allowed_hosts array. Defaults to false.

allow_package_managers?: boolean | null

Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the allowed_hosts array. Defaults to false on creation. Must be true when packages are specified.

allowed_hosts?: Array<string> | null

Specifies domains the container can reach.

interface BetaPackages { type: "packages"; apt; cargo; /* 4 more */ }

Packages (and their versions) available in this environment.

type?: "packages"

Package configuration type

defaultpackages
apt: Array<string>

Ubuntu/Debian packages to install

cargo: Array<string>

Rust packages to install

gem: Array<string>

Ruby packages to install

go: Array<string>

Go packages to install

npm: Array<string>

Node.js packages to install

pip: Array<string>

Python packages to install

interface BetaPackagesParams { type: "packages"; apt; cargo; /* 4 more */ }

Specify packages (and optionally their versions) available in this environment.

When versioning, use the version semantics relevant for the package manager, e.g. for pip use package==1.0.0. You are responsible for validating the package and version exist. Unversioned installs the latest.

Under limited networking, requires networking.allow_package_managers to be true.

interface BetaSelfHostedConfig { type: "self_hosted" }

Configuration for self-hosted environments.

type: "self_hosted"

Environment type

interface BetaSelfHostedConfigParams { type: "self_hosted" }

Request params for self_hosted environment configuration.

type: "self_hosted"

Environment type

interface BetaUnrestrictedNetwork { type: "unrestricted" }

Unrestricted network access.

type: "unrestricted"

Network policy type

環境工作

取得工作項目
client.beta.environments.work.retrieve(workID, params, options?): BetaSelfHostedWork
GET/v1/environments/{environment_id}/work/{work_id}

注意:這些端點會由 SDK 和 CLI 中提供的預先建置環境工作程式自動呼叫,用於協調使用自行託管沙箱環境的工作階段。此處列出僅供參考;您無需直接呼叫它們。

輪詢工作
client.beta.environments.work.poll(environmentID, params?, options?): BetaSelfHostedWork | null
GET/v1/environments/{environment_id}/work/poll

注意:這些端點會由 SDK 和 CLI 中提供的預先建置環境工作程式自動呼叫,用於協調使用自行託管沙箱環境的工作階段。此處列出僅供參考;您無需直接呼叫它們。

確認工作
client.beta.environments.work.ack(workID, params, options?): BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/ack

注意:這些端點會由 SDK 和 CLI 中提供的預先建置環境工作程式自動呼叫,用於協調使用自行託管沙箱環境的工作階段。此處列出僅供參考;您無需直接呼叫它們。

記錄心跳
client.beta.environments.work.heartbeat(workID, params, options?): BetaSelfHostedWorkHeartbeatResponse
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat

注意:這些端點會由 SDK 和 CLI 中提供的預先建置環境工作程式自動呼叫,用於協調使用自行託管沙箱環境的工作階段。此處列出僅供參考;您無需直接呼叫它們。

停止工作
client.beta.environments.work.stop(workID, params, options?): BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/stop

注意:這些端點會由 SDK 和 CLI 中提供的預先建置環境工作程式自動呼叫,用於協調使用自行託管沙箱環境的工作階段。此處列出僅供參考;您無需直接呼叫它們。

列出工作項目
client.beta.environments.work.list(environmentID, params?, options?): PageCursor<BetaSelfHostedWork>
GET/v1/environments/{environment_id}/work

注意:這些端點會由 SDK 和 CLI 中提供的預先建置環境工作程式自動呼叫,用於協調使用自行託管沙箱環境的工作階段。此處列出僅供參考;您無需直接呼叫它們。

更新工作項目
client.beta.environments.work.update(workID, params, options?): BetaSelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}

注意:這些端點會由 SDK 和 CLI 中提供的預先建置環境工作程式自動呼叫,用於協調使用自行託管沙箱環境的工作階段。此處列出僅供參考;您無需直接呼叫它們。

取得佇列統計資料
client.beta.environments.work.stats(environmentID, params?, options?): BetaSelfHostedWorkQueueStats
GET/v1/environments/{environment_id}/work/stats

取得環境工作佇列的統計資料。