Execute commands and stream output. Includes exec()
, execStream()
, and background process management.
API Reference
The Sandbox SDK provides a comprehensive API for executing code, managing files, running processes, and exposing services in isolated sandboxes. All operations are performed through the Sandbox
instance you obtain via getSandbox()
.
import { getSandbox } from '@cloudflare/sandbox';
const sandbox = getSandbox(env.Sandbox, 'user-123');
The sandbox ID should be unique per user or session. The same ID will always return the same sandbox instance with persistent state.
The Sandbox SDK is organized into focused APIs:
Read, write, and manage files in the sandbox filesystem. Includes directory operations and file metadata.
Execute Python and JavaScript code with rich outputs including charts, tables, and formatted data.
Expose services running in the sandbox via preview URLs. Access web servers and APIs from the internet.
Advanced: Create isolated execution contexts with persistent shell state. Configure environment variables and manage container lifecycle.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-