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.
A key reaches its whole team
Section titled “A key reaches its whole team”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.
Sign in with a profile, pick a team
Section titled “Sign in with a profile, pick a team”Alchemy deploys with the credentials in a profile:
pnpm alchemy profile edit --add E2Bbun alchemy profile edit --add E2Bnpx alchemy profile edit --add E2Byarn alchemy profile edit --add E2BPick 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.
Give production its own team
Section titled “Give production its own team”A stage decides what you deploy. The profile decides where. Give production its own team, and its own profile:
pnpm alchemy profile create prodpnpm alchemy profile edit --profile prod --add E2Bpnpm alchemy deploy --stage prod --profile prodbun alchemy profile create prodbun alchemy profile edit --profile prod --add E2Bbun alchemy deploy --stage prod --profile prodnpx alchemy profile create prodnpx alchemy profile edit --profile prod --add E2Bnpx alchemy deploy --stage prod --profile prodyarn alchemy profile create prodyarn alchemy profile edit --profile prod --add E2Byarn alchemy deploy --stage prod --profile prodEach stage’s templates get names generated from the app, stage and id, so stages in one team don’t collide.
Each host gets a key of its own
Section titled “Each host gets a key of its own”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:
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.
Deploy from CI with a token
Section titled “Deploy from CI with a token”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:
E2B_ACCESS_TOKEN=sk_e2b_... E2B_TEAM_ID=... pnpm alchemy deploy --stage prodE2B_ACCESS_TOKEN=sk_e2b_... E2B_TEAM_ID=... bun alchemy deploy --stage prodE2B_ACCESS_TOKEN=sk_e2b_... E2B_TEAM_ID=... npx alchemy deploy --stage prodE2B_ACCESS_TOKEN=sk_e2b_... E2B_TEAM_ID=... yarn alchemy deploy --stage prodE2B_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.