EphemeralBox is a lightweight, short-lived sandbox that provides exec, file, schedule, and snapshot operations. It’s designed for quick, disposable compute tasks where a full Box (with agent, git, public URLs, etc.) is unnecessary.
Creation
Box.create(): Ephemeral boxes are ready immediately — no polling. The API returns with status: "idle" and the box is usable right away.
The request sends { ephemeral: true, ttl?, runtime?, name?, labels?, size?, env_vars?, attach_headers?, network_policy? } to POST /v2/box.
Available API
Properties
id— box identifier (e.g."sweet-shark-26021")expiresAt— Unix timestamp (seconds) when the box auto-deletes
How it differs from Box
- Instant creation — no polling loop; the response is the ready box
- Auto-expiry — boxes are automatically deleted after TTL;
expiresAttracks this - Reduced surface — exec, files, schedules, and snapshots; no agent, git, public URLs, or
pause()/resume(). An idle ephemeral box can still be auto-paused before its TTL (after 1 hour on the free plan, 6 hours on paid plans), and new exec or file calls resume it - Simpler config —
EphemeralBoxConfighasapiKey,baseUrl,name,labels,runtime,size,ttl,env,attachHeaders,networkPolicy,timeout,debug, andenableTelemetry(TypeScript only). There is no agent, git, skills, mcpServers, keepAlive, or initCommand - Composition over inheritance —
EphemeralBoxwraps an internalBoxand exposes only the relevant subset, so agent/git/etc. are not accessible even at runtime
Examples
Run a shell command
Execute inline code
File operations
Clean up early
Otherwise the box auto-deletes atexpiresAt.
Exported types
EphemeralBox— the classEphemeralBoxConfig— config forEphemeralBox.create()EphemeralBoxData— extendsBoxDatawithephemeral: booleanandexpires_at: number