sandbox/index.md
Deno Sandbox brings instant Linux microVMs to Deno Deploy. Each sandbox boots in
under a second, is API driven from the @deno/sandbox SDK, and is torn down as
soon as you are done. The result is on-demand compute that feels like opening a
terminal, yet ships with production-grade isolation and observability.
Deno Sandbox specializes in workloads where code needs to be generated, evaluated, or safely executed on behalf of an untrusted user. They are ideal for:
This is compute built not just for developers, but for software that builds software.
Once the Deno Sandbox exists, you get a full Linux environment with files, processes, package managers, and background services:
<deno-tabs group-id="sandbox-sdk"> <deno-tab value="js" label="JavaScript" default>import { Sandbox } from "@deno/sandbox";
await using sandbox = await Sandbox.create();
await sandbox.sh`ls -lh /`;
from deno_sandbox import DenoDeploy
def main():
sdk = DenoDeploy()
with sdk.sandbox.create() as sandbox:
process = sandbox.spawn("ls", args=["-lh"])
process.wait()
from deno_sandbox import AsyncDenoDeploy
async def main():
sdk = AsyncDenoDeploy()
async with sdk.sandbox.create() as sandbox:
process = await sandbox.spawn("ls", args=["-lh"])
await process.wait()
Provision a sandbox so that it can only talk to approved hosts:
<deno-tabs group-id="sandbox-sdk"> <deno-tab value="js" label="JavaScript" default>await Sandbox.create({
allowNet: ["google.com"],
});
sdk = AsyncDenoDeploy()
async with sdk.sandboxes.create(allowNet=["google.com"]) as sandbox:
print(f"Sandbox {sandbox.id} is ready.")
sdk = DenoDeploy()
with sdk.sandboxes.create(allowNet=["google.com"]) as sandbox:
print(f"Sandbox {sandbox.id} is ready.")
Secrets never enter the sandbox environment. The real value is substituted only when the sandbox makes outbound requests to approved hosts.
<deno-tabs group-id="sandbox-sdk"> <deno-tab value="js" label="JavaScript" default>await Sandbox.create({
allowNet: ["api.openai.com"],
secrets: {
OPENAI_API_KEY: {
hosts: ["api.openai.com"],
value: process.env.OPENAI_API_KEY,
},
},
});
sdk = AsyncDenoDeploy()
async with sdk.sandboxes.create(
allowNet=["api.openai.com"],
secrets={
"OPENAI_API_KEY": {
"hosts": ["api.openai.com"],
"value": os.environ.get("OPENAI_API_KEY"),
}
},
) as sandbox:
print(f"Sandbox {sandbox.id} is ready.")
sdk = DenoDeploy()
with sdk.sandboxes.create(
allowNet=["api.openai.com"],
secrets={
"OPENAI_API_KEY": {
"hosts": ["api.openai.com"],
"value": os.environ.get("OPENAI_API_KEY"),
}
},
) as sandbox:
print(f"Sandbox {sandbox.id} is ready.")
Developers and AI systems now expect compute that is instant, safe, and globally accessible. Deno Sandbox delivers:
Together, Deno Deploy and Deno Sandbox form a single workflow: code is created, proved safe in a sandbox, and deployed globally without new infrastructure or orchestration layers.
The Deno Sandbox SDK is tested and supported on:
You can use Deno Sandbox from any environment that can make outbound HTTPS
requests to the Deno Deploy API. The JavaScript SDK is available as
@deno/sandbox on both jsr and
npm (the JSR package is optimized
for Deno usage). The Python SDK is available as deno-sandbox on
PyPI. For direct API access, see the
REST API documentation.
:::note await using support
The
await using
syntax requires Node.js 24+. If your project uses earlier Node.js versions, use
try/finally blocks instead:
import { Sandbox } from "@deno/sandbox";
const sandbox = await Sandbox.create();
try {
// ... use sandbox ...
} finally {
await sandbox.close();
}
:::
Deno Sandbox has the following limits:
Exceeding these limits may result in throttling or termination of your sandbox.
Regions currently supported are:
ams - Amsterdam, Netherlandsord - Chicago, USAYou can specify the region where the sandbox will be created when creating a new sandbox:
<deno-tabs group-id="sandbox-sdk"> <deno-tab value="js" label="JavaScript" default>import { Sandbox } from "@deno/sandbox";
await using sandbox = await Sandbox.create({ region: "ams" });
from deno_sandbox import DenoDeploy
def main():
sdk = DenoDeploy()
with sdk.sandboxes.create(region="ams") as sandbox:
print(f"Sandbox {sandbox.id} is ready.")
from deno_sandbox import AsyncDenoDeploy
async def main():
sdk = AsyncDenoDeploy()
async with sdk.sandboxes.create(region="ams") as sandbox:
print(f"Sandbox {sandbox.id} is ready.")
If not specified, the sandbox will be created in the default region.
Ready to try it? Follow the Getting started guide to create your first sandbox, obtain an access token, and run code on the Deploy edge.