Getting Started
This section introduces core concepts, common workflows, and next steps for using Daytona.
Dashboard
Section titled “Dashboard”Daytona Dashboard ↗ is a visual user interface where you can manage sandboxes, access API keys, view usage, and more. It serves as the primary point of control for managing your Daytona resources.
Daytona provides Python, TypeScript, Ruby, Go, and Java SDKs to programmatically interact with sandboxes. They support sandbox lifecycle management, code execution, resource access, and more.
Daytona provides command-line access to core features for interacting with Daytona Sandboxes, including managing their lifecycle, snapshots, and more.
To interact with Daytona Sandboxes from the command line, install the Daytona CLI:
brew install daytonaio/cli/daytonapowershell -Command "irm https://get.daytona.io/windows | iex"After installing the Daytona CLI, use the daytona command to interact with Daytona Sandboxes from the command line.
To upgrade the Daytona CLI to the latest version:
brew upgrade daytonaio/cli/daytonapowershell -Command "irm https://get.daytona.io/windows | iex"To view all available commands and flags, see the CLI reference.
Daytona provides a RESTful API for interacting with Daytona Sandboxes, including managing their lifecycle, snapshots, and more. It serves as a flexible and powerful way to interact with Daytona from your own applications.
To interact with Daytona Sandboxes from the API, see the API reference.
MCP server
Section titled “MCP server”Daytona provides a Model Context Protocol (MCP) server that enables AI agents to interact with Daytona Sandboxes programmatically. The MCP server integrates with popular AI agents including Claude, Cursor, and Windsurf.
To set up the MCP server with your AI agent:
daytona mcp init [claude/cursor/windsurf]For more information, see the MCP server documentation.
Multiple runtime support
Section titled “Multiple runtime support”Daytona supports multiple programming language runtimes for direct code execution inside the sandbox.
TypeScript SDK works across multiple JavaScript runtimes including Node.js, browsers, and serverless platforms: Cloudflare Workers, AWS Lambda, Azure Functions, etc.
Using the Daytona SDK in browser-based environments or frameworks like Vite and Next.js requires configuring node polyfills.
Daytona in Vite projects
Section titled “Daytona in Vite projects”When using Daytona SDK in a Vite-based project, configure node polyfills to ensure compatibility.
Add the following configuration to your vite.config.ts file in the plugins array:
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineConfig({ plugins: [ // ... other plugins nodePolyfills({ globals: { global: true, process: true, Buffer: true }, overrides: { path: 'path-browserify-win32', }, }), ], // ... rest of your config})Daytona in Next.js projects
Section titled “Daytona in Next.js projects”When using Daytona SDK in a Next.js project, configure node polyfills to ensure compatibility with Webpack and Turbopack bundlers.
Add the following configuration to your next.config.ts file:
import type { NextConfig } from 'next'import NodePolyfillPlugin from 'node-polyfill-webpack-plugin'import { env, nodeless } from 'unenv'
const { alias: turbopackAlias } = env(nodeless, {})
const nextConfig: NextConfig = { // Turbopack experimental: { turbo: { resolveAlias: { ...turbopackAlias, }, }, }, // Webpack webpack: (config, { isServer }) => { if (!isServer) { config.plugins.push(new NodePolyfillPlugin()) } return config },}
export default nextConfigGuides
Section titled “Guides”Daytona provides a comprehensive set of guides to help you get started. The guides cover a wide range of topics, from basic usage to advanced topics, and showcase various types of integrations between Daytona and other tools.
Examples
Section titled “Examples”Daytona provides quick examples for common sandbox operations and best practices.
The examples are based on the Daytona Python, TypeScript, Go, Ruby, Java SDKs, CLI, and API references. More examples are available in our GitHub repository.
Create a sandbox
Section titled “Create a sandbox”Create a sandbox with default settings.
from daytona import Daytona
daytona = Daytona()sandbox = daytona.create()print(f"Sandbox ID: {sandbox.id}")import { Daytona } from '@daytona/sdk';
const daytona = new Daytona();const sandbox = await daytona.create();console.log(`Sandbox ID: ${sandbox.id}`);package main
import ( "context" "fmt" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
sandbox, err := client.Create(context.Background(), nil) if err != nil { log.Fatal(err) } fmt.Printf("Sandbox ID: %s\n", sandbox.ID)}require 'daytona'
daytona = Daytona::Daytona.newsandbox = daytona.createputs "Sandbox ID: #{sandbox.id}"import io.daytona.sdk.Daytona;import io.daytona.sdk.Sandbox;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Sandbox sandbox = daytona.create(); System.out.println("Sandbox ID: " + sandbox.getId()); } }}daytona createcurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{}'Create and run code in a sandbox
Section titled “Create and run code in a sandbox”Create a sandbox and run code securely in it.
from daytona import Daytona
daytona = Daytona()sandbox = daytona.create()response = sandbox.process.exec("echo 'Hello, World!'")print(response.result)sandbox.delete()import { Daytona } from '@daytona/sdk';
const daytona = new Daytona();const sandbox = await daytona.create();const response = await sandbox.process.executeCommand('echo "Hello, World!"');console.log(response.result);await sandbox.delete();package main
import ( "context" "fmt" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
sandbox, err := client.Create(context.Background(), nil) if err != nil { log.Fatal(err) }
response, err := sandbox.Process.ExecuteCommand(context.Background(), "echo 'Hello, World!'") if err != nil { log.Fatal(err) } fmt.Println(response.Result) sandbox.Delete(context.Background())}require 'daytona'
daytona = Daytona::Daytona.newsandbox = daytona.createresponse = sandbox.process.exec(command: "echo 'Hello, World!'")puts response.resultdaytona.delete(sandbox)import io.daytona.sdk.Daytona;import io.daytona.sdk.Sandbox;import io.daytona.sdk.model.ExecuteResponse;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Sandbox sandbox = daytona.create(); ExecuteResponse response = sandbox.process.executeCommand("echo 'Hello, World!'"); System.out.println(response.getResult()); sandbox.delete(); } }}daytona create --name my-sandboxdaytona exec my-sandbox -- echo 'Hello, World!'daytona delete my-sandbox# Create a sandboxcurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{}'
# Execute a command in the sandboxcurl 'https://proxy.app.daytona.io/toolbox/{sandboxId}/process/execute' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "command": "echo '\''Hello, World!'\''"}'
# Delete the sandboxcurl 'https://app.daytona.io/api/sandbox/{sandboxId}' \ --request DELETE \ --header 'Authorization: Bearer <API_KEY>'Create a sandbox with custom resources
Section titled “Create a sandbox with custom resources”Create a sandbox with custom resources (CPU, memory, disk).
from daytona import Daytona, CreateSandboxFromImageParams, Image, Resources
daytona = Daytona()sandbox = daytona.create( CreateSandboxFromImageParams( image=Image.debian_slim("3.12"), resources=Resources(cpu=2, memory=4, disk=8) ))import { Daytona, Image } from '@daytona/sdk';
const daytona = new Daytona();const sandbox = await daytona.create({ image: Image.debianSlim('3.12'), resources: { cpu: 2, memory: 4, disk: 8 }});package main
import ( "context" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona" "github.com/daytonaio/daytona/libs/sdk-go/pkg/types")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
sandbox, err := client.Create(context.Background(), types.ImageParams{ Image: daytona.DebianSlim(nil), Resources: &types.Resources{ CPU: 2, Memory: 4, Disk: 8, }, }) if err != nil { log.Fatal(err) }}require 'daytona'
daytona = Daytona::Daytona.newsandbox = daytona.create( Daytona::CreateSandboxFromImageParams.new( image: Daytona::Image.debian_slim('3.12'), resources: Daytona::Resources.new(cpu: 2, memory: 4, disk: 8) ))import io.daytona.sdk.Daytona;import io.daytona.sdk.Image;import io.daytona.sdk.Sandbox;import io.daytona.sdk.model.CreateSandboxFromImageParams;import io.daytona.sdk.model.Resources;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { CreateSandboxFromImageParams params = new CreateSandboxFromImageParams(); params.setImage(Image.debianSlim("3.12")); Resources resources = new Resources(); resources.setCpu(2); resources.setMemory(4); resources.setDisk(8); params.setResources(resources); Sandbox sandbox = daytona.create(params); } }}daytona create --class smallcurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "cpu": 2, "memory": 4, "disk": 8}'Create an ephemeral sandbox
Section titled “Create an ephemeral sandbox”Create an ephemeral sandbox that is automatically deleted when stopped.
from daytona import Daytona, CreateSandboxFromSnapshotParams
daytona = Daytona()sandbox = daytona.create( CreateSandboxFromSnapshotParams(ephemeral=True, auto_stop_interval=5))import { Daytona } from '@daytona/sdk';
const daytona = new Daytona();const sandbox = await daytona.create({ ephemeral: true, autoStopInterval: 5});package main
import ( "context" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona" "github.com/daytonaio/daytona/libs/sdk-go/pkg/types")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
autoStop := 5 sandbox, err := client.Create(context.Background(), types.SnapshotParams{ SandboxBaseParams: types.SandboxBaseParams{ Ephemeral: true, AutoStopInterval: &autoStop, }, }) if err != nil { log.Fatal(err) }}require 'daytona'
daytona = Daytona::Daytona.newsandbox = daytona.create( Daytona::CreateSandboxFromSnapshotParams.new(ephemeral: true, auto_stop_interval: 5))import io.daytona.sdk.Daytona;import io.daytona.sdk.Sandbox;import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams(); params.setAutoDeleteInterval(0); // same effect as ephemeral: true params.setAutoStopInterval(5); Sandbox sandbox = daytona.create(params); } }}daytona create --auto-stop 5 --auto-delete 0curl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "autoStopInterval": 5, "autoDeleteInterval": 0}'Create a sandbox from a snapshot
Section titled “Create a sandbox from a snapshot”Create a sandbox from a pre-built snapshot for faster sandbox creation with pre-installed dependencies.
from daytona import Daytona, CreateSandboxFromSnapshotParams
daytona = Daytona()sandbox = daytona.create( CreateSandboxFromSnapshotParams( snapshot="my-snapshot-name", language="python" ))import { Daytona } from '@daytona/sdk';
const daytona = new Daytona();const sandbox = await daytona.create({ snapshot: 'my-snapshot-name', language: 'typescript'});package main
import ( "context" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona" "github.com/daytonaio/daytona/libs/sdk-go/pkg/types")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
sandbox, err := client.Create(context.Background(), types.SnapshotParams{ Snapshot: "my-snapshot-name", SandboxBaseParams: types.SandboxBaseParams{ Language: types.CodeLanguagePython, }, }) if err != nil { log.Fatal(err) }}require 'daytona'
daytona = Daytona::Daytona.newsandbox = daytona.create( Daytona::CreateSandboxFromSnapshotParams.new( snapshot: 'my-snapshot-name', language: Daytona::CodeLanguage::PYTHON ))import io.daytona.sdk.Daytona;import io.daytona.sdk.Sandbox;import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams(); params.setSnapshot("my-snapshot-name"); params.setLanguage("python"); Sandbox sandbox = daytona.create(params); } }}daytona create --snapshot my-snapshot-namecurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "snapshot": "my-snapshot-name"}'Create a sandbox with a declarative image
Section titled “Create a sandbox with a declarative image”Create a sandbox with a declarative image that defines dependencies programmatically.
from daytona import Daytona, CreateSandboxFromImageParams, Image
daytona = Daytona()image = ( Image.debian_slim("3.12") .pip_install(["requests", "pandas", "numpy"]) .workdir("/home/daytona"))sandbox = daytona.create( CreateSandboxFromImageParams(image=image), on_snapshot_create_logs=print)import { Daytona, Image } from '@daytona/sdk';
const daytona = new Daytona();const image = Image.debianSlim('3.12') .pipInstall(['requests', 'pandas', 'numpy']) .workdir('/home/daytona');const sandbox = await daytona.create( { image }, { onSnapshotCreateLogs: console.log });package main
import ( "context" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona" "github.com/daytonaio/daytona/libs/sdk-go/pkg/types")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
image := daytona.DebianSlim(nil). PipInstall([]string{"requests", "pandas", "numpy"}). Workdir("/home/daytona") sandbox, err := client.Create(context.Background(), types.ImageParams{ Image: image, }) if err != nil { log.Fatal(err) }}require 'daytona'
daytona = Daytona::Daytona.newimage = Daytona::Image .debian_slim('3.12') .pip_install(['requests', 'pandas', 'numpy']) .workdir('/home/daytona')sandbox = daytona.create( Daytona::CreateSandboxFromImageParams.new(image: image), on_snapshot_create_logs: proc { |chunk| puts chunk })import io.daytona.sdk.Daytona;import io.daytona.sdk.Image;import io.daytona.sdk.Sandbox;import io.daytona.sdk.model.CreateSandboxFromImageParams;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Image image = Image.debianSlim("3.12") .pipInstall("requests", "pandas", "numpy") .workdir("/home/daytona"); CreateSandboxFromImageParams params = new CreateSandboxFromImageParams(); params.setImage(image); Sandbox sandbox = daytona.create(params, 60, System.out::println); } }}daytona create --dockerfile ./Dockerfilecurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "buildInfo": { "dockerfileContent": "FROM python:3.12-slim\nRUN pip install requests pandas numpy\nWORKDIR /home/daytona" }}'Create a sandbox with volumes
Section titled “Create a sandbox with volumes”Create a sandbox with a volume mounted to share data across sandboxes.
from daytona import Daytona, CreateSandboxFromSnapshotParams, VolumeMount
daytona = Daytona()volume = daytona.volume.get("my-volume", create=True)sandbox = daytona.create( CreateSandboxFromSnapshotParams( volumes=[VolumeMount(volume_id=volume.id, mount_path="/home/daytona/data")] ))import { Daytona } from '@daytona/sdk';
const daytona = new Daytona();const volume = await daytona.volume.get('my-volume', true);const sandbox = await daytona.create({ volumes: [{ volumeId: volume.id, mountPath: '/home/daytona/data' }]});package main
import ( "context" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona" "github.com/daytonaio/daytona/libs/sdk-go/pkg/types")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
volume, err := client.Volume.Get(context.Background(), "my-volume") if err != nil { volume, err = client.Volume.Create(context.Background(), "my-volume") if err != nil { log.Fatal(err) } }
sandbox, err := client.Create(context.Background(), types.SnapshotParams{ SandboxBaseParams: types.SandboxBaseParams{ Volumes: []types.VolumeMount{{ VolumeID: volume.ID, MountPath: "/home/daytona/data", }}, }, }) if err != nil { log.Fatal(err) }}require 'daytona'
daytona = Daytona::Daytona.newvolume = daytona.volume.get('my-volume', create: true)sandbox = daytona.create( Daytona::CreateSandboxFromSnapshotParams.new( volumes: [DaytonaApiClient::SandboxVolume.new( volume_id: volume.id, mount_path: '/home/daytona/data' )] ))import io.daytona.sdk.Daytona;import io.daytona.sdk.Sandbox;import io.daytona.sdk.exception.DaytonaNotFoundException;import io.daytona.sdk.model.CreateSandboxFromSnapshotParams;import io.daytona.sdk.model.Volume;import io.daytona.sdk.model.VolumeMount;
import java.util.Collections;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Volume volume; try { volume = daytona.volume().getByName("my-volume"); } catch (DaytonaNotFoundException e) { volume = daytona.volume().create("my-volume"); }
VolumeMount mount = new VolumeMount(); mount.setVolumeId(volume.getId()); mount.setMountPath("/home/daytona/data");
CreateSandboxFromSnapshotParams params = new CreateSandboxFromSnapshotParams(); params.setVolumes(Collections.singletonList(mount));
Sandbox sandbox = daytona.create(params); } }}daytona volume create my-volumedaytona create --volume my-volume:/home/daytona/datacurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "volumes": [ { "volumeId": "<VOLUME_ID>", "mountPath": "/home/daytona/data" } ]}'Create a sandbox with a Git repository cloned
Section titled “Create a sandbox with a Git repository cloned”Create a sandbox with a Git repository cloned to manage version control.
from daytona import Daytona
daytona = Daytona()sandbox = daytona.create()
sandbox.git.clone("https://github.com/daytonaio/daytona.git", "/home/daytona/daytona")status = sandbox.git.status("/home/daytona/daytona")print(f"Branch: {status.current_branch}")import { Daytona } from '@daytona/sdk';
const daytona = new Daytona();const sandbox = await daytona.create();
await sandbox.git.clone('https://github.com/daytonaio/daytona.git', '/home/daytona/daytona');const status = await sandbox.git.status('/home/daytona/daytona');console.log(`Branch: ${status.currentBranch}`);package main
import ( "context" "fmt" "log"
"github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona")
func main() { client, err := daytona.NewClient() if err != nil { log.Fatal(err) }
sandbox, err := client.Create(context.Background(), nil) if err != nil { log.Fatal(err) }
sandbox.Git.Clone(context.Background(), "https://github.com/daytonaio/daytona.git", "/home/daytona/daytona") status, err := sandbox.Git.Status(context.Background(), "/home/daytona/daytona") if err != nil { log.Fatal(err) } fmt.Printf("Branch: %s\n", status.CurrentBranch)}require 'daytona'
daytona = Daytona::Daytona.newsandbox = daytona.create
sandbox.git.clone(url: "https://github.com/daytonaio/daytona.git", path: "/home/daytona/daytona")status = sandbox.git.status("/home/daytona/daytona")puts "Branch: #{status.current_branch}"import io.daytona.sdk.Daytona;import io.daytona.sdk.Sandbox;import io.daytona.sdk.model.GitStatus;
public class App { public static void main(String[] args) { try (Daytona daytona = new Daytona()) { Sandbox sandbox = daytona.create(); sandbox.git.clone("https://github.com/daytonaio/daytona.git", "/home/daytona/daytona"); GitStatus status = sandbox.git.status("/home/daytona/daytona"); System.out.println("Branch: " + status.getCurrentBranch()); } }}# Create a sandboxcurl 'https://app.daytona.io/api/sandbox' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{}'
# Clone a Git repository in the sandboxcurl 'https://proxy.app.daytona.io/toolbox/{sandboxId}/git/clone' \ --request POST \ --header 'Authorization: Bearer <API_KEY>' \ --header 'Content-Type: application/json' \ --data '{ "url": "https://github.com/daytonaio/daytona.git", "path": "/home/daytona/daytona"}'
# Get repository statuscurl 'https://proxy.app.daytona.io/toolbox/{sandboxId}/git/status?path=/home/daytona/daytona' \ --header 'Authorization: Bearer <API_KEY>'