E2B 兼容接口

2026-10-20

E2B 兼容接口

基础地址

加载中…

接入

加载中…

控制面与数据面

  • 控制面:创建、列出、暂停、连接、终止沙箱等本页列出的端点,地址是上面的基础地址,用你的 API Key 认证(X-API-Key 头,官方 SDK 自动带上)。
  • 数据面:在沙箱里运行命令、读写文件,由 SDK 直连 <端口>-<沙箱 ID>.praxisusercontent.com,用创建沙箱时返回的访问凭证认证。所以 SDK 除了 api_url 还要把 domain 设为 praxisusercontent.com。

也可以不改代码,只设环境变量:

加载中…

端点

方法路径说明支持
POST/sandboxes创建沙箱● 支持
GET/sandboxes列出沙箱● 支持
GET/sandboxes/{sandboxID}读取沙箱● 支持
GET/sandboxes/{sandboxID}/metrics沙箱指标● 支持
POST/sandboxes/{sandboxID}/timeout设置超时● 支持
POST/sandboxes/{sandboxID}/pause暂停沙箱● 支持
POST/sandboxes/{sandboxID}/connect连接沙箱● 支持
DELETE/sandboxes/{sandboxID}终止沙箱● 支持
POST/v2/sandboxes创建沙箱(v2)● 支持
GET/v2/sandboxes列出沙箱(v2)● 支持
POST/v2/sandboxes/{sandboxID}/connect连接沙箱(v2)● 支持
GET/templates列出模板● 支持
GET/v2/templates列出模板(v2)● 支持
POST/volumes创建卷● 支持
GET/volumes列出卷● 支持
GET/volumes/{volumeID}读取卷● 支持
DELETE/volumes/{volumeID}删除卷● 支持
POST/sandboxes/{sandboxID}/fork复制沙箱● 支持
POST/sandboxes/{sandboxID}/snapshots创建快照● 支持
GET/snapshots列出快照● 支持
DELETE/templates/{templateID}删除快照● 支持
PUT/sandboxes/{sandboxID}/network更新网络策略● 支持
GET/v2/sandboxes/{sandboxID}/logs读取沙箱日志● 支持

与官方的差异

  • 创建沙箱:已弃用:最新官方 SDK 走 v2。平台暂未提供 E2B 默认的 base 模板:不带模板参数的 Sandbox.create() 会返回 404,请显式指定模板(可用模板见「列出模板」)。
  • 列出沙箱:已弃用:最新官方 SDK 走 v2。
  • 连接沙箱:已弃用:最新官方 SDK 走 v2。
  • 列出模板:已弃用:最新官方 SDK 走 v2。

参数与字段的权威定义以 E2B 官方文档为准。

错误按 E2B 格式返回,参见错误;额度与响应头参见限流。

创建沙箱

POST /e2b/sandboxes● 支持

E2B 官方文档 ↗

请求体

  • templateIDstring必填

    Template ID or alias from templates.list; resolves to your ready Environment first, then a public Base. Supply it explicitly.

  • timeoutinteger可选
    默认 15

    Time to live for the sandbox in seconds.

  • autoPauseboolean可选
    默认 false

    Automatically pauses the sandbox after the timeout

  • metadataany可选
  • envVarsany可选
  • secureboolean可选

    Secure all system communication with sandbox

  • allow_internet_accessboolean可选

    Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config.

  • autoPauseMemoryboolean可选
    默认 true

    Controls the snapshot kind taken when the sandbox auto-pauses on timeout (only relevant when autoPause is true). When false, the auto-pause drops the in-memory state and persists only the filesystem (a filesystem-only snapshot); resuming it cold-boots (reboots) the sandbox from disk. Such a snapshot cannot be auto-resumed by traffic and must be resumed explicitly, so it cannot be combined with autoResume. Defaults to true (full memory snapshot).

  • autoResumeobject可选

    Auto-resume configuration for paused sandboxes.

    ▸ 展开子字段(1)
    • enabledboolean必填
      默认 false

      Auto-resume enabled flag for paused sandboxes. Default false.

  • networkobject可选
    ▸ 展开子字段(7)
    • allowPublicTrafficboolean可选
      默认 true

      Specify if the sandbox URLs should be accessible only with authentication.

    • allowOutarray可选

      List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.

    • denyOutarray可选

      List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.

    • egressProxyobject可选

      SOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).

    • maskRequestHoststring可选

      Specify host mask which will be used for all sandbox requests

    • httpsPortsarray可选

      Unlike E2B, network.httpsPorts is rejected; omit it and serve plaintext HTTP inside the sandbox. The public port URL still uses HTTPS. The upstream field denotes HTTPS-speaking internal ports, permits self-signed certificates and excludes envd port 49983.

    • rulesobject可选

      Per-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, "*.example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "*" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.

  • ▸ 更多参数(3)
    • mcpobject可选

      MCP configuration for the sandbox

    • iamobject可选

      Sandbox workload identity configuration. A non-empty, valid tokens map enables workload identity for the sandbox.

      ▸ 展开子字段(1)
      • tokensobject可选

        Named workload-token definitions, keyed by a caller-chosen token name.

    • volumeMountsarray可选
      ▸ 展开子字段(2)
      • namestring必填

        Name of the volume

      • pathstring必填

        Path of the volume

返回

201

已弃用:最新官方 SDK 走 v2。平台暂未提供 E2B 默认的 base 模板:不带模板参数的 Sandbox.create() 会返回 404,请显式指定模板(可用模板见「列出模板」)。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was created successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.

列出沙箱

GET /e2b/sandboxes● 支持

E2B 官方文档 ↗

请求参数

  • metadatastring可选

    query: Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded.

返回

200

已弃用:最新官方 SDK 走 v2。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all running sandboxes

application/json

名称类型说明
[].templateIDstringIdentifier of the template from which is the sandbox created
[].aliasstringAlias of the template
[].sandboxIDstringIdentifier of the sandbox
[].clientIDstringIdentifier of the client
[].startedAtstringTime when the sandbox was started
[].endAtstringTime when the sandbox will expire
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].metadataany
[].statestringState of the sandbox
[].envdVersionstringVersion of the envd running in the sandbox
[].volumeMountsarray<object>
[].volumeMounts[].namestringName of the volume
[].volumeMounts[].pathstringPath of the volume

读取沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /e2b/sandboxes/{sandboxID}● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
aliasstringAlias of the template
sandboxIDstringIdentifier of the sandbox
clientIDstringIdentifier of the client
startedAtstringTime when the sandbox was started
endAtstringTime when the sandbox will expire
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
allowInternetAccessbooleanWhether internet access was explicitly enabled or disabled for the sandbox. Null means it was not explicitly set.
domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.
cpuCountintegerCPU cores for the sandbox
memoryMBintegerMemory for the sandbox in MiB
diskSizeMBintegerDisk size for the sandbox in MiB
metadataany
statestringState of the sandbox
networkobject
network.allowPublicTrafficbooleanSpecify if the sandbox URLs should be accessible only with authentication.
network.allowOutarray<string>List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.
network.denyOutarray<string>List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.
network.egressProxyobjectSOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).
network.maskRequestHoststringSpecify host mask which will be used for all sandbox requests
network.httpsPortsarray<integer>Unlike E2B, network.httpsPorts is rejected; omit it and serve plaintext HTTP inside the sandbox. The public port URL still uses HTTPS. The upstream field denotes HTTPS-speaking internal ports, permits self-signed certificates and excludes envd port 49983.
network.rulesobjectPer-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, ".example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.
lifecycleobjectSandbox lifecycle policy returned by sandbox info.
lifecycle.autoResumebooleanWhether the sandbox can auto-resume.
lifecycle.onTimeoutstringAction taken when the sandbox times out.
volumeMountsarray<object>
volumeMounts[].namestringName of the volume
volumeMounts[].pathstringPath of the volume

沙箱指标

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /e2b/sandboxes/{sandboxID}/metrics● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • startinteger可选

    query: Unix timestamp for the start of the interval, in seconds, for which the metrics

  • endinteger可选

    query: Unix timestamp for the end of the interval, in seconds, for which the metrics

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox metrics

application/json

名称类型说明
[].timestampstringTimestamp of the metric entry
[].timestampUnixintegerTimestamp of the metric entry in Unix time (seconds since epoch)
[].cpuCountintegerNumber of CPU cores
[].cpuUsedPctnumberCPU usage percentage
[].memUsedintegerMemory used in bytes
[].memTotalintegerTotal memory in bytes
[].memCacheintegerCached memory (page cache) in bytes
[].diskUsedintegerDisk used in bytes
[].diskTotalintegerTotal disk space in bytes

设置超时

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/timeout● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger必填

    Timeout in seconds from the current time after which the sandbox should expire

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully set the sandbox timeout

未声明响应体。

暂停沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/pause● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • memoryboolean可选
    默认 true

    Whether to capture a full memory snapshot. When false, only the filesystem is persisted and resuming the sandbox cold-boots (reboots) it from disk, losing in-memory state, running processes, and open connections. Resume it with an explicit request (connect or resume); auto-resume, which can be triggered by arbitrary traffic, refuses such a sandbox. Defaults to true.

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The sandbox was paused successfully and can be resumed

未声明响应体。

连接沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/connect● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger必填

    Timeout in seconds from the current time after which the sandbox should expire

  • memoryboolean可选

    Defaults to true. When false and the sandbox is paused, resume from disk state only: the sandbox cold-boots fresh and any memory in the snapshot is ignored, never modified or deleted. Disk state has crash-recovery semantics — writes not flushed before the pause may be lost. A no-op for snapshots that contain no memory. Rejected with an error in environments where this capability is not enabled, never silently downgraded to a memory restore.

返回

201

已弃用:最新官方 SDK 走 v2。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

The sandbox was already running

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.

HTTP 201

The sandbox was resumed successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.

终止沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

DELETE /e2b/sandboxes/{sandboxID}● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The sandbox was killed successfully

未声明响应体。

创建沙箱(v2)

POST /e2b/v2/sandboxes● 支持

E2B 官方文档 ↗

请求体

  • templateIDstring必填

    Template ID or alias from templates.list; resolves to your ready Environment first, then a public Base. Supply it explicitly.

  • timeoutinteger可选
    默认 300

    Time to live for the sandbox in seconds.

  • autoPauseboolean可选
    默认 false

    Automatically pauses the sandbox after the timeout

  • metadataany可选
  • envVarsany可选
  • allow_internet_accessboolean可选

    Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config.

  • autoPauseMemoryboolean可选
    默认 true

    Controls the snapshot kind taken when the sandbox auto-pauses on timeout (only relevant when autoPause is true). When false, the auto-pause drops the in-memory state and persists only the filesystem (a filesystem-only snapshot); resuming it cold-boots (reboots) the sandbox from disk. Such a snapshot cannot be auto-resumed by traffic and must be resumed explicitly, so it cannot be combined with autoResume. Defaults to true (full memory snapshot).

  • autoResumeobject可选

    Auto-resume configuration for paused sandboxes.

    ▸ 展开子字段(1)
    • enabledboolean必填
      默认 false

      Auto-resume enabled flag for paused sandboxes. Default false.

  • networkobject可选
    ▸ 展开子字段(7)
    • allowPublicTrafficboolean可选
      默认 true

      Specify if the sandbox URLs should be accessible only with authentication.

    • allowOutarray可选

      List of allowed destinations for egress traffic. Each entry can be a CIDR block (e.g. "8.8.8.8/32"), a bare IP address (e.g. "8.8.8.8"), or a domain name (e.g. "example.com", "*.example.com"). Allowed entries always take precedence over denied entries.

    • denyOutarray可选

      List of denied CIDR blocks or IP addresses for egress traffic. Domain names are not supported for deny rules.

    • egressProxyobject可选

      SOCKS5 proxy for sandbox egress. Outbound TCP is tunneled through the proxy after allow/deny filtering; the sandbox is unaware. Domain-matched flows use remote DNS (ATYP=domain).

    • maskRequestHoststring可选

      Specify host mask which will be used for all sandbox requests

    • httpsPortsarray可选

      Unlike E2B, network.httpsPorts is rejected; omit it and serve plaintext HTTP inside the sandbox. The public port URL still uses HTTPS. The upstream field denotes HTTPS-speaking internal ports, permits self-signed certificates and excludes envd port 49983.

    • rulesobject可选

      Per-domain transform rules applied to matching outbound HTTPS requests. Keys may be exact DNS names (for example, "api.example.com") or a leading wildcard (for example, "*.example.com"), and are normalized to lowercase on write. Wildcards match subdomains at any depth but not the apex domain; a bare "*" is invalid. Exact rules take precedence, followed by the longest matching wildcard suffix, and matching rule sets are not merged. Broad wildcards such as "*.com" are allowed and may expose transformed credentials to every matching destination the sandbox contacts. Rules do not grant network access; configure allowOut separately to permit the destination.

  • mcpobject可选

    MCP configuration for the sandbox

  • ▸ 更多参数(2)
    • iamobject可选

      Sandbox workload identity configuration. A non-empty, valid tokens map enables workload identity for the sandbox.

      ▸ 展开子字段(1)
      • tokensobject可选

        Named workload-token definitions, keyed by a caller-chosen token name.

    • volumeMountsarray可选
      ▸ 展开子字段(2)
      • namestring必填

        Name of the volume

      • pathstring必填

        Path of the volume

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was created successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.

列出沙箱(v2)

GET /e2b/v2/sandboxes● 支持

E2B 官方文档 ↗

请求参数

  • metadatastring可选

    query: Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded.

  • statearray可选

    query: Filter sandboxes by one or more states

  • orderstring可选
    默认 "desc"

    query: Sort direction by sandbox start time. Defaults to desc (newest first).

    取值 ascdesc
  • startedAfterstring可选

    query: Return sandboxes started at or after this timestamp.

  • templatestring可选

    query: Filter sandboxes by a template ID or alias.

  • nextTokenstring可选

    query: Cursor to start the list from

  • limitinteger可选
    默认 100

    query: Maximum number of items to return per page

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all running sandboxes

application/json

名称类型说明
[].templateIDstringIdentifier of the template from which is the sandbox created
[].aliasstringAlias of the template
[].sandboxIDstringIdentifier of the sandbox
[].clientIDstringIdentifier of the client
[].startedAtstringTime when the sandbox was started
[].endAtstringTime when the sandbox will expire
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].metadataany
[].statestringState of the sandbox
[].envdVersionstringVersion of the envd running in the sandbox
[].volumeMountsarray<object>
[].volumeMounts[].namestringName of the volume
[].volumeMounts[].pathstringPath of the volume

连接沙箱(v2)

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/v2/sandboxes/{sandboxID}/connect● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger可选
    默认 300

    Timeout in seconds from the current time after which the sandbox should expire

  • memoryboolean可选

    Defaults to true. When false and the sandbox is paused, resume from disk state only: the sandbox cold-boots fresh and any memory in the snapshot is ignored, never modified or deleted. Disk state has crash-recovery semantics — writes not flushed before the pause may be lost. A no-op for snapshots that contain no memory. Rejected with an error in environments where this capability is not enabled, never silently downgraded to a memory restore.

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

The sandbox was already running

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.

HTTP 201

The sandbox was resumed successfully

application/json

名称类型说明
templateIDstringIdentifier of the template from which is the sandbox created
sandboxIDstringIdentifier of the sandbox
aliasstringAlias of the template
clientIDstringIdentifier of the client
envdVersionstringVersion of the envd running in the sandbox
envdAccessTokenstringAccess token used for envd communication
trafficAccessTokenstringToken required for accessing sandbox via proxy.
domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.

列出模板

GET /e2b/templates● 支持

E2B 官方文档 ↗

请求参数

  • teamIDstring可选

    query: Identifier of the team

返回

200

已弃用:最新官方 SDK 走 v2。

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all templates

application/json

名称类型说明
[].templateIDstringIdentifier of the template
[].buildIDstringIdentifier of the last successful build for given template
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].publicbooleanWhether the template is public or only accessible by the team
[].aliasesarray<string>Aliases of the template
[].namesarray<string>Names of the template (namespace/alias format when namespaced)
[].createdAtstringTime when the template was created
[].updatedAtstringTime when the template was last updated
[].createdByobject
[].createdBy.idstringIdentifier of the user
[].createdBy.emailstringEmail of the user
[].lastSpawnedAtstringTime when the template was last used
[].spawnCountintegerNumber of times the template was used
[].buildCountintegerNumber of times the template was built
[].envdVersionstringVersion of the envd running in the sandbox
[].buildStatusstringStatus of the template build

列出模板(v2)

GET /e2b/v2/templates● 支持

E2B 官方文档 ↗

请求参数

  • teamIDstring可选

    query: Identifier of the team

  • nextTokenstring可选

    query: Cursor to start the list from

  • limitinteger可选
    默认 100

    query: Maximum number of items to return per page

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned all templates

application/json

名称类型说明
[].templateIDstringIdentifier of the template
[].buildIDstringIdentifier of the last successful build for given template
[].cpuCountintegerCPU cores for the sandbox
[].memoryMBintegerMemory for the sandbox in MiB
[].diskSizeMBintegerDisk size for the sandbox in MiB
[].publicbooleanWhether the template is public or only accessible by the team
[].aliasesarray<string>Aliases of the template
[].namesarray<string>Names of the template (namespace/alias format when namespaced)
[].createdAtstringTime when the template was created
[].updatedAtstringTime when the template was last updated
[].createdByobject
[].createdBy.idstringIdentifier of the user
[].createdBy.emailstringEmail of the user
[].lastSpawnedAtstringTime when the template was last used
[].spawnCountintegerNumber of times the template was used
[].buildCountintegerNumber of times the template was built
[].envdVersionstringVersion of the envd running in the sandbox
[].buildStatusstringStatus of the template build

创建卷

POST /e2b/volumes● 支持

E2B 官方文档 ↗

请求体

  • namestring必填

    Name of the volume

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

Successfully created a new team volume

application/json

名称类型说明
volumeIDstringID of the volume
namestringName of the volume
tokenstringAuth token to use for interacting with volume content
domainstringDomain to use as the destination for volume content requests, replacing the default `api.<E2B_DOMAIN>`. Only returned when the team is connected to a custom (BYOC) cluster; absent otherwise, in which case the default domain is used.

列出卷

GET /e2b/volumes● 支持

E2B 官方文档 ↗

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully listed all team volumes

application/json

名称类型说明
[].volumeIDstringID of the volume
[].namestringName of the volume

读取卷

GET /e2b/volumes/{volumeID}● 支持

E2B 官方文档 ↗

请求参数

  • volumeIDstring必填

    path:

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully retrieved a team volume

application/json

名称类型说明
volumeIDstringID of the volume
namestringName of the volume
tokenstringAuth token to use for interacting with volume content
domainstringDomain to use as the destination for volume content requests, replacing the default `api.<E2B_DOMAIN>`. Only returned when the team is connected to a custom (BYOC) cluster; absent otherwise, in which case the default domain is used.

删除卷

DELETE /e2b/volumes/{volumeID}● 支持

E2B 官方文档 ↗

请求参数

  • volumeIDstring必填

    path:

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully deleted a team volume

未声明响应体。

复制沙箱

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/fork● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • timeoutinteger可选
    默认 15

    新副本的存活时间,单位为秒。

  • countinteger可选
    默认 1

    要创建的独立副本数。所有副本来自同一次快照,每个副本分别返回成功结果或错误。

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

The sandbox was snapshotted and the forks were attempted; each entry reports one fork's outcome

application/json

名称类型说明
[].sandboxobject
[].sandbox.templateIDstringIdentifier of the template from which is the sandbox created
[].sandbox.sandboxIDstringIdentifier of the sandbox
[].sandbox.aliasstringAlias of the template
[].sandbox.clientIDstringIdentifier of the client
[].sandbox.envdVersionstringVersion of the envd running in the sandbox
[].sandbox.envdAccessTokenstringAccess token used for envd communication
[].sandbox.trafficAccessTokenstringToken required for accessing sandbox via proxy.
[].sandbox.domainstringDomain returned for sandbox traffic. Build an HTTP service URL as https://<port>-<sandboxID>.<domain> using the returned values, without replacing or stripping the sandboxID suffix.
[].errorobject
[].error.codeintegerError code
[].error.error_codestringMachine-readable semantic error code. Not a closed set; initial values: sandbox_capacity_unavailable, sandbox_placement_timeout, sandbox_no_compatible_node, sandbox_create_failed, internal_server_error.
[].error.messagestringError

创建快照

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

POST /e2b/sandboxes/{sandboxID}/snapshots● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • namestring可选

    可选别名。同一主体重复使用该别名会更新既有快照,保留本平台快照 ID。

返回

201

错误按 E2B 格式返回,参见 错误码

响应

HTTP 201

Snapshot created successfully

application/json

名称类型说明
snapshotIDstringIdentifier of the snapshot template including the tag. Uses namespace/alias when a name was provided (e.g. team-slug/my-snapshot:default), otherwise falls back to the raw template ID (e.g. abc123:default).
namesarray<string>Full names of the snapshot template including team namespace and tag (e.g. team-slug/my-snapshot:v2)

列出快照

GET /e2b/snapshots● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring可选

    query: 按来源沙箱 ID 筛选。

  • namestring可选

    query: 按原始别名或本平台 snap_ 快照 ID 筛选。

  • limitinteger可选
    默认 100

    query: 每页返回的快照数量上限。

  • nextTokenstring可选

    query: 上一页响应头 X-Next-Token 返回的游标。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned snapshots

application/json

名称类型说明
[].snapshotIDstringIdentifier of the snapshot template including the tag. Uses namespace/alias when a name was provided (e.g. team-slug/my-snapshot:default), otherwise falls back to the raw template ID (e.g. abc123:default).
[].namesarray<string>Full names of the snapshot template including team namespace and tag (e.g. team-slug/my-snapshot:v2)

删除快照

DELETE /e2b/templates/{templateID}● 支持

E2B 官方文档 ↗

请求参数

  • templateIDstring必填

    path: 本平台返回的 snap_ 快照 ID,不接受供应商句柄。

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

The template was deleted successfully

未声明响应体。

更新网络策略

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

PUT /e2b/sandboxes/{sandboxID}/network● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • allow_internet_accessboolean可选

    是否允许访问外网。false 等效于 denyOut 包含 0.0.0.0/0。

  • allowOutarray可选

    出站目标白名单,可用 CIDR、IP 或域名;白名单优先于拒绝规则。

  • denyOutarray可选

    出站目标黑名单,支持 CIDR 或 IP,不支持域名。

  • egressProxyobject可选

    上游代理配置字段,当前平台尚未应用。

    ▸ 展开子字段(3)
    • addressstring必填

      SOCKS5 proxy address in host:port format (e.g. "proxy.example.com:1080").

    • usernamestring可选

      Optional SOCKS5 username (RFC 1929), max 255 bytes.

    • passwordstring可选

      Optional SOCKS5 password (RFC 1929), max 255 bytes.

  • rulesobject可选

    上游按域名转换规则字段,当前平台尚未应用。

返回

204

错误按 E2B 格式返回,参见 错误码

响应

HTTP 204

Successfully updated the sandbox network configuration

未声明响应体。

读取沙箱日志

先调用「创建沙箱」,用返回的 sandboxID 替换 sbx_123。

GET /e2b/v2/sandboxes/{sandboxID}/logs● 支持

E2B 官方文档 ↗

请求参数

  • sandboxIDstring必填

    path:

  • cursorinteger可选

    query: 起始时间戳,单位为 Unix 毫秒。

  • limitinteger可选
    默认 1000

    query: 最多返回的日志条数。

  • directionstring可选

    query: forward 按时间向后读取;backward 按时间向前读取。

    取值 forwardbackward
  • levelstring可选

    query: 最低日志级别,低于该级别的日志会被过滤。

    取值 debuginfowarnerror
  • searchstring可选

    query: 按日志正文的子串筛选,区分大小写。

返回

200

错误按 E2B 格式返回,参见 错误码

响应

HTTP 200

Successfully returned the sandbox logs

application/json

名称类型说明
logsarray<object>Sandbox logs structured
logs[].timestampstringTimestamp of the log entry
logs[].messagestringLog message content
logs[].levelstringState of the sandbox
logs[].fieldsobject