Skip to main content
The Daytona TypeScript SDK provides a fully typed interface for interacting with Daytona Sandboxes, enabling sandbox management, code execution, file operations, and more.

Installation

Quick Start

Configuration

Using Environment Variables

Set the following environment variables:
Then initialize the client:

Using Configuration Object

Sandbox Management

Creating Sandboxes

Basic Sandbox Creation

Customized Sandbox Creation

Listing Sandboxes

Getting a Sandbox

Sandbox Lifecycle

Setting Labels

Code Execution

Running TypeScript/JavaScript Code

Executing Shell Commands

Code Interpreter (Stateful Execution)

File Operations

Uploading Files

Downloading Files

File System Operations

Git Operations

Cloning Repositories

Git Status and Branches

Committing Changes

Language Server Protocol

Starting an LSP Server

Code Intelligence

Stopping LSP Server

Error Handling

Complete Example

API Reference

Daytona Class

Methods

  • create(params?) - Create a new sandbox
  • get(sandboxIdOrName) - Get a sandbox by ID or name
  • list(options?) - List sandboxes with pagination
  • delete(sandbox) - Delete a sandbox

Sandbox Class

Properties

  • fs: FileSystem - File system operations interface
  • git: Git - Git operations interface
  • process: Process - Process execution interface
  • codeInterpreter: CodeInterpreter - Code interpreter interface
  • computerUse: ComputerUse - Computer use operations for desktop automation
  • id: string - Sandbox ID
  • state: SandboxState - Current state
  • labels: Record<string, string> - Custom labels
  • env: Record<string, string> - Environment variables

Methods

  • setLabels(labels) - Set custom labels
  • getPreviewLink(port) - Get port preview URL
  • start() - Start the sandbox
  • stop() - Stop the sandbox
  • delete() - Delete the sandbox
  • createLspServer(language, workingDir) - Create an LSP server

Process Class

Methods

  • executeCommand(command, cwd?, env?, timeout?) - Execute a shell command
  • codeRun(code, params?) - Execute code directly

FileSystem Class

Methods

  • uploadFile(content, path) - Upload a file
  • uploadFiles(files) - Upload multiple files
  • downloadFile(path) - Download a file
  • downloadFiles(requests) - Download multiple files
  • listFiles(path) - List files in a directory
  • createFolder(path, mode?) - Create a folder
  • searchFiles(root, pattern) - Search for files
  • replaceInFiles(files, oldStr, newStr) - Replace content in files

Git Class

Methods

  • clone(url, path, commitId?, branch?, username?, password?) - Clone a repository
  • status(path) - Get repository status
  • branches(path) - List branches
  • add(path, files) - Add files to staging
  • commit(path, message, author, email) - Commit changes
  • push(path, username?, password?) - Push changes

Best Practices

Always Use Try-Finally for Cleanup

Check Exit Codes

Use TypeScript for Type Safety

Handle Promise Rejections

Next Steps

SDK Overview

Compare all available SDKs

API Reference

Complete API documentation

Examples

Browse TypeScript examples on GitHub

Python SDK

Learn about the Python SDK