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#
Key difference from 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#
| Feature | Box | EphemeralBox |
|---|---|---|
exec.command() | Yes | Yes |
exec.code() | Yes | Yes |
exec.stream() | Yes | Yes |
exec.streamCode() | Yes | Yes |
exec.session() | Yes | Yes |
files.read/write/list/upload/download | Yes | Yes |
files.stat/mkdir/rename/remove | Yes | Yes |
schedule.exec/list/get/update/pause/resume/delete | Yes | Yes |
schedule.agent() | Yes | No (no agent) |
cd() / cwd | Yes | Yes |
getStatus() | Yes | Yes |
delete() | Yes | Yes |
networkPolicy (read) | Yes | Yes |
updateNetworkPolicy() | Yes | No |
expiresAt | No | Yes |
agent.run() / agent.stream() | Yes | No |
git.* | Yes | No |
getPublicURL() / listPublicURLs() / deletePublicURL() | Yes | No |
snapshot() / listSnapshots() / deleteSnapshot() / fromSnapshot() | Yes | Yes |
pause() / resume() | Yes | No |
configureModel() | Yes | No |
logs() / listRuns() | Yes | No |
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 at expiresAt.
Exported types#
EphemeralBox— the classEphemeralBoxConfig— config forEphemeralBox.create()EphemeralBoxData— extendsBoxDatawithephemeral: booleanandexpires_at: number