wtree Cloud

Sandboxes

Create short-lived Docker containers to run code from AI agents and automations, from the panel or the API.

A sandbox is a short-lived Docker container you create, run commands in, read and write files in, and discard. Use it when an AI agent, code interpreter or automation needs a clean, isolated place to execute code.

Sandboxes list

Sandboxes don't host services: they have no domain, no published ports and no persistent volumes. They run on the wtree Cloud server or on any remote server.

Typical uses:

  • Run code an AI agent writes without touching your applications.
  • Run user-submitted scripts in a code interpreter.
  • Run one-off jobs on a specific runtime such as Python, Node.js or Go.
  • Try a command or dependency without installing it on the server.

Create a sandbox

Open Sandboxes in the sidebar and pick a server in Viewing server.

Click Create sandbox.

Choose a template or custom image, set resources and click Create.

FieldWhat it doesDefault
NameLabel for the sandboxGenerated
Template / Custom imageBuilt-in template or any Docker image
ServerWhere the container runsServer being viewed
CPU coresCPU limit, 0.1 to 641
Memory (MB)Memory limit, swap disabled512
Timeout (minutes)Inactivity time before removal5
NetworkIsolated (no network) or InternetIsolated
RuntimeDocker runtime, such as runsc for gVisorrunc
Environment variablesKEY=value lines for every command

The sandbox page shows its details and a Console that streams command output.

In cloud mode, and on instances with Remote servers only enabled (Settings › Single sign-on), sandboxes must be created on a remote server.

Templates

Commands in every template run as the non-root user 1000:1000 in /home/user.

TemplateImage
baseubuntu:24.04
alpinealpine:3.20
pythonpython:3.13-slim
nodenode:22-slim
bunoven/bun:1
denodenoland/deno:debian
gogolang:1.24
rustrust:1-slim
rubyruby:3.3-slim
javaeclipse-temurin:21-jdk
phpphp:8.3-cli

A custom image must include sh, sleep and date. Commands run as 1000:1000 whatever the image's default user is.

Lifecycle

A sandbox is running until it becomes killed, which happens in one of three ways:

  • Inactivity timeout: removed after the configured timeout (5 minutes by default) with no activity. Running a command, writing a file or listing files restarts the countdown. A process left running inside doesn't.
  • Hard limit: removed 24 hours after creation, even if in use.
  • Kill: you stop it from the dashboard or the API.

Use Extend timeout on the sandbox page, or sandbox.setTimeout in the API, to change the timeout of a running sandbox. The container enforces its own lifetime, so sandboxes expire on time even if wtree Cloud is restarted or unreachable. The record stays in the list as killed until you delete it.

Everything inside a sandbox is lost when it stops. Read the files you need before the timeout expires.

Use the API

Every operation is in the wtree Cloud API. Create a key in your Profile (avatar menu), in the API/CLI Keys section, and send it in the x-api-key header.

export W3PANEL_URL=https://cloud.example.com
export W3PANEL_KEY=your-api-key

Create

curl -s -X POST "$W3PANEL_URL/api/sandbox.create" \
  -H "x-api-key: $W3PANEL_KEY" -H "content-type: application/json" \
  -d '{
    "template": "python",
    "name": "agent-run-42",
    "cpu": 1,
    "memoryMb": 512,
    "timeoutMs": 300000,
    "networkMode": "isolated"
  }'

The response contains the sandboxId that every other call needs. Optional fields: image (instead of template), serverId (omit for the wtree Cloud server), envVars, pidsLimit, workdir, maxLifetimeMs and runtime.

Run a command

curl -s -X POST "$W3PANEL_URL/api/sandbox.exec" \
  -H "x-api-key: $W3PANEL_KEY" -H "content-type: application/json" \
  -d '{"sandboxId": "SANDBOX_ID", "cmd": "python3 -c \"print(1+1)\""}'
{ "stdout": "2\n", "stderr": "", "exitCode": 0, "timedOut": false, "truncated": false }

The command runs through sh -c in the sandbox working directory. You can pass cwd, an env object and timeoutMs (60 seconds by default, 10 minutes at most). On timeout the command and its children are killed and exitCode is 124.

Write and read files

curl -s -X POST "$W3PANEL_URL/api/sandbox.writeFile" \
  -H "x-api-key: $W3PANEL_KEY" -H "content-type: application/json" \
  -d '{"sandboxId": "SANDBOX_ID", "path": "/home/user/main.py", "content": "print(\"hi\")\n"}'

curl -s "$W3PANEL_URL/api/sandbox.readFile?sandboxId=SANDBOX_ID&path=/home/user/main.py" \
  -H "x-api-key: $W3PANEL_KEY"

curl -s "$W3PANEL_URL/api/sandbox.listFiles?sandboxId=SANDBOX_ID&path=/home/user" \
  -H "x-api-key: $W3PANEL_KEY"

Paths must be absolute, and parent directories are created automatically. For binary files send "encoding": "base64" to writeFile and encoding=base64 to readFile.

writeFile and readFile don't run as the sandbox user. They reach any path regardless of permissions, and written files are owned by 1000:1000.

Stream output

For long commands, connect a WebSocket to /sandbox-exec?sandboxId=SANDBOX_ID with the x-api-key header and send one command at a time:

{ "type": "exec", "cmd": "pip install requests", "timeoutMs": 120000 }

The server sends stdout and stderr messages with a data chunk, and ends each command with an exit message:

{ "type": "exit", "exitCode": 0, "timedOut": false }

Endpoints

EndpointMethodWhat it does
sandbox.listGETSandboxes of the organization; add serverId for one server with live status
sandbox.oneGETOne sandbox
sandbox.templatesGETBuilt-in templates
sandbox.setTimeoutPOSTChange the inactivity timeout (timeoutMs)
sandbox.killPOSTStop the sandbox and keep the record
sandbox.removePOSTStop it if needed and delete the record

MCP

The wtree Cloud MCP server exposes the same operations: sandbox-create, sandbox-exec, sandbox-writeFile, sandbox-readFile, sandbox-listFiles, sandbox-setTimeout, sandbox-kill, sandbox-remove, sandbox-list, sandbox-one and sandbox-templates.

Security

Each sandbox is created with:

  • All Linux capabilities dropped and no-new-privileges enabled.
  • CPU, memory and process limits, with swap disabled.
  • Commands always running as a non-root user, unable to stop the processes that enforce the lifetime.
  • A dedicated network. Sandboxes can't reach each other and are never attached to w3panel-network or any application network.
  • No network access in Isolated mode, the default.
  • Environment variables encrypted at rest and never returned by the API.

Sandboxes use the standard Docker runtime (runc) by default and share the server's kernel. For untrusted code, use a stronger runtime such as gVisor and a server that doesn't host your applications. The non-root user restricts the code you run, not the API caller: sandbox.writeFile can replace any file in the container, and anyone with Create permission can keep a sandbox alive past its timeout and maximum lifetime. Grant it only to people you trust with the server.

Use gVisor

gVisor puts a user-space kernel between the sandbox and the server. wtree Cloud doesn't install it. You register the runtime once and select it per sandbox; other sandboxes and containers keep using runc.

Install runsc on the server by following the gVisor installation guide. It supports Linux on x86_64 and ARM64.

Register the runtime with shared file access, which wtree Cloud needs to read and write sandbox files:

sudo runsc install --runtime=runsc -- --overlay2=none --file-access=shared
sudo systemctl reload docker

Create the sandbox with Runtime set to runsc, or "runtime": "runsc" in the API.

With gVisor, /tmp lives in memory inside the sandbox, so files written there through sandbox.writeFile are invisible to your commands. Write under the working directory instead.

Permissions

Sandboxes belong to the organization, not a project. Owners and admins have full access; members have none.

ActionAllows
ReadView sandboxes, read and list files
CreateCreate sandboxes, run commands, write files, change the timeout, kill
DeleteDelete sandbox records

Limits

  • No interactive shell: commands run one at a time and can't read stdin.
  • No public domains or exposed ports.
  • No snapshots, pause or resume. A stopped sandbox can't be recovered.
  • Output is capped at 1 MiB per stream and files at 10 MiB.
  • Sandboxes can't join project or application networks.
  • On remote servers each operation opens an SSH connection, so calls are slower.

On this page