# Sandbox capabilities A sandbox is a private Linux machine in your workspace. Open a shell to edit files, run tests or preview a server. Pause a session to pick it up later, or fork it to try a change on a separate copy. You can create a sandbox before you have an app. ## Start a sandbox A running sandbox is called a **session**. Your workspace needs a worker to run one. **In the dashboard**, open **Services → New → Sandbox**. Enter a name, choose a template and select **Create sandbox**. Under **Sessions**, select **Start session**. When the session is running, open **Terminal**. **From the CLI**, [sign in](cli.md) and start a sandbox with this command. ```sh smolcloud sandbox new ``` This starts a session on the default template. Use the IDs printed beside `Environment:` and `Session:` in place of `ENV_ID` and `SESSION_ID` below. ```sh smolcloud sandbox exec ENV_ID SESSION_ID -- pwd ``` The command prints the working directory inside the sandbox. [Open a shell and work with your files](sandbox-workbench.md#open-a-terminal). ### Choose a template A template sets the tools and machine size your session starts with. In the dashboard, choose **Template and size** when you create the sandbox. To choose from the CLI, run `smolcloud sandbox templates` and copy the `identity` of the template you want. ```sh smolcloud sandbox create NAME TEMPLATE_IDENTITY ``` Use the returned `id` in `smolcloud sandbox start ENV_ID`. Each session starts with its own copy of the template. Workspace owners can [build a template with tools preinstalled](sandbox-custom-templates.md) by running setup commands on an approved base. Custom kernels and Dockerfile builds are unsupported. ## Work in a live session - **Run and debug code.** Open the browser terminal, run a command with `smolcloud sandbox exec`, or attach with `smolcloud sandbox ssh` on Linux or macOS with OpenSSH. Commands return their exit code. The process API streams output, accepts input and signals, and can reconnect to a running process. After an interrupted command stream, list processes and reconnect before starting more work. [Interactive sessions](sandbox-sessions.md). - **Work with files.** Use `sandbox write` to upload a local file and `sandbox read` to download it. The filesystem RPC can inspect, list, move, remove and watch files or directories. One file transfer is limited to 4 MiB. A session allows 64 MiB of transfer in total. [Copy a file from a session](sandbox-sessions.md). - **Test a service on a port.** Start a server in the guest, then ask the session API for its response. Use `POST /ports` for HTTP, `POST /ports/stream` for a streamed response, or a WebSocket upgrade on `/forward` under the session URL. Each request checks access. For an HTTPS address to share with teammates, [deploy a private app](builder-guide.md). ## Pause, fork and recover Pause saves files, memory and running programs to the worker. Resume restores them on that worker. A snapshot captures a starting point for more sessions. A fork takes a snapshot and starts a second, independent session. To compare two repository changes side by side, allow two concurrent sessions and leave enough capacity for both. [Fork a working session](sandbox-sessions.md). New environments default to one concurrent session and at most five minutes of running time. An owner can raise the limit up to twelve hours, subject to the worker lease. Read `deadlineAt` for the effective deadline. A pause can fail if the worker lacks space, so wait for `paused` before treating work as saved. Pauses expire after 30 days, ordinary snapshots after seven days, and fork snapshots after one day. Stopping deletes the session’s files. Worker disk loss also loses its pauses and snapshots. Download important output to a separate machine for recovery. [Session limits and retention](sandbox-sessions.md). ## Run a job or use a model For a single command, post a job with its time limit and optional input files. Poll for completion, then fetch the final stdout, stderr and result. Retry a lost submission with the same body and idempotency key. An app-backed job can export declared files to its approved bucket. For standalone work, download files from a session. [One-off jobs](sandbox-api.md). For a model-guided task, use an app-backed agent job. Its runner calls an approved model through the workspace gateway and lets it issue bounded commands in the guest. The provider key stays on the gateway on customer compute. The model provider receives the conversation, and the router handles prompts and responses in transit. The job result and export receipts tell you what completed. [Agent jobs](sandbox-agent.md) · [Workspace architecture](workspace-architecture.md). ## Give the machine access - **Internet.** Network access starts blocked. An owner can allow exact public hosts, choose the package-registry preset, or allow public HTTP and HTTPS on a qualified worker. General web permits sending data to public destinations. [Network settings](sandbox-environments.md). - **Database and bucket.** An authorized caller can grant a session access to an app’s PostgreSQL database or bucket. Allow the workspace HTTPS hostname first. The guest receives a short-lived capability for that resource. Pausing, snapshotting or stopping revokes the grant. Reconnect explicitly after a resume or fork. [Resource grants and examples](sandbox-resources.md). - **Workspace actions.** To create resources or deploy from inside a session, an administrator connects a named agent with those permissions. Its session credential is separate from a data grant or model access. [Connect a coding agent](agent-start.md). ## If your sandbox doesn’t start - **No worker attached.** Open **Settings → Workspace** and look under **Compute**. A session can start once the workspace has a worker with room to run it. - **Sandboxes are disabled or the template is too large.** Run `smolcloud sandbox templates` to see the workspace settings. If `enabled` is false, ask the owner to enable sandboxes in **Settings → Sandbox limits**. If the template exceeds the workspace limits, choose a smaller size. - **The start command timed out.** Run `smolcloud sandbox sessions ENV_ID` to see whether the session started before trying again. If you need the environment ID, `smolcloud sandbox list` lists the sandboxes you can access. [More sandbox troubleshooting](sandbox-questions.md#why-did-my-command-upload-or-session-fail). ## Use the API With your [workspace credentials](cli.md), call `GET /api/sandbox-environments/options` for templates, limits and availability. If `available` is false, `unavailableReason` explains why. The job and session API is documented at `/api/sandboxes/openapi.json` on your workspace. For app-specific permissions and calling instructions, use `smolcloud capabilities APP_ID` and `smolcloud guide APP_ID`. [Sandbox permissions](sandbox-environments.md#who-can-do-what).