跳转到内容
EN

预留模板构建

POST/e2b/v3/templates● 支持

请求体

  • namestring可选

    Name of the template. Can include a tag with colon separator (e.g. "my-template" or "my-template:v1"). If tag is included, it will be treated as if the tag was provided in the tags array.

  • tagsarray可选

    Tags to assign to the template build

  • aliasstring可选

    Alias of the template. Deprecated, use name instead.

  • teamIDstring可选

    Identifier of the team

  • cpuCountinteger可选

    CPU cores for the sandbox

  • memoryMBinteger可选

    Memory for the sandbox in MiB

  • minFreeDiskMbinteger可选

    Requested minimum free space after the template's build steps, in MiB. Omit to use the team's default. Set to 0 to request no minimum free-disk growth. The filesystem is never shrunk, including inherited or already-larger filesystems. Growth is best effort, so filesystem metadata can leave the available space slightly below the requested minimum.

返回

202

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

请求示例

curl
curl https://api.deepraxis.com/e2b/v3/templates \
  -H "X-API-Key: $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"docs-template","cpuCount":2,"memoryMB":1024,"tags":["docs"]}'
Python
import requests

opts = dict(
    api_key="$PRAXIS_API_KEY",
    api_url="https://api.deepraxis.com/e2b",
    domain="sandbox.praxisusercontent.com",
)

# templateID and buildID come from the preceding create response; replace the example IDs.
resp = requests.request("POST", opts["api_url"] + "/v3/templates",
    headers={"X-API-Key": opts["api_key"]},
    json={"name":"docs-template","cpuCount":2,"memoryMB":1024,"tags":["docs"]},
)
print(resp.status_code, resp.text)
TypeScript
const opts = {
  apiKey: "$PRAXIS_API_KEY",
  apiUrl: "https://api.deepraxis.com/e2b",
  domain: "sandbox.praxisusercontent.com",
};

// templateID and buildID come from the preceding create response; replace the example IDs.
const resp = await fetch(opts.apiUrl + "/v3/templates", { method: "POST",
  headers: { "X-API-Key": opts.apiKey, "Content-Type": "application/json" },
  body: JSON.stringify({"name":"docs-template","cpuCount":2,"memoryMB":1024,"tags":["docs"]}),
});
console.log(resp.status, await resp.text());

响应示例 202

{
  "templateID": "sbe_316095347ee129f46013",
  "buildID": "sbt_e2d426b9-49b3-4082-ace8-ef369dd78c07",
  "public": false,
  "names": [
    "docs-template-2734c250"
  ],
  "aliases": [],
  "tags": [
    "docs"
  ]
}

响应

HTTP 202

The build was requested successfully

application/json

名称 类型 说明
templateID string Identifier of the template
buildID string Identifier of the last successful build for given template
public boolean Whether the template is public or only accessible by the team
names array<string> Names of the template
tags array<string> Tags assigned to the template build
aliases array<string> Aliases of the template