575d5bc288
Summary - When E2B_API_KEY is set via environment variable, the CLI no longer falls back to the teamId from ~/.e2b/config.json, avoiding "Team ID param mismatch with the API key" errors - Adds E2B_TEAM_ID environment variable support - Introduces resolveTeamId() helper with clear precedence: --team CLI flag > E2B_TEAM_ID env var > config file (only when E2B_API_KEY env var is not set) Problem When using E2B_API_KEY env var (e.g. for local development or CI with a different team), the CLI still reads teamId from ~/.e2b/config.json and sends it as a query parameter. If the config file belongs to a different team than the API key, the API rejects the request with 400: Team ID param mismatch with the API key. Changes - api.ts: Export E2B_TEAM_ID env var, add resolveTeamId() helper - list.ts, build.ts, delete.ts, publish.ts: Use resolveTeamId() instead of inline userConfig?.teamId fallback Test plan - Set E2B_API_KEY to a key from team A, have ~/.e2b/config.json with team B's ID → e2b template list should work (no mismatch error) - Set both E2B_API_KEY and E2B_TEAM_ID → CLI uses the env var team ID - Without any env vars, normal e2b auth login flow still works as before - --team flag still takes highest priority <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small, localized change to CLI argument/env/config precedence for team selection; main risk is behavior changes for users relying on implicit `~/.e2b/config.json` teamId when also setting `E2B_API_KEY`. > > **Overview** > Fixes sandbox template commands failing with "Team ID param mismatch" when `E2B_API_KEY` is set via environment by changing team resolution precedence and avoiding `~/.e2b/config.json` team fallback in that case. > > Introduces `E2B_TEAM_ID` and a centralized `resolveTeamId()` helper (CLI flag > env var > local `e2b.toml` > user config *only when no env API key*), and updates template `build`, `list`, `delete`, and `publish` flows to use it consistently. Adds a changeset bump for `@e2b/cli`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 905172fc8e59f8325a8d36af913326f7eb47a15f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
E2B CLI
This CLI tool allows you to build manager your running E2B sandbox and sandbox templates. Learn more in our documentation.
1. Install the CLI
Using Homebrew (on macOS)
brew install e2b
Using NPM
npm install -g @e2b/cli
2. Authenticate
e2b auth login
Note
To authenticate without the ability to open the browser, provide
E2B_ACCESS_TOKENas an environment variable. You can find your token in Account Settings under the Team selector at e2b.dev/dashboard. Then use the CLI like this:E2B_ACCESS_TOKEN=sk_e2b_... e2b template build.
Important
Note the distinction between
E2B_ACCESS_TOKENandE2B_API_KEY.
3. Check out docs
Visit our CLI documentation to learn more.
