Skip to main content
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


Properties

  • id — box identifier (e.g. "sweet-shark-26021")
  • expiresAt — Unix timestamp (seconds) when the box auto-deletes

How it differs from Box

  1. Instant creation — no polling loop; the response is the ready box
  2. Auto-expiry — boxes are automatically deleted after TTL; expiresAt tracks this
  3. 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
  4. Simpler config — EphemeralBoxConfig has apiKey, baseUrl, name, labels, runtime, size, ttl, env, attachHeaders, networkPolicy, timeout, debug, and enableTelemetry (TypeScript only). There is no agent, git, skills, mcpServers, keepAlive, or initCommand
  5. Composition over inheritance — EphemeralBox wraps an internal Box and 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 class
  • EphemeralBoxConfig — config for EphemeralBox.create()
  • EphemeralBoxData — extends BoxData with ephemeral: boolean and expires_at: number