List Sandboxes

Updated at:

Listing Sandboxes lets you view Sandboxes under the current account that are still running or can still be reconnected to. It is useful for operations troubleshooting, resource cleanup, and task recovery.

List sandboxes

import { Sandbox } from "e2b";

const paginator = Sandbox.list({
  apiKey: process.env.E2B_API_KEY,
  apiUrl: process.env.E2B_API_URL,
  domain: process.env.E2B_DOMAIN,
});

while (paginator.hasNext) {
  const sandboxes = await paginator.nextItems();
  for (const sandbox of sandboxes) {
    console.log(sandbox.sandboxId, sandbox.state);
  }
}

Python example:

import os

from e2b import Sandbox

paginator = Sandbox.list(
    api_key=os.environ["E2B_API_KEY"],
    api_url=os.environ["E2B_API_URL"],
    domain=os.environ["E2B_DOMAIN"],
)

while paginator.has_next:
    for sandbox in paginator.next_items():
        print(sandbox.sandbox_id, sandbox.state)

Pagination objects may differ across SDK versions. In application code, prefer the iteration interface provided by the SDK instead of assuming the return value is always an array.

Get Current Sandbox Information

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

Python example:

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

Recommendations

The list API is better suited to management-plane workflows and should not be called repeatedly in high-frequency request paths. Your application should persist its own mapping between task IDs and sandboxId values instead of inferring business state from a full list scan.