Skip to main content
Forking lets you create running copies of a sandbox in a single call. The sandbox is snapshotted in place — paused, captured with its full filesystem and memory state, and resumed — and new sandboxes boot from that snapshot. Each fork is an independent sandbox with its own ID and timeout. It starts with the exact state the original had at the moment of the fork — files, running processes, loaded variables, and data — and diverges from there. The original sandbox keeps running with its ID and expiration untouched.

Fork flow

The snapshot is captured once regardless of how many forks you request, so forking into many sandboxes costs the same single snapshot of the original.
During the fork, the original sandbox is paused and resumed. The pause duration scales with the amount of disk changes since the last snapshot — write-heavy workloads pause longer. The pause also causes all active connections (e.g. WebSocket, PTY, command streams) to be dropped, so make sure your client handles reconnection properly.

Fork a sandbox

You can fork a running sandbox instance. The method returns a list with one entry per requested fork.
You can also fork by sandbox ID using the static method.

Create multiple forks

Use count to boot several sandboxes from the same snapshot in one call. You can request up to 100 forks at once.

Handle failed forks

Each fork succeeds or fails independently. Instead of throwing on the first failure, the returned list contains a connected sandbox for each fork that started and an error value for each fork that didn’t — so a partial failure doesn’t throw away the successful forks.
If the request fails as a whole (for example, the sandbox does not exist), the method throws instead of returning error values.

Fork timeout

The timeoutMs (JavaScript) / timeout (Python) option sets how long the new forked sandboxes live and defaults to 5 minutes, like Sandbox.create(). It applies to the forks only — the original sandbox’s expiration is not changed.

Forking vs. Snapshots

Forking is a one-call shortcut for the common snapshot pattern: capture a running sandbox and immediately boot new sandboxes from the capture. Use forking when you want running copies right now. Use snapshots when you want a durable checkpoint to create sandboxes from later.