Interactive sandbox sessions
Keep a sandbox running: commands, files, private ports, pause, resume and snapshots.
A session keeps a sandbox running while you send commands, read and write files, or call an HTTP server inside it. Pause the session to continue later, or take a snapshot when you want to start a separate copy.
From the command line
Run the commands below as smolcloud sandbox COMMAND after signing in. Replace the uppercase names with your own values. ENV_ID identifies the sandbox and its settings. SESSION_ID identifies one running or saved session. Start a sandbox shows how to get both IDs.
| Task | Command after smolcloud sandbox |
|---|---|
| See available templates and workspace limits | templates |
| List sandboxes you can access | list |
| Create a sandbox and start it on the default template | new [NAME] |
| Create a sandbox for later, optionally choosing its template | create NAME [TEMPLATE_IDENTITY] |
| Start a session and wait for it to be ready | start ENV_ID [--lifetime SECONDS] [--template BASE_IDENTITY] |
| List sessions, or wait for one to be ready | sessions ENV_ID · wait ENV_ID SESSION_ID |
| Run a program and return its exit code | exec ENV_ID SESSION_ID -- COMMAND [ARGUMENTS...] |
| Open a shell, or run one quoted shell command over SSH | ssh ENV_ID SESSION_ID [COMMAND] |
| Upload a file from your computer | write ENV_ID SESSION_ID SANDBOX_PATH LOCAL_FILE |
| Download a file to your computer | read ENV_ID SESSION_ID SANDBOX_PATH > LOCAL_FILE |
| Pause or resume a session | pause ENV_ID SESSION_ID · resume ENV_ID SESSION_ID |
| Stop a session and delete its files | stop ENV_ID SESSION_ID |
| Grant temporary access to an app’s database or bucket | connect SESSION_ID APP_ID database or connect SESSION_ID APP_ID bucket |
| Revoke a resource grant | revoke-resource GRANT_ID |
For an app’s sessions, put --app before the session command and use the app ID in place of ENV_ID. To select a workspace explicitly, put --workspace WORKSPACE_ID before the command. The --template option on start requires workspace-owner access. SSH requires OpenSSH on Linux or macOS. Operators checking a worker’s host prerequisites can run smolcloud sandbox doctor [DATA_DIRECTORY] on that host.
Run commands and copy files · Use a database or bucket · Run a one-off job · Run a model-guided job.
Start and use a session
Choose the base URL for the session you want to use.
| Caller and sandbox | Base path on the workspace | Credentials |
|---|---|---|
| Person or agent using a standalone sandbox | /api/sandbox-environments/{environmentId}/sandbox-sessions | Workspace bearer token and X-Innie-Workspace: WORKSPACE_ID |
| Person or agent using an app’s sandbox | /api/apps/{appId}/sandbox-sessions | Same workspace credentials, with access to that app’s sandbox |
| Deployed app calling its own sandbox | /api/workloads/apps/{appId}/sandbox-sessions | Backend’s injected SANDBOX_API_TOKEN as a bearer token and the incoming request’s X-Innie-Connector-Context |
Create a session with a POST to the base address, then GET it until ready is true before sending commands. A new sandbox allows one session at a time, for five minutes, with network access blocked; the owner can change these. Full request and response schemas are in /api/sandboxes/openapi.json.
| To | Request | Body or result |
|---|---|---|
| Start a session | POST base | {version:1,idempotencyKey:UUID,lifetimeSeconds:300} |
| List your sessions | GET base | The latest 50 |
| Check one | GET /{sessionId} | Its state, and ready |
| Stop it | POST /{sessionId}/kill | {version:1}. Its files are deleted |
| Run a command | POST /{sessionId}/rpc | See below |
| Write a file | POST /{sessionId}/files/write | {path,contentBase64} |
| Read a file | POST /{sessionId}/files/read | {path} → {contentBase64} |
| Call a server inside it | POST /{sessionId}/ports | {port,path,method,contentType?,bodyBase64?} → {status,contentType,bodyBase64} |
Private HTTP and WebSockets
Use a running session and a server listening on 0.0.0.0 inside it. Each route below starts at the session URL (base/{sessionId}). Try a private port has a complete request you can copy.
| What you need | Request | How to read the response |
|---|---|---|
| One HTTP response, up to 4 MiB | POST /ports | Read status and contentType. Decode bodyBase64 as bytes. |
| A streamed HTTP response | POST /ports/stream | Read one JSON object per line. The first has the guest’s status and content type. Decode each bodyBase64 chunk in order and check for a final {"complete":true}. An early disconnect leaves the response incomplete. |
| A WebSocket connection | Upgrade GET /forward?port=8000&path=%2Fecho | URL-encode the guest path. Text and binary messages keep their type. Authenticate the handshake the same way as other session requests. |
Both HTTP routes accept port, path and method (GET, HEAD, POST, PUT, PATCH or DELETE). To send a body, set contentType and encode the bytes in bodyBase64. A successful call to Smolcloud can carry a guest error such as 404 in status. Requests use the session’s authorized connection. The guest receives no workspace token or browser cookies. Port 49983 is reserved.
Run a command
Send this request to the session's /rpc endpoint:
{
"service": "process",
"method": "Start",
"idempotencyKey": "b33f3cd6-075b-4718-b26c-dd1a7a778d38",
"input": {
"process": {
"cmd": "/bin/bash",
"args": ["-lc", "python3 -c 'print(42)'"]
},
"stdin": false
}
}
The response is a stream with one JSON object per line: output as it happens, then a final complete line.
- Read to the
completeline and check it for an error before treating the command as finished. - If the connection drops, don't start the command again; sending the same UUID returns 409. Call
Listto find the process, thenConnectto pick its output back up. - To stop a command, send
SendSignalor stop the session. Closing the connection leaves it running.
For process control, the supported RPC methods are Start, List, Connect, SendInput, SendSignal, CloseStdin and Update. For filesystem operations, use Stat, MakeDir, ListDir, Move, Remove, WatchDir, CreateWatcher, GetWatcherEvents or RemoveWatcher. Use the dedicated file endpoints above to transfer file contents.
Pause and resume
| Request | Body and what to wait for |
|---|---|
POST /{sessionId}/pause | {version:1}; poll until state:"paused" |
POST /{sessionId}/resume | {version:1,idempotencyKey,lifetimeSeconds}; poll until ready:true |
A paused session keeps its running programs, memory and files until the time in pauseExpiresAt. Open network connections are dropped. Stopping a session, unlike pausing, deletes its files, so read anything you need first.
Sessions request a pause shortly before their execution deadline, and after fifteen
minutes without an authorized file/process/port request or a connected stream.
Detached background programs pause too. Keep the process stream connected while
working. A workspace administrator can allow sessions up to twelve hours; existing
workspace settings remain unchanged. A worker with less time left shortens the run,
and deadlineAt reports that actual deadline. No run extends the worker lease.
POST /{sessionId}/connect with {version:1,idempotencyKey} resumes a paused machine
within the current workspace limit, or returns its existing run. Poll until ready.
smolcloud sandbox ssh ENV_ID SESSION_ID does this automatically. Reconnect the
named-agent credential and resource grants after resume: copied credentials stay revoked.
Pauses still need a free slot (two per environment, eight per workspace) and enough worker disk space. A refused or failed save is not a successful pause: the hard execution deadline still stops the guest. Export important work before it expires. Usage reports conservative memory-plus-disk reservations for saved machines and snapshots separately from input/log storage. Paused machines and snapshots live on the worker disk and are not backed up; worker disk loss loses them.
Save a snapshot or make a copy
A snapshot saves a running session so you can start new sessions from that point later. A fork does both at once: it snapshots the session and starts a second one from it.
| To | Request | Body or result |
|---|---|---|
| Take a snapshot | POST /{sessionId}/snapshots | {version:1,idempotencyKey,name}; GET it until ready |
| Fork a session | POST /{sessionId}/fork | {version:1,idempotencyKey,lifetimeSeconds,name?} → snapshot and session |
| Start from a snapshot | POST base | Add snapshotId to the usual body |
| List or check snapshots | GET …/sandbox-snapshots, /{snapshotId} | |
| Delete a snapshot | POST …/sandbox-snapshots/{id}/delete | {version:1}; wait for deleted |
Snapshot addresses use sandbox-snapshots where session addresses use sandbox-sessions. Taking a snapshot pauses the session for a moment, so reconnect to any command output afterwards.
To install tools once and reuse them in every session, build a custom template instead.
Limits
- Session length: 15–43,200 seconds, or less if the owner set a lower limit. Time spent waiting to start counts.
- The session API allows 8 requests at once, 4,096 requests and 128 process starts. Each
sandbox execstarts a process. Commands typed into an already-open shell run inside that shell without another session API start. - 4 MiB per file or request body, and 64 MiB transferred per session in total.
- Port 49983 is reserved. The port endpoint returns the response body (size-limited), not a public URL.
- A paused session is kept for 30 days. Snapshots are kept for 7 days; a fork's snapshot for 1 day.
- Snapshot names: up to 63 lowercase letters, digits and hyphens, starting with a letter or digit.
- A new session starts from one thing: the sandbox's template, a snapshot (
snapshotId), a custom template (templateId), or, for owners, another base template (baseTemplateIdentity). A session started from a snapshot keeps the original's CPU and memory size.
Connect a named agent
An administrator can give a running sandbox a credential for an existing named agent. In its Sessions list, choose Connect agent, select the agent, then confirm. Create the identity in Users first and allow it to use this sandbox. Use general web access or include your workspace HTTPS hostname in the session's approved network list.
The credential stays in the guest. The screen returns only its configuration path;
set INNIE_CONFIG_FILE to that path when running the Smolcloud CLI inside the
sandbox. It acts as the named agent with that agent's existing permissions. It
can create apps, databases and buckets as a builder, subject to your compute
allowance. Existing resources still need grants; administrative actions still
need an explicit administrator delegation in Users → Agents.
Pause, snapshot and stop revoke the credential before state is copied. Resume and fork do not revive copied credentials: connect the agent again in the new running session. An expired job or worker lease also refuses requests. Reconnecting rotates only this agent's credential for this session, retaining unrelated CLI credentials. Delivery failure revokes the attempted credential, so retrying is safe.
The equivalent browser-authenticated request is
POST /api/sandbox-sessions/SESSION_ID/agent with
{"agentId":"AGENT_ID","confirm":true}. The response contains credentialId,
agentId, path and expiresAt, never the token. Keep the configuration file
private: it is a bearer credential while its session remains authorized.