Skip to content

Users & Auth

A bhatti user is an owner with one API key. I usually create one for each agent or person sharing my server, so their sandboxes, secrets, images, volumes and snapshots stay separate. This isn’t a promise of hostile-tenant hosting — it’s a useful boundary for your own workloads. The installer creates an admin user and saves its key to the invoking user’s ~/.bhatti/config.yaml.

Terminal window
sudo bhatti user create --name coding-agent --max-sandboxes 5 --max-cpus 4 --max-memory 4096
# Save the printed bht_... key; it is shown once.

These are server-only commands that open the local data directory and SQLite database; they aren’t remote admin API calls. Give the agent its own key rather than sharing the admin key. For remote use, see Self-hosting → Remote access; the fresh control API has only a Unix socket.

The server stores the SHA-256 hash, not the plaintext key. Creation and rotation show the plaintext once; if a key is lost or compromised, user rotate-key replaces it. API calls require Authorization: Bearer <key> even over the local socket (except health and the web-shell entry point, which validates credentials on its WebSocket). Keys don’t belong in URL query parameters.

LimitWhat it controls
max_sandboxesNumber of concurrent, non-destroyed sandboxes owned by the key.
max_cpus_per_sandboxMaximum --cpus for a new sandbox.
max_memory_mb_per_sandboxMaximum --memory for a new sandbox.

Lowering limits doesn’t change existing sandboxes, but a fork or template-based create is held to the limits as they are now: a fork runs at its source’s size. New creates over the sandbox-count cap return 429 with "code": "quota_exceeded"; CPU/memory over the per-sandbox cap return 400.

Rate limits are per-user token buckets: 30 sandbox creates or forks per minute (burst 10), 600 exec/file-write/websocket requests per minute (burst 30), and 1200 other requests per minute (burst 60), including destroy and snapshot resume. The server config’s rate_limits changes them. They stop runaway loops; they aren’t a reservation of CPU, memory or disk. An exhausted bucket returns 429 with "code": "rate_limited" and a Retry-After header; the CLI waits and retries up to three times. A quota 429 has no Retry-After and isn’t retried. Watch the disk capacity of your host; volume and sandbox data still occupy real storage.

An owner lists and manipulates only their own sandboxes; looking up someone else’s sandbox returns 404. User secrets, images, snapshots and volumes are scoped to that owner. A fresh sandbox has no NIC. When one opts into networking, its owner’s bhatti-netd gateway enforces egress. Host addresses are denied except for configured daemon TCP service listener address/port pairs when the remaining policy permits them; private daemon-service addresses need an explicit CIDR allowance. Other host ports, gateway and other-owner addresses stay blocked, and API authentication still applies. Same-owner siblings cannot connect by default either; create with --allow-siblings only when the workload needs it. See Networking and Credentials for the two separate boundaries.