Skip to content

CLI Reference

The Runra CLI (runra) provides a terminal interface for managing sandboxes, running AI agents, and interacting with the Runra platform. Install it alongside the SDK.

Terminal window
# Install globally
npm install -g @runra/cli
# Or run via npx
npx @runra/cli sandbox list
# Verify installation
runra --version

All commands accept these global flags:

FlagEnv VariableDescription
--api-key <key>RUNRA_API_KEYRunra API key
--api-url <url>RUNRA_API_URLAPI base URL (default: https://api.box.runra.dev)
--jsonOutput as JSON (for scripting)
--verboseShow debug output
--helpShow help for any command

Authenticate with Runra and store credentials locally.

Terminal window
runra auth login

Prompts for your API key interactively. Credentials are stored in ~/.runra/credentials.json.

Check authentication status.

Terminal window
runra auth status
{
"authenticated": true,
"workspace": "my-org",
"apiUrl": "https://api.box.runra.dev"
}

Remove stored credentials.

Terminal window
runra auth logout

Create a new API key.

Terminal window
runra auth create-key \
--name "production-ci" \
--scope "sandbox:create,sandbox:execute,sandbox:delete" \
--expires-in 90d
# Output
# Created API key: rra_live_x7k2m9p4q1w3v5b8n6c0d2a4f
# Name: production-ci
# Scopes: sandbox:create, sandbox:execute, sandbox:delete
# Expires: 2026-09-13
# Save this key — it will not be shown again.
FlagDescription
--name <name>Key name (required)
--scope <scopes>Comma-separated scopes (default: sandbox:*)
--expires-in <duration>Key lifetime: 30d, 90d, 365d, never

List all API keys for your account.

Terminal window
runra auth list-keys

Revoke an API key.

Terminal window
runra auth revoke-key --key-id "key_abc123def456"

Create a new sandbox.

Terminal window
runra sandbox create \
--image node:22 \
--cpu 2 \
--memory 4096 \
--disk 10240 \
--env NODE_ENV=production \
--env CI=true \
--timeout 300000 \
--idle-timeout 120000 \
--metadata userId=user_123 \
--label "build-sandbox"
FlagDescriptionDefault
--image <name>Base imagenode:22
--cpu <count>vCPUs (2, 4, 8)2
--memory <mb>Memory in MB4096
--disk <mb>Disk in MB10240
--env <KEY=VALUE>Environment variable (repeatable)
--workdir <path>Working directory/workspace
--timeout <ms>Max lifetime in ms300000
--idle-timeout <ms>Auto-pause after idle ms120000
--metadata <KEY=VALUE>Custom tags (repeatable)
--label <name>Friendly label
--waitWait for sandbox to be readyfalse

List sandboxes.

Terminal window
runra sandbox list # All sandboxes
runra sandbox list --state running # Only running
runra sandbox list --limit 10 # Paginate
runra sandbox list --json # JSON output

Get a single sandbox.

Terminal window
runra sandbox get sb_x7k2m9p4q1w3v5b8n

Pause a running sandbox.

Terminal window
runra sandbox pause sb_x7k2m9p4q1w3v5b8n

Resume a paused sandbox.

Terminal window
runra sandbox resume sb_x7k2m9p4q1w3v5b8n

Terminate a sandbox.

Terminal window
runra sandbox delete sb_x7k2m9p4q1w3v5b8n
# Force delete without confirmation
runra sandbox delete sb_x7k2m9p4q1w3v5b8n --force

Execute a command in a sandbox.

Terminal window
# Simple command
runra exec sb_x7k2m9p4q1w3v5b8n "npm install && npm run build"
# With options
runra exec sb_x7k2m9p4q1w3v5b8n "npm test" \
--cwd /workspace/packages/core \
--env CI=true \
--timeout 120000
# Execute from stdin
echo "console.log('hello')" | runra exec sb_x7k2m9p4q1w3v5b8n "node -"
FlagDescriptionDefault
--cwd <path>Working directorySandbox workdir
--env <KEY=VALUE>Environment variable (repeatable)
--timeout <ms>Command timeout60000
--stdin <text>Text to pipe to stdin

Execute with streaming output.

Terminal window
runra exec stream sb_x7k2m9p4q1w3v5b8n "for i in 1 2 3; do echo Line \$i; sleep 1; done"

List files in a sandbox.

Terminal window
runra files ls sb_x7k2m9p4q1w3v5b8n /workspace
runra files ls sb_x7k2m9p4q1w3v5b8n /workspace/src --recursive

Read a file from a sandbox.

Terminal window
runra files read sb_x7k2m9p4q1w3v5b8n /workspace/package.json

Write content to a sandbox file.

Terminal window
runra files write sb_x7k2m9p4q1w3v5b8n /workspace/app.ts ./local-file.ts
# Write from stdin
echo "export const hello = 'world'" | runra files write sb_x7k2m9p4q1w3v5b8n /workspace/hello.ts --stdin

Delete a file or directory.

Terminal window
runra files delete sb_x7k2m9p4q1w3v5b8n /workspace/temp.log
runra files delete sb_x7k2m9p4q1w3v5b8n /workspace/old-build --recursive

Check if a path exists.

Terminal window
runra files exists sb_x7k2m9p4q1w3v5b8n /workspace/package.json
# Exit code: 0 (exists) or 1 (not found)

Expose a port for public access.

Terminal window
runra port expose sb_x7k2m9p4q1w3v5b8n 3000
# Output
# Port 3000 exposed at https://3000-ab12cd.box.runra.dev

List exposed ports.

Terminal window
runra port list sb_x7k2m9p4q1w3v5b8n

Close an exposed port.

Terminal window
runra port close sb_x7k2m9p4q1w3v5b8n 3000

Run an AI agent in a sandbox.

Terminal window
runra agent run \
--provider claude-code \
--model claude-sonnet-4-20250514 \
--image node:22 \
--prompt "Create a React component for a signup form"
# Use an existing sandbox
runra agent run \
--provider codex \
--sandbox sb_x7k2m9p4q1w3v5b8n \
--prompt "Add validation to the signup form"
FlagDescriptionDefault
--provider <name>Agent adapterclaude-code
--model <name>LLM modelAgent default
--sandbox <id>Existing sandbox ID
--image <name>Sandbox image (creates new)node:22
--cpu <count>Sandbox vCPUs2
--memory <mb>Sandbox memory MB4096
--max-turns <n>Maximum agent loops50
--permission <mode>auto-approve, prompt, planauto-approve

Stream live runtime events.

Terminal window
runra events tail --sandbox sb_x7k2m9p4q1w3v5b8n
# Filter by type
runra events tail --type exec.completed
# Output as JSON
runra events tail --json

Export events to a file.

Terminal window
# Export to JSONL
runra events export \
--sandbox sb_x7k2m9p4q1w3v5b8n \
--output ./events.jsonl
# Filter and export
runra events export \
--type "exec.completed" \
--after 2026-06-15T00:00:00Z \
--limit 1000 \
--output ./exec-events.jsonl

Set configuration values.

Terminal window
runra config set defaults.image node:22
runra config set defaults.resources.cpu 4
runra config set sandbox.provider runra-sandbox
runra config set observability.provider axiom

Get configuration values.

Terminal window
runra config get defaults.image
runra config get --all

Remove a configuration value.

Terminal window
runra config unset defaults.image

Check API health.

Terminal window
runra health
# Output
# ✓ API: healthy (v1)
# ✓ Authentication: valid
# latency: 45ms

Show CLI version.

Terminal window
runra version
# Output
# runra CLI 1.2.0
# @runra/sdk 1.2.0
# @runra/runtime 1.2.0

Generate shell completion scripts.

Terminal window
# Bash
source <(runra completion bash)
# Zsh
source <(runra completion zsh)
# Fish
runra completion fish > ~/.config/fish/completions/runra.fish

The --json flag outputs structured JSON for use in scripts:

Terminal window
# Create sandbox and capture ID
SANDBOX_ID=$(runra sandbox create --json | jq -r '.id')
# Execute and capture result
RESULT=$(runra exec "$SANDBOX_ID" "npm test" --json)
EXIT_CODE=$(echo "$RESULT" | jq -r '.exitCode')
# List sandboxes with jq
runra sandbox list --json | jq '.data[] | {id, state, image}'

The CLI reads configuration from these environment variables:

VariableDescription
RUNRA_API_KEYAPI key for authentication
RUNRA_API_URLAPI base URL
RUNRA_CONFIG_PATHConfig file location (default: ~/.runra/config.json)
CodeMeaning
0Success
1General error
2Authentication error
3Network error
4Invalid arguments
5Sandbox not found
6Execution failed (non-zero exit code)