Skip to main content
A fork of a running sandbox answers 201. A fork pauses a sandbox, takes a copy-on-write snapshot of its memory and disk, and restores the children on pre-spawned blank VMs. The parent keeps running after the fork; the children see the parent’s memory at the moment of the fork and then diverge.

Fork a sandbox

count is the number of children, default 1. timeout (seconds) and metadata apply to the children. The answer is 201 and a list with one entry per child, each holding the child’s sandbox as a create answer:
Each child is a normal sandbox: use its sandboxID for exec, files and kill. Children count against your concurrent sandbox limit, so a fork that would exceed it answers 429 (see limits).

Forks under heavy load

A fork is admitted behind creates. While the node is busy it answers 503 (capacity, admission_deadline_exceeded) or takes several seconds, and a burst of forks from many sandboxes at once is refused more often than a single one (measured on the test region on 2026-11-13: a storm of forks at 8 times the normal create rate completed fewer than a third of its forks on the first try). Retry a refused fork with a growing wait, as parallel fan-out does, and keep the number of simultaneous forks small.

Best of N

Set a sandbox up once, fork it into N children, try one attempt in each at the same time, keep the best child and kill the rest. Each child is a sandbox of its own: it is billed from the fork that made it until it is killed, so the attempts you discard cost only the seconds they ran. The children of one fork restore from one snapshot of the parent, so N children cost one snapshot, not N.
The example uses the unmodified e2b package for create, exec, connect and kill (see Switch from E2B) and one HTTP call for the fork. For the next round, fork the kept child the same way: a child forks like any sandbox.

What a fork is not

  • It is not a re-run of the parent’s commands: the child starts from the parent’s memory, not from its template.
  • It is not free of the parent: a running parent is paused for the snapshot and resumes when the fork returns. A paused parent can be forked too and stays paused (one parked on disk is woken for the snapshot and paused again in memory). A snapshot of a paused sandbox works the same way.
A snapshot of a sandbox is a separate call; see snapshots.

Operations