quiet robotBook a call

Sandboxes

Quickstart

Create a sandbox, write a file, run it, watch a blocked connection and a command held for approval, then destroy the sandbox.

View as Markdown

Sandboxes is in early access. It is free to try, some parts are still in testing, and details may change. Sign up free

This takes about five minutes. You'll need Node.js 18 or newer and a Sandboxes API key.

1. Get an API key

Sign in to the dashboard, open API keys and create one. It starts with qr_live_ and is shown only once. Keep it in an environment variable:

Terminal
export QR_API_KEY=qr_live_...
export QR_BASE_URL=https://www.quietrobot.ai/app

2. Create a sandbox

With curl:

Terminal
curl -s -X POST "$QR_BASE_URL/api/v1/sandboxes" \
  -H "Authorization: Bearer $QR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"quickstart","timeoutSec":300,"egress":{"mode":"allowlist","allow":["pypi.org"]}}'

The response is the sandbox. Note its id (it starts with sbx_). The call returns once the sandbox is running.

JSON
{
  "id": "sbx_7f3a9c2e1b4d6a",
  "name": "quickstart",
  "status": "running",
  "template": "base",
  "cpus": 1,
  "memoryMb": 1024,
  "egress": { "mode": "allowlist", "allow": ["pypi.org"] },
  "deadlineAt": "2026-11-29T18:05:00.000Z"
}

(Shortened. See the sandbox object for every field.)

3. Write a file and run it

Terminal
SBX=sbx_7f3a9c2e1b4d6a

curl -s -X PUT "$QR_BASE_URL/api/v1/sandboxes/$SBX/files?path=main.py" \
  -H "Authorization: Bearer $QR_API_KEY" \
  --data-binary $'print("hello from a quiet robot")\n'

curl -s -X POST "$QR_BASE_URL/api/v1/sandboxes/$SBX/exec" \
  -H "Authorization: Bearer $QR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cmd":"python3 main.py"}'

Relative paths are inside the sandbox user's home folder, /home/sandbox. The command's result comes back in the same response:

JSON
{ "id": "exe_…", "status": "completed", "exitCode": 0, "stdout": "hello from a quiet robot\n", "stderr": "", "durationMs": 41 }

4. See the network rule work

This sandbox may only reach pypi.org. Anything else is blocked:

Terminal
curl -s -X POST "$QR_BASE_URL/api/v1/sandboxes/$SBX/exec" \
  -H "Authorization: Bearer $QR_API_KEY" -H "Content-Type: application/json" \
  -d '{"cmd":"curl -s -m5 -o /dev/null -w \"%{http_code}\" https://example.com || true"}'

stdout is 000: the connection never left the VM. The blocked attempt is in the audit log.

5. See a command held for approval

The default rules hold recursive force deletes, among others:

Terminal
curl -s -X POST "$QR_BASE_URL/api/v1/sandboxes/$SBX/exec" \
  -H "Authorization: Bearer $QR_API_KEY" -H "Content-Type: application/json" \
  -d '{"cmd":"rm -rf /tmp/scratch"}'

This returns 202 Accepted with "status": "pending_approval" and the rule that matched. It runs only after a person approves it in the dashboard. Poll GET /api/v1/executions/{id} for the result, or let the SDK wait for you. See Approvals.

6. Destroy it

Terminal
curl -s -X DELETE "$QR_BASE_URL/api/v1/sandboxes/$SBX" -H "Authorization: Bearer $QR_API_KEY"

If you forget, the sandbox stops by itself at its deadline (here, 5 minutes).

The same thing with the SDK

TypeScript
import { Sandboxes } from "@quietrobot/sandboxes";

const qr = new Sandboxes(); // reads QR_API_KEY and QR_BASE_URL
const sbx = await qr.create({ name: "quickstart", timeoutSec: 300, egress: { mode: "allowlist", allow: ["pypi.org"] } });

await sbx.files.write("main.py", "print('hello from a quiet robot')\n");
const run = await sbx.exec("python3 main.py");
console.log(run.exitCode, run.stdout);

// Held by the "Recursive force delete" rule. Don't wait for a person here.
const held = await sbx.exec("rm -rf /tmp/scratch", { waitForApproval: false });
console.log(held.status, held.approval?.reason); // pending_approval Recursive force delete

console.log((await sbx.audit()).map((e) => e.action));
await sbx.destroy();

Note

The SDK isn't on npm yet. Until it is, use the REST API directly; every SDK call maps to one request, listed in the SDK reference.