All Products
Search
Document Center

Function Compute:Metadata

Last Updated:Sep 14, 2026

Metadata lets you label Sandboxes in the control plane so your application can track tasks, users, scenarios, and versions. Metadata does not automatically become environment variables inside the Sandbox.

Write Metadata When Creating a Sandbox

TypeScript example:

const sandbox = await Sandbox.create("code-interpreter-v1", {
  apiKey: process.env.E2B_API_KEY,
  apiUrl: process.env.E2B_API_URL,
  domain: process.env.E2B_DOMAIN,
  metadata: {
    task_id: "task-001",
    agent: "code-reviewer",
  },
});

const info = await sandbox.getInfo();
console.log(info.metadata);

Python example:

sandbox = Sandbox.create(
    template="code-interpreter-v1",
    api_key=os.environ["E2B_API_KEY"],
    api_url=os.environ["E2B_API_URL"],
    domain=os.environ["E2B_DOMAIN"],
    metadata={
        "task_id": "task-001",
        "agent": "code-reviewer",
    },
)

info = sandbox.get_info()
print(info.metadata)

Metadata vs. Environment Variables

  • Metadata is used for management-plane queries, audit, and business correlation.

  • Environment variables are read by processes inside the Sandbox.

  • If the same business field must be visible in both the management plane and the process runtime, you can write it to both metadata and envs.

Recommendations

Use short strings for metadata values, and avoid storing large context blocks, user privacy data, or credentials in metadata. Complex business state should live in your application database, and metadata should keep only indexable correlation IDs.