API reference (3)
Last updated Sep 30, 2026 Note
This page documents Sandbox SDK 0.x for existing applications. For new applications, refer to Sandboxes. To move an existing application to @cloudflare/sandbox 1.0, refer to Migrate from Sandbox SDK 0.x.
The Sandbox SDK provides a comprehensive API for executing code, managing files, running processes, and exposing services in isolated sandboxes.
Lifecycle
Create and manage sandbox containers. Get sandbox instances, configure options, and clean up resources.
Commands
Execute commands and stream output. Run scripts, manage background processes, and capture execution results.
Files
Read, write, and manage files in the sandbox filesystem. Includes directory operations and file metadata.
File watching
Monitor real-time filesystem changes using native inotify. Build development tools, hot-reload systems, and responsive file processing.
Code interpreter
Execute Python and JavaScript code with rich outputs including charts, tables, and formatted data.
Ports
Expose services running in the sandbox via preview URLs. Access web servers and APIs from the internet.
Tunnels
Expose services on zero-config *.trycloudflare.com URLs via sandbox.tunnels.get(port). Best for quick development and .workers.dev deployments.
Storage
Mount S3-compatible buckets (R2, S3, GCS) as local filesystems for persistent data storage across sandbox lifecycles.
Backups
Create point-in-time snapshots of directories and restore them from R2.
Sessions
Create isolated execution contexts within a sandbox. Each session maintains its own shell state, environment variables, and working directory.
Terminal
Connect browser-based terminal UIs to sandbox shells via WebSocket, with the xterm.js SandboxAddon for automatic reconnection and resize handling.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/sandbox/sdk/api/#page","headline":"API reference","description":"Sandbox SDK 0.x API for executing code, managing files, running processes, and exposing services.","url":"https://developers.cloudflare.com/sandbox/sdk/api/","inLanguage":"en","image":"https://developers.cloudflare.com/sandbox/sdk/api/og.png?v=2992d25c6889cd46","dateModified":"2026-09-30","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Create and restore point-in-time snapshots of sandbox directories with the Sandbox SDK 0.x. title: Backups image: https://developers.cloudflare.com/sandbox/sdk/api/backups/og.png?v=931f259941cef1e9
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/sandbox/llms.txt
Use this file to discover all available pages before exploring further.
Docs