Skip to content

CLI Reference

bhatti is a single binary. bhatti serve runs the daemon; everything else is a CLI client that talks to the daemon’s HTTP API. All sandbox commands accept the sandbox name or ID interchangeably.

Terminal window
bhatti setup # configure endpoint + API key
bhatti create --name dev # create a sandbox
bhatti exec dev -- echo hello # run a command
bhatti shell dev # interactive shell (Ctrl+\ to detach)
bhatti destroy dev # clean up
CommandSyntaxDescription
Core
createbhatti create [flags]Create a new sandbox VM
destroybhatti destroy <sandbox> [-y]Destroy a sandbox (alias: rm)
editbhatti edit <sandbox> [--keep-hot | --allow-cold]Update mutable settings
execbhatti exec <sandbox> [--] <command...>Run a command in a sandbox
inspectbhatti inspect <sandbox>Show sandbox details (alias: info)
listbhatti list [-o wide]List sandboxes (alias: ls)
portsbhatti ports <sandbox>List listening ports inside a sandbox
psbhatti ps <sandbox>List active sessions in a sandbox
sharebhatti share <sandbox> [--revoke]Generate a web shell URL
shellbhatti shell <sandbox> [--new]Open an interactive shell (alias: sh)
startbhatti start <sandbox> [--force]Resume a stopped sandbox
stopbhatti stop <sandbox>Snapshot and stop a sandbox
Files
file readbhatti file read <sandbox> <path>Read a file from a sandbox
file writebhatti file write <sandbox> <path>Write a file (reads from stdin)
file lsbhatti file ls <sandbox> <path>List directory contents
Networking
publishbhatti publish <sandbox> -p <port> [-a <alias>] [--shell]Publish a port with a public URL
unpublishbhatti unpublish <sandbox> -p <port>Remove a published port
Images
image listbhatti image listList available rootfs images
image pullbhatti image pull <ref> [--name N] [--auth U:T]Pull from a public OCI registry
image importbhatti image import <docker-ref> | --tar <path> [--name N]Import a Docker image or tarball
image savebhatti image save <sandbox> --name <image>Save a sandbox’s filesystem as an image
image deletebhatti image delete <name> [-y]Delete an image
image sharebhatti image share <name> --user <u>...Share an image with specific users
image unsharebhatti image unshare <name> --user <u>...Revoke image access from users
Volumes
volume createbhatti volume create --name <v> --size <MB>Create a persistent volume
volume listbhatti volume listList volumes
volume deletebhatti volume delete <name> [-y]Delete a volume
volume resizebhatti volume resize <name> --size <MB>Resize a volume (grow only)
volume clonebhatti volume clone <src> --name <new>Clone a volume (point-in-time copy)
volume backupbhatti volume backup <name>Back up a volume to S3
volume backup-listbhatti volume backup-list <name>List backups for a volume
volume restorebhatti volume restore <name> --backup-id <id>Restore a volume from a backup
volume backup-deletebhatti volume backup-delete <name> <id> [-y]Delete a volume backup
Secrets
secret setbhatti secret set <name> <value>Create or update a secret
secret listbhatti secret listList secret names
secret deletebhatti secret delete <name> [-y]Delete a secret
Snapshots
snapshot createbhatti snapshot create <sandbox> --name <snap>Checkpoint a running sandbox
snapshot listbhatti snapshot listList snapshots
snapshot resumebhatti snapshot resume <snap> [--name <new>]Resume from a snapshot into a new sandbox
snapshot deletebhatti snapshot delete <name> [-y]Delete a snapshot
Server & admin
servebhatti serveStart the bhatti daemon
setupbhatti setupConfigure CLI endpoint and API key
versionbhatti versionPrint version and check for updates
updatebhatti update [--cli-only] [--tiers <list>]Update bhatti
completionbhatti completion <bash|zsh|fish>Generate shell completion script
user createbhatti user create --name <u> [--max-...]Create a user (server-only)
user listbhatti user listList users (server-only)
user rotate-keybhatti user rotate-key <name>Rotate a user’s API key (server-only)
user deletebhatti user delete <name> [-y]Delete a user (server-only)
admin statusbhatti admin statusOne-shot system overview (server-only)
admin eventsbhatti admin events [--type T] [--since 24h]Query the event log (server-only)
admin metricsbhatti admin metrics [--since 1h]Query metrics snapshots (server-only)

These flags are accepted by every command.

FlagDescription
--url <url>API endpoint (overrides config and BHATTI_URL).
--token <key>API key (overrides config and BHATTI_TOKEN).
--data-dir <path>Path to the server’s data directory. Required for bhatti user * and bhatti admin * since those operate directly on the local SQLite database.
--jsonPrint machine-readable JSON instead of the default human format. Universally supported.
--timingPrint a per-request timing breakdown (DNS, connect, TLS, server, transfer, total) to stderr after the command runs.
-h, --helpShow help for any command.
VariableUsed byDescription
BHATTI_URLCLIAPI endpoint. Falls back when --url is not set and the config file has no api_url.
BHATTI_TOKENCLIAPI key. Same fallback semantics as BHATTI_URL.
BHATTI_CONFIGCLI + serverOverride path to the config file. When set, layered loading is bypassed and only this file is read.
BHATTI_LOG_LEVELserver (bhatti serve)debug, info (default), warn, error.
BHATTI_FORCE_STREAMCLI (bhatti exec)Set to 1 to force NDJSON streaming output even when stdout is not a TTY. Useful in CI logs where you want real-time progress.

Per-call flag → config file → environment variable → built-in default.

--url <x> (highest)
api_url: <x> (in config file)
BHATTI_URL=<x> (env var)
http://localhost:8080 (default, lowest)

The config file is the primary source — bhatti setup writes it and most users never touch the rest. Environment variables are the fallback for CI pipelines and scripts.

See Configuration for the file format and layered loading rules (/etc/bhatti/config.yaml for system settings, ~/.bhatti/config.yaml for client credentials).

Human (default). Compact, TTY-friendly. bhatti list prints columns; bhatti inspect prints kubectl-describe-style details with live disk usage on running VMs.

--json. Universally supported. Drops all human formatting; emits the raw API response (for queries) or a small status object (for mutations).

bhatti list -o wide. Adds CPUs, memory, disk, and image columns to list. Equivalent to kubectl get -o wide.

Streaming exec output. bhatti exec auto-detects how to format its output:

  • Stdout is a TTY → NDJSON streaming, line-by-line, flushed immediately.
  • Stdout is a pipe or --json is set → buffered JSON with {exit_code, stdout, stderr}.
  • Override with BHATTI_FORCE_STREAM=1 to force streaming when piping.
CodeMeaning
0Success.
1CLI or API error (see stderr for details and recovery hints).
<n>bhatti exec only — the child process’s exit code is forwarded verbatim, so a script’s $? reflects the command’s true status.

Destructive commands (destroy, volume delete, image delete, snapshot delete, volume backup-delete, secret delete, user delete) require confirmation. Pass -y / --yes to skip the prompt; without -y in a non-interactive shell, the command exits 1.

Terminal window
bhatti completion bash > /etc/bash_completion.d/bhatti
bhatti completion zsh > "${fpath[1]}/_bhatti"
bhatti completion fish > ~/.config/fish/completions/bhatti.fish

Sandbox-name completion uses a local cache (/tmp/bhatti-completions-<uid>) updated by create, destroy, and list. It never hits the network — instant, works offline.