The E2B CLI lets you create, connect to, and manage sandboxes directly from your terminal. It’s also used to manage templates.Documentation Index
Fetch the complete documentation index at: https://e2b-squash-sandbox-pages.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Using Homebrew (on macOS)Authentication
There are two ways to authenticate with the E2B CLI:Browser authentication
Run the following command to sign in through your browser:Environment variables
Set your environment variables:Learn more about obtaining and managing your API key and access token on the API Key page.
Create a sandbox
Create a sandbox and connect an interactive terminal to it.base template:
- Create a new sandbox from the specified template
- Connect your terminal to the sandbox
- Keep the sandbox alive while you’re connected
- Automatically kill the sandbox when you exit the terminal
Connect to a sandbox
Connect an interactive terminal to an already running sandbox.create command, connect does not kill the sandbox when you disconnect. When you exit the terminal, only your terminal session is closed — the sandbox continues running.
Execute commands
Execute commands in a running sandbox.Pipe from stdin
Run in background
Use the--background flag to run a command in the background and return immediately. The command will print the process ID (PID) to stderr:
Set working directory
Run as specific user
Set environment variables
Use the--env flag to set environment variables. This flag can be repeated for multiple variables:
List sandboxes
List all sandboxes:--state to filter by state.