创建沙箱
/sandbox/v1/sandboxes● 支持请求体
templateIDstring必填Identifier of the required template
timeoutinteger可选Lifetime of the new sandbox in seconds. Defaults to 300 seconds when omitted.
autoPauseboolean可选Lifecycle declaration on the E2B-compatible face. true creates a persistent sandbox that pauses at its timeout and can be resumed; false or absent creates an ephemeral sandbox that ends at its timeout and keeps nothing. Keep true only for long-lived computers. The own face declares with ephemeral instead.
metadataany可选Your own string key/value pairs stored with the sandbox; usable as a filter in listSandboxes.
envVarsany可选Environment variables as name to value string pairs.
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可选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必填Auto-resume enabled flag for paused sandboxes. Default false.
networkobject可选Network policy of the sandbox: public access, egress allow and deny lists and proxy.
展开子字段 (9)
allowPublicTrafficboolean可选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 when creating a sandbox.
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.
staticEgressIpboolean可选Own face, persistent sandboxes only (autoPause: true, or ephemeral: false): true gives the sandbox one fixed public egress IP for its whole life, held through pause and resume and released when the sandbox is deleted. Without it the egress IP is not stable: it changes when a spot machine is reclaimed, when a paused machine starts again, and when the machine is rebuilt. An ephemeral sandbox returns INVALID_PARAMS; the E2B face refuses the field; it is placed only on capacity that declares static IPs, and without such capacity the create does not start (it never falls back to a changing IP). Billed as the usage item sandbox:public_ip:hours from allocation to release, paused time included, plus outbound traffic as usual.
egressIpstring可选Own face, read-only: the fixed public egress IP of a sandbox created with staticEgressIp: true, present once the machine has bound it; add this address to the IP allowlist of the service you call (for example a WeCom trusted IP list). Absent on a sandbox that did not ask for a static IP, because its public address can change.
mcpobject可选MCP configuration for the sandbox
更多参数 (14)
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可选Volumes to mount into the sandbox, each with the volume name and the path inside the sandbox.
展开子字段 (2)
namestring必填Name of the volume
pathstring必填Path of the volume
ephemeralboolean可选Own face, required unless sku is named: true for an ephemeral sandbox (ends at its timeout, never pauses, cannot be snapshotted), false for a persistent one (pauses, resumes, snapshots, mounts volumes). Leaving it out returns INVALID_PARAMS.
sizestring可选Own face: the machine size, a SKU id such as base-2c4g or, for an android phone, android-2c4g. Omitted, the template's default size is used.
namestring可选Own face: a display name for the sandbox, 1 to 64 characters. Omitted, one is generated from the template.
waitForReadyboolean可选Own face, android phones only: keep the create open until the phone is running or 55 seconds have passed since the request arrived; running out is not an error and answers the state reached.
onExpirestring可选Own face: what happens at the timeout. pause needs ephemeral: false; must agree with autoPause when both are sent.
idleTimeoutinteger可选Own face, persistent sandboxes only: pause after this many milliseconds without activity; null turns the idle pause off.
idleActivitystring可选Own face, persistent sandboxes only: whose activity resets idleTimeout. traffic (default) counts data-plane calls, preview traffic and live processes; caller counts only your own control-plane calls.
skustring可选Own face: a demand-profile SKU <kind>.<image>.<size>, such as run.document.medium (someone waits; starts fast), job.base.large (background work that must not be cut off), batch.base.large (retried work that may be reclaimed) or computer.base.medium (keeps its disk). It fixes ephemeral, interruptible, size and the template, so those may be left out; any of them you also send must agree with it, otherwise the create fails with INVALID_PARAMS naming the field. The sandbox answers it back as sku and as the read-only label praxis.sku.
kindstring可选Own face: the kind of sandbox you need, when you do not name a full sku. The sandbox completes <kind>.<image>.<size> from the template you start (its family, or custom for your own environment or snapshot) and the size you send, or medium. run is for work someone waits for (starts fast), job is background work that must not be cut off, batch is retried work that may be reclaimed (spot capacity), computer keeps its disk, and compat is the E2B-compatible persistent series. The kind fixes ephemeral and interruptible, so leave those out; if you also send them, or a sku of another kind, the create fails with INVALID_PARAMS naming the field. The light template always starts the light shell, whatever the kind says.
interruptibleboolean可选Own face, ephemeral sandboxes only: true says this sandbox may be reclaimed while it runs (a build or test you retry), which lets it run on cheaper spot capacity. A reclaimed sandbox ends with PROVIDER_FAILED; create it again. Absent or false keeps the usual capacity.
onLossstring可选Own face, persistent sandboxes only: what happens when the provider loses the machine. fail (default) ends the sandbox; rebuild starts a new machine under the same id with its state lost.
outputsarray可选Own face: up to eight absolute paths to keep when the sandbox ends; each is packed as .tar.gz into File and listed on the killed event.
展开子字段 (1)
pathstring必填Absolute path of a directory or file inside the sandbox.
返回
201
与 E2B 一致:不带 templateID 创建时使用默认的 base 模板;要用其他模板,从「列出模板」选取 templateID。每个沙箱创建时必须声明生命周期:Praxis 原生接口(请求头 X-Praxis-Face: own-v1)必须传 ephemeral,true 是一次性(从不暂停,结束即删除,用于跑任务),false 是持久(可暂停、快照、挂卷,用于长期使用的云电脑),缺省返回 INVALID_PARAMS;E2B 兼容接口用 autoPause 声明,true 为持久,false 或缺省为一次性。持久专属字段(autoPause:true、onExpire:pause、autoPauseMemory、autoResume、idleTimeout、retention、存储卷)必须配合 ephemeral:false。只有长期云电脑选持久。机器结束后再访问会返回 SANDBOX_EXPIRED(410),文件已不在,需新建沙箱。要保留结果,在原生接口创建时声明 outputs: [{ path }](最多 8 条绝对路径,目录或文件):沙箱结束时(供应商丢失和启动失败除外),每条打包成 .tar.gz 存进 File,事件接口的 killed 事件列出每条的 fileId 或没保留下来的原因;没声明的路径不保留,E2B 兼容接口拒绝 outputs。响应里的 ephemeral 回显所属类型。
错误按 E2B 格式返回,参见 错误码
请求示例
curl
curl https://api.deepraxis.com/sandbox/v1/sandboxes \
-H "X-API-Key: $PRAXIS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"templateID":"node22","timeout":300,"ephemeral":false}'Python
import requests
api_key = "$PRAXIS_API_KEY"
# Call /sandbox/v1 directly over HTTP.
resp = requests.post(
"https://api.deepraxis.com/sandbox/v1/sandboxes",
headers={"X-API-Key": api_key},
json={"templateID": "node22", "timeout": 300, "ephemeral": False},
)
print(resp.status_code, resp.text)TypeScript
const apiKey = "$PRAXIS_API_KEY";
// Call /sandbox/v1 directly over HTTP.
const resp = await fetch(`https://api.deepraxis.com/sandbox/v1/sandboxes`, {
method: "POST",
headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
body: JSON.stringify({ templateID: "node22", timeout: 300, ephemeral: false }),
});
console.log(resp.status, await resp.text());响应示例 201
{
"templateID": "node22",
"sandboxID": "sbib2586b83c183533da70bced2",
"clientID": "i42g6lkj181tyvouozh1o",
"envdVersion": "0.9.0",
"envdAccessToken": "<access-token>",
"domain": "sandbox.praxisusercontent.com"
}响应
HTTP 201
The sandbox was created successfully
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| templateID | string | Identifier of the template from which is the sandbox created |
| sandboxID | string | Identifier of the sandbox |
| alias | string | Alias of the template |
| clientID | string | Identifier of the client |
| envdVersion | string | Version of the envd running in the sandbox |
| envdAccessToken | string | Access token used for envd communication |
| trafficAccessToken | string | Token required for accessing sandbox via proxy. |
| domain | string | Base domain where the sandbox traffic is accessible |
| machine | string | What kind of machine this sandbox is, so you can decide whether to drive it as a computer without knowing which vendor placed it. full: a complete environment that runs files, commands, terminals and background processes through the data plane — drive it as a computer. light: a light machine without that. none: a single-use box that is reachable but must not be driven as a computer. |