Skip to content

Team & API keys

Everything you create on E2B belongs to a team: its templates, sandboxes, volumes, secrets and API keys, and the bill for them. Your account can belong to several teams, and one of them is your default.

An API key reaches everything in its team. A sandbox has its own access token too, which its envd daemon checks for commands and files in that one sandbox.

Alchemy deploys with the credentials in a profile:

Terminal window
pnpm alchemy profile edit --add E2B

Pick Browser login for most setups: you sign in to E2B in your browser, and Alchemy deploys to your account’s default team. The login refreshes itself.

Pick Access token or API key to paste one instead. An access token acts for you, so give the team id too when you deploy to a team other than your default. An API key already belongs to one team.

A stage decides what you deploy. The profile decides where. Give production its own team, and its own profile:

Terminal window
pnpm alchemy profile create prod
pnpm alchemy profile edit --profile prod --add E2B
pnpm alchemy deploy --stage prod --profile prod

Each stage’s templates get names generated from the app, stage and id, so stages in one team don’t collide.

E2B can’t narrow an API key, so Alchemy gives each host that uses a binding a key of its own, created at deploy and deleted when the host is destroyed. Your access token never reaches the host. The host’s key still reaches the whole team, so put production in a team of its own.

Creating a key takes your access token: an API key can’t create other keys. Declare a key for CI or another app the same way:

src/Keys.ts
import * as E2B from "@alchemy.run/e2b";
export const Ci = E2B.ApiKey("Ci", {});

Ci.key is the key, as a Redacted value. E2B shows a key only once, so Alchemy keeps it in state. Renaming it updates it in place, and destroying it deletes it.

A host can also read the team’s own records: its lifecycle event log and usage metrics.

const team = yield* E2B.ReadTeam();
const events = yield* team.events({ limit: 50 });

Provide E2B.ReadTeamHttp.

When E2B_ACCESS_TOKEN is set, Alchemy uses it instead of the profile. Set E2B_TEAM_ID to deploy to a team other than your default:

Terminal window
E2B_ACCESS_TOKEN=sk_e2b_... E2B_TEAM_ID=... pnpm alchemy deploy --stage prod

E2B_API_KEY is enough to deploy templates, snapshots and other resources, but not bindings or E2B.ApiKey: those create keys, which takes the access token. Set E2B_DOMAIN if you run E2B on your own domain. See CI.

What a sandbox can reach, and how secrets reach it without entering it, is in Network & secrets.