Skip to main content
This example demonstrates the fundamental operations for working with sandboxes in Daytona.

What You’ll Learn

  • Creating a new sandbox
  • Setting labels and metadata
  • Starting and stopping sandboxes
  • Retrieving sandbox information
  • Listing all sandboxes
  • Deleting sandboxes

Complete Example

Expected Output

Key Concepts

Creating a Sandbox

The simplest way to create a sandbox is calling create() with no parameters. This creates a sandbox with default settings:
  • Language: Python (default)
  • State: Running
  • Auto-archive: Enabled (after inactivity)

Setting Labels

Labels are key-value pairs that help organize and identify sandboxes:

Sandbox States

Sandboxes can be in different states:
  • running - Sandbox is active and ready to use
  • stopped - Sandbox is paused and not consuming compute resources
  • archived - Sandbox is archived to save storage costs

Listing Sandboxes

The list() method returns paginated results:

Best Practices

Always clean up: Delete sandboxes when you’re done to avoid unnecessary costs.
Stopping vs Deleting: Stopping a sandbox preserves its state but you still pay for storage. Deleting removes everything.

Next Steps

File Operations

Learn how to upload and download files

Code Execution

Execute code in your sandboxes