Skip to main content

What You’ll Learn

  • Creating two sandboxes side by side
  • Writing a file in Sandbox A with sbx.files.write()
  • Confirming the file does NOT exist in Sandbox B with sbx.files.exists()
  • Reading file content with sbx.files.read() to verify contents
  • Writing a file in B and verifying A cannot see it (bidirectional isolation)
  • Proper cleanup of multiple sandboxes with try/finally

Prerequisites

This example is available in Python. TypeScript version coming soon.

Code Walkthrough

Create two sandboxes and keep references to both:
Write a secret file in Sandbox A and confirm it exists there:
Verify the same path does not exist in Sandbox B:
Confirm isolation is bidirectional — write in B and check A cannot see it:
Confirm the two sandboxes have different IDs:
Always clean up all sandboxes in finally:

Expected Output