Skip to content

Getting Started

View as Markdown

This section introduces core concepts, common workflows, and next steps for using Daytona.

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:

Terminal window
brew install daytonaio/cli/daytona

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:

Terminal window
brew upgrade daytonaio/cli/daytona

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.

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:

Terminal window
daytona mcp init [claude/cursor/windsurf]

For more information, see the MCP server documentation.

The TypeScript SDK ships as a dual ESM/CJS package and works out of the box in Node.js, Bun, Next.js, Nuxt.js, Remix, Vite SSR, AWS Lambda, and Azure Functions without any extra configuration.

For Cloudflare Workers, set the Node.js compatibility flag in your wrangler.toml:

compatibility_flags = ["nodejs_compat"]

For Deno, install with deno add npm:@daytona/sdk or import directly with the npm: specifier:

import { Daytona, Image } from 'npm:@daytona/sdk'

For browser apps with Vite (or any browser bundler), install vite-plugin-node-polyfills and add it to your vite.config.ts:

import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineConfig({
plugins: [nodePolyfills({ globals: { Buffer: true, process: true, global: true } })],
})

The SDK uses Node’s Buffer for binary data (downloaded files, multipart bodies). Browsers don’t ship Buffer, so the polyfill provides it. Without it, basic operations like Image.base() and daytona.list() still work, but methods that handle binary payloads (fs.downloadFile, fs.downloadFiles) will throw.

Some runtimes don’t expose the full set of Node.js APIs (browsers and edge runtimes have no filesystem, no crypto, etc.). Methods that depend on those APIs throw a clear runtime error instead of silently producing wrong results.

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.

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 with default settings.

from daytona import Daytona
daytona = Daytona()
sandbox = daytona.create()
print(f"Sandbox ID: {sandbox.id}")

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()

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)
)
)

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)
)

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"
)
)

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
)

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")]
)
)

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}")