How to do it in a sandbox
One task each, with working TypeScript and Python.
- How to add a custom domain to a sandboxRun runtime domain add app.example.com <sandbox> 3000, set the TXT and CNAME records it prints, then runtime domain verify.
- How to add Runtime to Claude.ai as a custom connectorIn Claude, open Customize > Connectors, choose Add custom connector, enter https://api.withruntime.com/mcp, and approve in your browser.
- How to add Runtime to Cursor with MCPAdd a runtime server running npx -y withruntime mcp to ~/.cursor/mcp.json, then approve the link Cursor's agent shows you.
- How to attach a persistent volume to a sandboxCreate a volume with runtime.volumes.create({ sizeMiB }), then pass volumes: [{ volumeId, path }] when you create the sandbox.
- How to back up and restore a sandbox volumeVolumes are backed up off their server daily; volumes.backup(id) makes one now and volumes.restore(backupId) restores it.
- How to block a domain from a sandboxCall sbx.network.set({ internet: true, deny: ["example.com"] }); the sandbox keeps the rest of the internet but never reaches that domain.
- How to build a custom sandbox image from a list of packagesCall runtime.images.build({ name, recipe: { pip, apt, npm } }) once, then create each sandbox with image: name; the build is free.
- How to build a sandbox image from a DockerfileRun runtime image build .
- How to call the Runtime REST API with curlSend Authorization: Bearer $RUNTIME_API_KEY to https://api.withruntime.com/v1/...; POST /v1/sandboxes with {} creates a sandbox.
- How to cap what a single sandbox can costPass maxTotalCostMicros for a ceiling over the sandbox's whole life, or maxCostMicros to refuse a create whose first lease costs more.
- How to choose a sandbox's CPU, memory and disk sizePass vcpu, memoryMiB and diskMiB when you create the sandbox; the default is 2 vCPU, 4 GiB of memory and a 4 GiB disk.
- How to compare your sandbox costs with E2B, Daytona, Modal and othersRun runtime compare --from e2b (or another provider); it prices your last 30 days of sandboxes at that rival's published rates.
- How to connect your network to sandboxes with WireGuardRun runtime tunnel create, runtime tunnel peer add office and sudo wg-quick up ./runtime.conf; your machines then reach every sandbox.
- How to control a Linux desktop in a cloud sandboxCall sbx.desktop.start(), then drive it with open, click, type and press, and call screenshot() to see what changed.
- How to create a read-only API key for monitoring and CIChoose Read only when you create a key at withruntime.com/account/keys, or run runtime keys create --read-only.
- How to download files from a sandboxCall sbx.files.readText(path) or read(path) for one file, and sbx.files.download(dir, localDir) for a whole folder.
- How to expose a port from a sandbox at an HTTPS URLStart the server with spawn, then call sbx.previews.create(port); the address needs a token unless you pass visibility: "public".
- How to extend a sandbox's leaseCall sbx.extend(seconds) while the sandbox runs; it moves the end of the lease later, up to an hour ahead of now, as often as you need.
- How to find a sandbox by nameCall Sandbox.getOrCreate("dev"); it returns the sandbox that holds the name, woken if paused, or creates one when none does.
- How to fork a running sandbox into parallel copiesCall sbx.fork({ count }) for up to 10 running copies with the source's files, memory and processes, all answered in one call.
- How to give sandboxes a static outbound IP addressRun runtime address reserve; from then on every sandbox of your account sends from that one IPv4 address, for $5 per 30-day month.
- How to handle no_capacity and quota_exceeded errorsLet the SDK wait: a create refused with no_capacity, quota_exceeded or trial_busy sends the same request again for up to two minutes.
- How to install apt packages in a sandboxRun sudo apt-get update && sudo apt-get install -y <package> in the sandbox; sudo needs no password, because you are root inside it.
- How to install Python packages with uv in a sandboxuv is preinstalled: run uv venv, then uv pip install <package>, or uv sync in a project that has a uv.lock.
- How to invite your team to a Runtime accountOpen Members, choose Invite member, enter the email address and a role, and send; the link works once, for seven days.
- How to keep a sandbox runningCreate it with persistent: true to keep a paid sandbox running while credit lasts, or call keepAlive() to hold it from your process.
- How to label and list sandboxesPass labels: { team: "search" } when you create a sandbox, then runtime.sandboxes.list({ labels }) returns every sandbox that matches.
- How to make charts with a code interpreterRun matplotlib code with sbx.interpreter.run(); every open figure comes back as a PNG in the result, with no file to fetch.
- How to mount an S3 bucket in a sandboxStore the bucket's key as a Runtime secret, then call sbx.mounts.add({ provider: "s3", bucket, path, secret }).
- How to open a cloud sandbox in VS Code with Remote-SSHRun runtime sandbox ssh config --install once, then in VS Code run Remote-SSH: Connect to Host and enter <id>.runtime.
- How to open a public TCP port on a sandboxRun runtime port open <sandbox> 5432; it prints a public address:port that carries raw TCP to that port in the sandbox.
- How to open an interactive terminal in a sandboxRun runtime sandbox shell <id> from your terminal, or call sbx.terminal() in code for a real terminal over a WebSocket.
- How to pause a sandbox when it is idleSet idlePauseSeconds; after that many seconds with no request the sandbox pauses, and the next request wakes it.
- How to pause and resume a sandboxCall pause() to save its files, memory and running processes, and wake() to carry on exactly where it stopped, on the same host.
- How to port-forward a database from a sandbox to your machineRun runtime sandbox port-forward <id> 5432; localhost:5432 on your machine then reaches Postgres inside the sandbox.
- How to read a sandbox's CPU and memory metricsCall sbx.metrics({ range: "1h" }): latest is the newest reading and points the series, measured by the sandbox's host.
- How to read your Runtime audit logOwners and admins open Audit log in the account, or call GET /v1/audit with a key an owner or admin made, filtered by action.
- How to receive webhooks for sandbox eventsCall runtime.webhooks.create({ url, events }); Runtime POSTs each event to your HTTPS URL, signed, retrying for about three days.
- How to reserve CPU for a sandbox (dedicated vCPUs)Create it with cpu: "reserved" to guarantee every vCPU, or raise cpuFloorMillis to guarantee part of them while CPU stays shared.
- How to restrict a sandbox to an allow-list of hostsCreate the sandbox with network: { internet: true, allow: ["pypi.org", "*.pythonhosted.org"] }; every other destination is refused.
- How to retry sandbox API calls safely with idempotency keysSend the same Idempotency-Key with the same body, and for 24 hours Runtime answers the first result again instead of acting twice.
- How to rotate a preview tokenCall sbx.previews.rotate(port): every token issued for that port stops working, and the call returns a new one.
- How to run a background process in a sandboxCall spawn() with the command; it starts a server, watcher or REPL, returns at once, and keeps running after you disconnect.
- How to run an MCP server in a sandboxCall sbx.mcp.start([{ id: "github" }]), wait for sbx.mcp.ready(), and give your agent each server's HTTPS URL and bearer header.
- How to run Docker inside a sandboxRun sudo enable-docker once in the sandbox; it installs Docker Engine, Buildx and Compose, and docker then works as the sandbox user.
- How to run Runtime sandboxes from GitHub ActionsMake a key with runtime keys create, store it as the repository secret RUNTIME_API_KEY, and run npx withruntime in a workflow step.
- How to set a daily spending limit for an AI agent's API keySet it on the key's row at withruntime.com/account/keys, or make the key with runtime keys create --daily-limit 25.
- How to set up single sign-on (SAML or OIDC) for RuntimeAn owner connects your identity provider on the Single sign-on page, proves the email domain with a DNS TXT record, and picks a role.
- How to snapshot a sandbox and start new ones from itCall sbx.snapshot({ name, retentionDays }), then sandboxes.create({ snapshot: id }) to start a new sandbox as that machine.
- How to SSH into a cloud sandboxRun runtime sandbox ssh <id>; the CLI makes a key, sends only its public half and logs you in as the sandbox user.
- How to start a sandbox from a private registry imageStore the registry's credential once with runtime image registry set, then build from the private image and start sandboxes from it.
- How to stream command output from a sandboxPass onStdout to exec (on_stdout in Python), or loop over execStream(); each chunk arrives as the command prints it.
- How to switch from E2B to Runtime by changing one importReplace from "e2b" with from "withruntime/e2b" (Python: from withruntime.e2b import Sandbox) and set RUNTIME_API_KEY.
- How to take a screenshot in a cloud sandboxStart the sandbox's desktop and call sbx.desktop.screenshot() for PNG bytes, or run Playwright's page.screenshot() for a full page.
- How to turn off internet access in a sandboxCreate the sandbox with network: { internet: false }, or call sbx.network.off() at any time; every outbound connection is refused.
- How to upload a folder to a sandboxCall sbx.files.upload(localDir, "/workspace/project"); the whole folder travels as one compressed archive and keeps its permissions.
- How to use API keys in a sandbox without exposing themStore the key with runtime secrets set NAME --host api.example.com; sandboxes see a placeholder and Runtime adds the value in transit.
- How to use AWS from a sandbox without storing keysTrust https://withruntime.com/oidc in IAM, then trade the sandbox's identity token for a role with AssumeRoleWithWebIdentity.
- How to use JetBrains Gateway with a cloud sandboxRun runtime sandbox ssh config --install, then add a Gateway SSH connection to <id>.runtime, user runtime, using the OpenSSH config.
- How to use Runtime's OpenAPI specDownload https://api.withruntime.com/v1/openapi.json, an OpenAPI 3.1 document of every route, and feed it to a client generator.
- How to verify a Runtime webhook signatureCompare v1 in Runtime-Signature with the hex HMAC-SHA256 of {t}.{raw body} under your secret, and refuse ones over five minutes old.
- How to wake a sandbox on requestDo nothing: a paused sandbox wakes by itself when an exec, file, process or terminal call, or a visit to a shared port, reaches it.
- How to watch files for changes in a sandboxCall sbx.files.watch(dir, onEvent, { recursive: true }); it reports each create, write, remove, rename and chmod as it happens.