Routing and policies
Every sandbox runs on one provider account, chosen when it's created and kept for good. A sandbox either names where it runs, with its spec.placement.selector, or leaves it to your workspace's Auto order, which tries providers in turn and fails over to the next.
This guide explains both. For every field of a create and each refusal, see Run or create a sandbox in the API guide.
Providers and accounts
| Provider | topology.sandboxrouter.io/provider | Runs on |
|---|---|---|
| Native | cloudflare | Sandbox Router's own account. It takes no key, and Sandbox Router bills it |
| Daytona, E2B, Freestyle, Maritime | daytona, e2b, freestyle, maritime | Your workspace's own account, by its key. That provider bills you directly |
A workspace connects one account of each provider: in the console under Settings → Providers, with sandboxrouter provider-configs connect (Providers), or in the API (Provider accounts). Once the provider takes its key, the account is a pool of your namespace, labelled with its provider and its name. A provider whose key you haven't connected runs none of your sandboxes. An account runs in the region it's connected with, where the provider takes one: Daytona's target, E2B's domain.
Pin a sandbox
A sandbox's spec.placement.selector names where it runs, by one label or both:
topology.sandboxrouter.io/provider: a provider. Native runs on Sandbox Router's account, and every other on your own account of it.topology.sandboxrouter.io/account: one of your own provider accounts, by its name. With a provider beside it, the provider must be the account's.
{
"metadata": { "name": "build-agent" },
"spec": { "placement": { "selector": { "topology.sandboxrouter.io/provider": "e2b" } } }
}A pinned sandbox runs there or nowhere: no other provider is tried. A selector matches by equality and takes no other label. A create its place can't run, such as one on a provider you haven't connected, an account whose key isn't Ready, or a feature its provider doesn't offer, is refused before anything is created.
In the console, pick the provider under 1. Choose a provider in New sandbox. With the CLI, pass --provider PROVIDER or --account ACCOUNT.
The Auto order
A sandbox without a selector is placed by your workspace's Auto order: a list of providers, tried in turn. Until an owner sets it, it's maritime, daytona, freestyle, e2b, cloudflare: your own accounts first, then Native. An owner sets it in the console under Settings → Auto order, or with PUT /v1/providers/auto (The Auto order), for every create after the change.
A create passes over a provider of the order:
whose key your workspace hasn't connected;
that can't run what the sandbox asks: its size (exactly, with
sizeMatch: exact), its image, its outbound access or its connectors.
A provider the order leaves out is never used for such a sandbox, and [] leaves it nowhere to run. A create no provider of the order can run is refused before anything is created.
Under Auto, a sandbox with a list of hosts or with connectors goes only to Native, which enforces them for all of its traffic, outside the sandbox. Daytona, E2B and Freestyle apply them only to what goes through their proxy, so Auto never places such a sandbox there; a selector can still name one of them. GET /v1/providers shows each provider's place in your Auto order and what it offers (The providers in your workspace).
Creation failover
Under Auto, the create goes to the first provider of the order that can run the sandbox. When that provider refuses the create, or its sandbox never runs, the next provider of the order takes the create, and so on down the order.
The sandbox keeps one uid and one name throughout.
status.providernames where it runs.Once it runs, its placement is for good: a sandbox never moves to another provider.
A pinned sandbox has one place to try, so nothing to fail over to.
A refusal before anything is created (a field, the name, billing or the key's scopes) isn't failed over: the create ends there.
Sending the create again with the same
Idempotency-Keyand body answers the same sandbox, wherever it was placed.When no provider of the order runs it, the create answers
503provider_unavailable, withRetry-Afterwhen the provider said how long, or the sandbox readsFailed, with why on itsReadycondition.
Snapshots and images
A sandbox that boots something one provider account holds runs on that account alone, whatever its placement:
A restore (
spec.from.snapshotRef) runs on its snapshot's own provider and account.An image of the namespace made of a provider's artifact runs on your own account of that provider.
An image of the namespace made of a Dockerfile runs on your Daytona account, where it's built.
A selector that names another provider is refused 422 Unsupported. See Snapshots and Images and the registry.
Policies
| What | Who can |
|---|---|
| Create a sandbox, pinned or under Auto | Owners and operators, and their keys with sandbox:write |
| Set the Auto order | Owners, and their keys |
| Connect or remove a provider account | Owners, and their keys |
| Read the providers, pools, accounts and Auto order | Everyone in the workspace, and keys with sandbox:read |
See Scopes and Roles for what each key and role allows.
Where a sandbox may connect out is its own spec.network.egress, enforced by its provider: see Outbound access. A sandbox's connectors add their keys to its requests on the way out, without the sandbox ever holding them: see Connectors.