All Products
Search
Document Center

Function Compute:Pause and Resume

Last Updated:Jul 15, 2026

Pause lets you preserve Sandbox state for a period of time and continue later by reconnecting to the same Sandbox.

Pause a Sandbox

Pause the current Sandbox:

sandbox.pause()

TypeScript example:

await sandbox.pause();

After a Sandbox is paused, it is no longer in an active running state. You can resume using it later by reconnecting to the existing Sandbox.

Auto-resume on Connect

Sandbox.connect(sandboxId) can connect to an existing Sandbox. If the Sandbox is paused, it is automatically resumed when you connect.

import os

from e2b_code_interpreter import Sandbox

sandbox = Sandbox.connect(
    sandbox_id,
    api_key=os.environ["E2B_API_KEY"],
    api_url=os.environ["E2B_API_URL"],
    domain=os.environ["E2B_DOMAIN"],
)

TypeScript example:

const sandbox = await Sandbox.connect(sandboxId, {
  apiKey: process.env.E2B_API_KEY,
  apiUrl: process.env.E2B_API_URL,
  domain: process.env.E2B_DOMAIN,
});

Recommendations

  • Pause a Sandbox when a task needs to preserve context for a short interval between steps.

  • After resuming, recheck long-lived connections, process state, and application state before proceeding.

  • Pause is not the same as kill. When the task is complete, call sandbox.kill() to release resources.