Skip to main content
An E2B sandbox is a persistent, secure cloud environment where your AI agents execute code, run commands, manage files, and access the internet. Every sandbox supports pause and resume — when a sandbox times out, it can automatically pause and preserve its full state (filesystem and memory), then resume exactly where it left off when activity arrives.

Key characteristics

  • Persistent by default — configure onTimeout: 'pause' and sandboxes preserve their full state (filesystem + memory) indefinitely. Resume at any time.
  • Auto-resume — when enabled, paused sandboxes wake automatically when SDK calls or HTTP traffic arrive. No manual state management needed.
  • Snapshots — capture a running sandbox’s state and spawn multiple new sandboxes from it. Useful for checkpointing, forking, and rollback.
  • Configurable timeouts — sandboxes run for up to 24 hours (Pro) or 1 hour (Base) continuously. Pausing resets the runtime window.
  • Isolated and secure — each sandbox runs in its own microVM with network controls, access tokens, and rate limits.

Quick setup: persistent sandbox

import { Sandbox } from 'e2b'

const sandbox = await Sandbox.create({
  timeoutMs: 5 * 60 * 1000,
  lifecycle: {
    onTimeout: 'pause',     // pause instead of kill on timeout
    autoResume: true,        // wake on activity
  },
})

// Use the sandbox — it auto-pauses when idle, auto-resumes when needed
const result = await sandbox.commands.run('echo "Hello from a persistent sandbox"')
console.log(result.stdout)

Core

Lifecycle

Timeouts, sandbox info, metadata, listing, connecting, and shutdown.

Pause, resume & snapshots

Pause/resume, auto-pause, auto-resume, snapshots, and state transitions.

Commands

Interactive terminal (PTY) and SSH access.

Configuration

Environment variables and storage bucket integration.

Security

Secured access, network controls, and rate limits.

Observability

Metrics, lifecycle events API, and webhooks.

Guides

Runtime customization

Install packages, upload files, and configure sandboxes dynamically.

Git integration

Clone repos, manage branches, push changes.

Proxy tunneling

Route sandbox traffic through a proxy server.

Custom domain

Set up a custom domain for sandbox access.