Skip to main content
Run agents and workloads on your machine by default. Need more compute? Switch to our managed cloud by setting the backend for the CLI and SDKs. Keep the same sandbox code, and switch back just as easily.

Start locally

Microsandbox runs locally by default, without a cloud account or daemon:
With no backend configured, SDK calls also run locally without an API key.

Switch to cloud

Get an API key from the dashboard and set it in your environment:
Select cloud for CLI commands and SDK calls:
Run the same code with either destination:
New builders and lookups use the configured destination. Use an explicit resource selector to override it for one workflow. Existing builders and resources keep their original connection.

Switch back

Select local execution again:
MSB_BACKEND=remote switches unqualified SDK calls and CLI commands to remote. MSB_API_KEY supplies credentials; setting it alone does not switch where commands run. cloud remains an alias for remote. Set MSB_API_URL to use another API, or save a profile for later commands.

Save a connection

Save a connection as a profile to use it again. Profiles live in ~/.microsandbox/config.json.
Set url on a remote profile for a self-hosted API. See the profiles schema for all fields and credential sources. Readers accept the previous backend and cloud spellings; older SDKs may reject profiles rewritten with kind and remote.

View and switch

For one command, use MSB_PROFILE:

Load a profile in code

New SDK calls honor the active profile. To use a different named profile explicitly:

More options

Another endpoint

The default endpoint is https://api.microsandbox.dev. Set an explicit URL to use another compatible API; an empty URL is an error. Explicit http:// endpoints are supported for deployments that manage transport protection separately, such as local development or an encrypted tunnel. HTTP itself does not encrypt the API key, request body or response. Use HTTPS when you need the SDK connection to provide transport encryption and server-certificate verification.
Explicit remote context options take precedence over MSB_API_KEY and MSB_API_URL independently. A key is required. The URL defaults to https://api.microsandbox.dev. For Standard and Shared options, see compute types.
Create a copy of a context to change its endpoint, credentials, or options. Settings you leave out stay the same. Existing resources keep their original connection. Copying a context does not reload profiles or configuration.
Empty URLs and keys are errors. Changing a connection does not contact the server.
Request timeouts and user agents can be set when constructing or deriving a context. See the SDK references for options and validation. Custom HTTP client behavior is documented in the Rust configuration reference.
CLI selection uses this order:
  1. Explicit --local or --remote on a supported resource command
  2. Managed active_profile
  3. MSB_BACKEND=local|remote
  4. MSB_PROFILE
  5. Saved active_profile
  6. Local runtime
Explicit flags override a managed active profile but still enforce allowed_backends.--remote uses MSB_API_KEY and optional MSB_API_URL (otherwise the hosted default), not the credentials or URL of the saved profile. Missing environment credentials are an error. --local selects the local context. These flags apply to the current command and do not save a new profile preference.Environment and managed settings can override msb context use; the command warns when they do. reset clears only the saved preference. Missing credentials or a blocked connection cause an error. The command will not run locally instead.A managed active_profile of null or "" clears saved and environment-selected profiles, while preserving MSB_BACKEND. To enforce local execution, choose a named managed local profile. Managed profile entries replace same-named user entries.
Set allowed_backends to ["local"], ["remote"], or ["local", "remote"] in user configuration or managed overrides. cloud remains an input alias for remote. Both are allowed by default; an empty list is invalid. null removes the restriction, and managed values replace user values.This controls where execution is allowed. It does not switch the current connection. Changes apply to newly created contexts. See managed configuration.
See context commands for JSON output and troubleshooting.

Check your connection

msb context shows where CLI commands run. To check an object’s connection in code, see your SDK reference. See configuration for defaults and cloud limitations for feature differences.

Resource selectors

For explicit selection before creation, lookup or listing, use the resource’s local() or remote() selector. Sandbox, Volume and Snapshot return their existing plural collection types. Unqualified calls follow configuration and fall back to local. Explicit selectors override the configured destination and respect managed backend restrictions.
Remote selectors capture MSB_API_KEY and optional MSB_API_URL at the call, ignoring ambient backend/profile selection. Construction performs no remote lookup; validation or missing-provider errors happen before a usable remote collection is returned. Existing collections, deferred builders and resources keep captured credentials after environment changes. Go’s local selectors also return an error because context/provider construction can fail. Rust selectors are gated by the corresponding local/cloud feature. Bindings require the corresponding installed provider and never fall back to the other destination. Use Resource.ctx(context) or context collections when selecting a named profile, a different account or custom local configuration. Instance resources remain bound to their original destination. Rust local_state() / remote_state() expose retained backend-specific state; they do not perform live inspection.

Agent connection timeouts

Agent connection timeout errors identify the phase that exhausted the connection deadline: identity is the sandbox lookup, websocket covers connection establishment and upgrade, and handshake is the guest-agent protocol handshake. The deadline covers the whole attempt. A timeout does not retry the command or change TLS verification; retain the phase when reporting an intermittent connection failure.