Databricks Sandbox

Important

This feature is in Beta. To enable this feature preview in the workspace, opt into the Databricks Sandbox setting in the workspace Previews page. See Manage Azure Databricks previews.

Databricks does not currently charge for usage of this feature. However, cost and pricing for features in Beta are subject to change.

Databricks Sandbox lets you run untrusted code in an isolated environment through the Databricks REST API, SDK, or Databricks CLI. The sandbox provides serverless, on-demand compute for running code dynamically.

Each sandbox includes a persistent home directory. You can stop and start a sandbox at any time, and the data in your home directory persists.

The sandbox is ideal for:

  • Running an agent harness.
  • Executing user-written or AI-written code.
  • Running background tasks or workers.
  • Launching interactive IDE or SSH sessions.

Prerequisites

Quickstart

Get started by creating a sandbox with a few lines of code:

from databricks.sdk import WorkspaceClient
from databricks.sdk.service.sandbox import Sandbox

w = WorkspaceClient()

created = w.sandbox.create_sandbox(
    sandbox=Sandbox(),
    sandbox_id="my-sandbox",
)
print(created.name)   # "sandboxes/my-sandbox"

For a full walkthrough of creating a sandbox, running commands in it, and managing its lifecycle, see Create and manage sandboxes with the SDK.

Compute size

Databricks Sandbox comes with 4 vCPUs and 8 GB of RAM. This size is not configurable.

Storage

Warning

At the end of the Beta period, Databricks might perform a one-time purge of data stored in sandboxes. Do not store anything you cannot afford to lose.

Databricks Sandbox comes with network-attached storage.

  • Data in your home directory (/home/sandbox-agent) persists for the lifetime of your Databricks Sandbox. Even after stopping your Databricks Sandbox, the data in your home directory is available when you start your next session.
  • Your home directory can store up to 100 GB. At this time, this cannot be changed.
  • You can store up to 10 GB outside your home directory, but this data is deleted when you stop your sandbox.

Networking

There are no restrictions on network egress from a sandbox, and egress is not configurable.

Usage costs

For complete billing usage information, see Databricks pricing. Databricks anticipates billing sandbox usage for:

  • Runtime compute: Billed hourly while your Databricks Sandbox is running.
  • Persistent storage: You are billed for the data stored in your home directory until your Databricks Sandbox is deleted. Storage incurs billing as long as the Databricks Sandbox instance exists. To stop paying for storage, you must delete the sandbox.
  • Data transfer

The Databricks SDK for Python is the recommended way to access the sandbox. See the Databricks SDK for Python sandbox reference for available commands, and Create and manage sandboxes with the SDK for examples.

Access the sandbox via CLI

You can also access your sandbox over SSH. This is useful for running longer agent tasks without needing your local machine to stay active. For example, you can:

  • Drive your coding agent directly from the Databricks CLI over SSH.
  • Connect a desktop IDE or an agent harness such as Cursor, Claude, or Codex.

To create a sandbox and connect to it with the Databricks CLI, run:

databricks sandbox create      # create your sandbox
databricks sandbox register    # optional: register SSH keys
databricks sandbox ssh         # SSH to your default sandbox

When you SSH into your sandbox, the Databricks CLI is installed and authenticated to the Databricks workspace where your sandbox is running. You might also want to configure Git credentials. See Connect your Git provider to Databricks.

For detailed command help, run databricks sandbox -h, or see sandbox command group.

When you first SSH into your sandbox, Databricks automatically configures common coding harnesses such as Claude and Codex to use AI Gateway if AI Gateway is configured for your workspace. For more information, see Create and manage model APIs (model services).

Managed Omnigent

Managed Omnigent uses Databricks Sandbox as its execution backend. For more information, see Omnigent on Databricks.

Limitations

  • Quotas are enforced. You can have at most 40 active sandboxes per user (400 total across all states), and a workspace can have at most 100 active sandboxes (1,000 total).
  • Databricks Sandbox is a compute primitive for running code, not a general-purpose Spark runtime. For Spark workloads, use Connect to serverless compute.
  • The public IP addresses of your Databricks Sandbox can change at any time. The default ingress of the sandbox is closed to all traffic. This cannot be changed at this time.
  • You cannot customize your environment at startup or persist an environment outside your home directory. To reuse packages or configurations across sessions, store them in your home directory.