E2B icon

E2B

Run commands and manage E2B sandboxes and snapshots

Sandbox → Create

AI-generated

Summary

Create a new E2B sandbox with customizable options such as template or snapshot, attached metadata, environment variables, internet access permission, and volume mounts, applying a timeout for the operation.

Inputs

  • Template or Snapshot ID — Specify an E2B template name/ID or snapshot ID for the sandbox. Leave empty to use the default template.
  • Metadata — Provide a JSON object with metadata key-value pairs to attach to the sandbox upon creation.
  • Environment Variables — Set environment variables for the sandbox using a JSON object mapping variable names to values.
  • Allow Internet Access — Choose whether the created sandbox is allowed internet access (default is true).
  • Volume Mounts — Provide a JSON object that maps sandbox mount paths to existing E2B volume names, e.g., {"/data":"my-volume"}.
  • Timeout — Set a timeout in seconds for the sandbox creation operation (minimum 1 second, default is 300 seconds).

Output shape

a single record

Returns details about the created sandbox including its ID, domain, and related configuration information.

Examples

Example 1: Create a sandbox with a specific template and metadata

Set Template or Snapshot ID to "custom-template", Metadata to {"project":"demo"}, Allow Internet Access to true.

Example 2: Create a sandbox with volume mounts and limited timeout

Set Volume Mounts to {"/app/cache":"cache-volume"}, Timeout to 120 seconds, Allow Internet Access to false.

Links

Discussion