Claude Platform Docs

环境

创建环境
$client->beta->environments->create(string name, ?Config config, ?string description, ?array<string,string> metadata, ?Scope scope, ?list<AnthropicBeta> betas, ?string workspaceID): BetaEnvironment
POST/v1/environments

使用指定配置创建新环境。

列出环境
$client->beta->environments->list(?bool includeArchived, ?int limit, ?string page, ?list<AnthropicBeta> betas, ?string workspaceID): PageCursor<BetaEnvironment>
GET/v1/environments

列出环境,支持分页。

获取环境
$client->beta->environments->retrieve(string environmentID, ?list<AnthropicBeta> betas, ?string workspaceID): BetaEnvironment
GET/v1/environments/{environment_id}

按 ID 检索特定环境。

更新环境
$client->beta->environments->update(string environmentID, ?Config config, ?string description, ?array<string,string> metadata, ?string name, ?Scope scope, ?list<AnthropicBeta> betas, ?string workspaceID): BetaEnvironment
POST/v1/environments/{environment_id}

更新现有环境的配置。

删除环境
$client->beta->environments->delete(string environmentID, ?list<AnthropicBeta> betas, ?string workspaceID): BetaEnvironmentDeleteResponse
DELETE/v1/environments/{environment_id}

按 ID 删除环境。返回删除确认。

归档环境
$client->beta->environments->archive(string environmentID, ?list<AnthropicBeta> betas, ?string workspaceID): BetaEnvironment
POST/v1/environments/{environment_id}/archive

按 ID 归档环境。已归档的环境不能用于创建新会话。

Models
class BetaCloudConfig { $type = 'cloud'; $networking; $packages; }
"cloud" type

Environment type

Networking networking

Network configuration policy.

BetaPackages packages

Package manager configuration.

class BetaCloudConfigParams { $type = 'cloud'; $networking; $packages; }
"cloud" type

Environment type

?Networking networking

Network configuration policy. Omit on update to preserve the existing value.

?BetaPackagesParams packages

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.

class BetaEnvironment { $type = 'environment'; $id; $archivedAt; /* 7 more */ }
"environment" type

The type of object (always 'environment')

string id

Environment identifier (e.g., 'env_...')

?string archivedAt

RFC 3339 timestamp when environment was archived, or null if not archived

Config config

Environment configuration (either Anthropic Cloud or self-hosted)

string createdAt

RFC 3339 timestamp when environment was created

?string description

User-provided description for the environment; null when unset

array<string,string> metadata

User-provided metadata key-value pairs

string name

Human-readable name for the environment

string updatedAt

RFC 3339 timestamp when environment was last updated

?Scope scope

The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

class BetaEnvironmentDeleteResponse { $type; $id; }
Type type

The type of response

string id

Environment identifier

class BetaLimitedNetwork { $type = 'limited'; $allowMCPServers; $allowPackageManagers; $allowedHosts; }
"limited" type

Network policy type

bool allowMCPServers

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

bool allowPackageManagers

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

list<string> allowedHosts

Specifies domains the container can reach.

class BetaLimitedNetworkParams { $type = 'limited'; $allowMCPServers; $allowPackageManagers; $allowedHosts; }
"limited" type

Network policy type

?bool allowMCPServers

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

?bool allowPackageManagers

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.

?list<string> allowedHosts

Specifies domains the container can reach.

class BetaPackages { $type; $apt; $cargo; /* 4 more */ }
?Type type

Package configuration type

list<string> apt

Ubuntu/Debian packages to install

list<string> cargo

Rust packages to install

list<string> gem

Ruby packages to install

list<string> go

Go packages to install

list<string> npm

Node.js packages to install

list<string> pip

Python packages to install

class BetaPackagesParams { $type; $apt; $cargo; /* 4 more */ }
?Type type

Package configuration type

?list<string> apt

Ubuntu/Debian packages to install

?list<string> cargo

Rust packages to install

?list<string> gem

Ruby packages to install

?list<string> go

Go packages to install

?list<string> npm

Node.js packages to install

?list<string> pip

Python packages to install

class BetaSelfHostedConfig { $type = 'self_hosted'; }
"self_hosted" type

Environment type

class BetaSelfHostedConfigParams { $type = 'self_hosted'; }
"self_hosted" type

Environment type

class BetaUnrestrictedNetwork { $type = 'unrestricted'; }
"unrestricted" type

Network policy type

环境工作

获取工作项
$client->beta->environments->work->retrieve(string workID, string environmentID, ?list<AnthropicBeta> betas, ?string workspaceID): SelfHostedWork
GET/v1/environments/{environment_id}/work/{work_id}

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

轮询工作
$client->beta->environments->work->poll(string environmentID, ?int blockMs, ?int reclaimOlderThanMs, ?list<AnthropicBeta> betas, ?string anthropicWorkerID): SelfHostedWork
GET/v1/environments/{environment_id}/work/poll

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

确认工作
$client->beta->environments->work->ack(string workID, string environmentID, ?list<AnthropicBeta> betas): SelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/ack

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

记录心跳
$client->beta->environments->work->heartbeat(string workID, string environmentID, ?int desiredTTLSeconds, ?string expectedLastHeartbeat, ?list<AnthropicBeta> betas): SelfHostedWorkHeartbeatResponse
POST/v1/environments/{environment_id}/work/{work_id}/heartbeat

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

停止工作
$client->beta->environments->work->stop(string workID, string environmentID, ?bool force, ?list<AnthropicBeta> betas, ?string workspaceID): SelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}/stop

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

列出工作项
$client->beta->environments->work->list(string environmentID, ?int limit, ?string page, ?list<AnthropicBeta> betas): PageCursor<SelfHostedWork>
GET/v1/environments/{environment_id}/work

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

更新工作项
$client->beta->environments->work->update(string workID, string environmentID, array<string,string> metadata, ?list<AnthropicBeta> betas, ?string workspaceID): SelfHostedWork
POST/v1/environments/{environment_id}/work/{work_id}

注意:这些端点由 SDK 和 CLI 中提供的预构建环境工作器自动调用,用于编排使用自托管沙箱环境的会话。此处列出仅供参考;您无需直接调用它们。

获取队列统计信息
$client->beta->environments->work->stats(string environmentID, ?list<AnthropicBeta> betas, ?string workspaceID): SelfHostedWorkQueueStats
GET/v1/environments/{environment_id}/work/stats

获取某个环境的工作队列统计信息。