Lifecycle States
States
| State | Description | Billable | Can Execute Code |
|---|---|---|---|
| Creating | VM is spinning up | ❌ No | ❌ No |
| Running | VM is active and ready | ✅ Yes | ✅ Yes |
| Stopped | VM is stopped (disk persists) | 💾 Disk only | ❌ No |
| Paused | VM is paused (RAM persists) | 💾 Disk + RAM | ❌ No |
| Deleted | VM is destroyed | ❌ No | ❌ No |
Cost optimization tip: Use
pause() instead of keeping sandboxes running when not in use. Paused sandboxes preserve state but cost less than running sandboxes.Lifecycle Methods
The SDK provides methods to transition between states:- Python
- JavaScript/TypeScript
State Transitions
Creating → Running
When you create a sandbox, it starts in theCreating state and automatically transitions to Running when ready (typically ~100ms).
- Python
- JavaScript/TypeScript
Running ↔ Stopped
Usestop() to halt execution while preserving disk state. Use start() to resume:
- Python
- JavaScript/TypeScript
Running ↔ Paused
Usepause() to preserve both RAM and disk state. Use resume() to restore:
- Python
- JavaScript/TypeScript
Any State → Deleted
Usekill() to permanently delete a sandbox from any state:
- Python
- JavaScript/TypeScript
Best Practices
Use Timeout for Automatic Cleanup
Use Timeout for Automatic Cleanup
- Python
- JavaScript/TypeScript
Pause Instead of Stop for State Preservation
Pause Instead of Stop for State Preservation
If you need to preserve in-memory state, use
pause() instead of stop():- Python
- JavaScript/TypeScript
Check State Before Operations
Check State Before Operations
Always check sandbox state before performing operations:
- Python
- JavaScript/TypeScript

