CLI
Install the briq CLI, sign in with a link or an API key, and run the MCP tools from a terminal or a script.
npm install -g @briq-cloud/cli
briq login
briq run postgres --sleep 2hThe CLI calls the REST API. Most commands match an MCP tool
with the same options: briq_exec is briq exec, briq_set_sleep is briq set-sleep. Agents use
the MCP server; the CLI is for you, your scripts, git hooks and CI. It needs Node 22.6 or later.
Sign in
With a link
briq loginOpen this link to sign in, then pick the team and budget for the briq CLI:
https://app.briq.cloud/connect?user_code=WDJBMJHT
Approve only if the page shows the code WDJBMJHT.- Open the link on any device, sign in, pick the team and the budget, and approve.
- The CLI shows the team and budget, and saves the sign-in.
The CLI's sign-in is listed on the dashboard's Agents & CLI page, where you revoke it. It stays signed in while you use it at least once every two weeks.
With an API key
briq login --key bq_live_…
cat key.txt | briq login --key
export BRIQ_API_KEY=bq_live_… # CI, containers, agentsCreate the key on the dashboard's API keys page. BRIQ_API_KEY wins over a saved sign-in.
For a sandbox credential, set BRIQ_API_KEY and use the exact sandbox ID.
Only direct command, command-result/cancellation and file commands are supported.
login --key, whoami, quota and status need a team credential. Read safe status through REST instead.
Who am I
briq whoamiteam Acme (acme), plan pro
as briq CLI (signed in by link)
budget … a day, 3 briqs at once, sizes nano, small
api https://api.briq.cloud (production)briq logout forgets the sign-in on this machine and prints its dashboard page.
Revoke browser sign-ins on Agents & CLI, or keys on API keys. Run briq logout before
signing in again.
Commands
The full command table assumes a team credential. See the sandbox credential support matrix.
Where a command takes a <briq>, give its id (bq_…) or its name. A name must belong to exactly one live briq of the team: when two stacks share it, the command lists the ids to use instead. A sandbox credential uses the exact id.
| Command | MCP tool | What it does |
|---|---|---|
briq catalog [name] | briq_catalog | The recipes, or one with its fields and outputs |
briq run <recipe or image> | briq_run | Create and start a briq. See briq run |
briq up | briq_up | Bring up the stack in briq.yaml. See briq up |
briq list | briq_list | Briqs of the team. --stack <name>, --all for destroyed ones too, --name <name>, --label <k=v> and --state <state> (repeat them), --limit <n> and --cursor <cursor> for a page |
briq status <briq> | briq_status | One briq, with the time its create took to each step, its image digest and an opaque id of its host |
briq shell <briq> | Open an interactive terminal; type exit to leave. Requires terminal stdin and stdout | |
briq exec <briq> -- <cmd…> | briq_exec | Run a command and exit with its code. --timeout <ms>, --stdin to pipe input, --env K=V (repeat it), --clear-env. Put CLI options before -- |
briq exec --async <briq> -- <cmd…> | briq_exec | Start a command that takes over a minute; prints its exec id. --stdin-open for exec-input |
briq exec-result <briq> <exec> | briq_exec_result | Where it stands, with its output. --wait <ms>. --offset <n> prints the output from that byte, raw, and the next offset on stderr (--stream, --max-bytes). Exits with its code |
briq exec-input <briq> <exec> [text|-] | briq_exec_input | Write to its stdin; - pipes this command's stdin. --eof, --seq <n> |
briq exec-stop <briq> <exec> | briq_exec_stop | Stop it |
briq logs <briq> | briq_logs | Recent logs. -n 200, --since <cursor> |
briq files-put <briq> <path> [file] | briq_files_put | Upload a file, from file or piped stdin, sent as it is read. The limit is maxFileBytes in briq quota --json (1 MB or more) |
briq files-get <briq> <path> | briq_files_get | Download a file to stdout, or -o <file> |
briq expose <briq> <port> | briq_expose | A URL for a port. --mode private or public, --rotate for a new token |
briq expose <briq> <port> --additional | briq_expose | A separate HTTP URL, keeping the front door; supported environments only |
briq unexpose <briq> <endpoint> | briq_unexpose | Remove one HTTP URL; the service keeps running privately |
briq expose <briq> <port> --protocol postgres | briq_expose | A TCP endpoint over TLS. See Connect from outside |
briq fork <briq> | briq_fork | Fork one briq. --name, --stack, --sleep, --no-wait. --cmd <command> replaces CMD on a raw-image fork with a copied volume |
briq fork --stack <stack> | briq_fork | Fork every briq of a stack. --into <stack>, --branch <branch> (into the stack it names: feat/login → feat-login), --sleep, --env <file>, --expose (from outside), --no-wait. Exits 1 when a fork ends in error |
briq stop <briq> · briq start <briq> | briq_stop · briq_start | Stop or start a briq. Its disk is kept. Stop accepts --no-wait |
briq destroy <briq> | briq_destroy | Destroy a briq. --no-wait returns after it is queued. --no-volume-publish skips publishing its --volume-publish volume |
briq destroy --stack <stack> | briq_destroy (stack) | Destroy every briq of a stack, by name or id. --no-wait returns after they are queued. --branch <branch> for the stack a branch's fork made |
briq set-sleep <briq> <sleep> | briq_set_sleep | When it goes to sleep: 30m, 3h, 7d, never. --stack for its whole stack |
briq resize <briq> | briq_resize | Another size, bigger volume, or stopped image: --size medium, --volume-gb 20, or --image ubuntu:24.04 alone |
briq move <briq> [stack] | briq_move | Into a stack, or out of it with --out; a running briq joining a stack with briqs restarts |
briq quota | briq_quota | What the credential may still spend and run today |
briq secrets | briq_secrets | The team's secrets: names, ids, hosts and where each goes; never a value |
briq secret-update <id> | briq_secret_update | Narrow where a secret goes, without its value: --host <host...> and --location <header|body...>, the whole new lists. Adding a host or body is the dashboard's. See Edit a team secret |
briq volumes | briq_volumes | The team's volumes: name, id, size, state, generation, last use and expiry |
briq volume-destroy <volume> | briq_volume_destroy | Delete a volume, by name or id. Briqs that name it start empty |
briq feedback <topic> <message> | briq_feedback | Write to the briq team: bug, idea or question |
briq mcp | Where to add briq to an MCP client: Clients |
--json on commands other than shell prints the API's response instead of the summary. Messages go to stderr,
so --json output stays parseable.
With --no-wait, an already pending move returns invalid_state. Read its status to follow completion.
Command routing
A synchronous briq exec goes to the regional origin when the API returns scoped execution access,
and through the API's exec route when the API answers that regional access is unsupported. There is no option to set.
Sandbox credentials are refused regional access; their commands run through the API route.
briq exec <briq> -- uname -aPut CLI options before the briq ID, then -- before the command to preserve its arguments.
Without --, recognized CLI options are consumed even after the briq ID.
briq run and briq up ask for this access with the create, and the CLI never prints an access grant, --json included.
After sending a regional command, the CLI never retries it through the API route.
An uncertain result requires checking the command's effects before running it again.
Async commands, interactive terminals and file transfers use the API routes.
briq run
A recipe and the fields it changes, or an image with its settings: the briq_run input as flags.
briq run postgres --image pgvector/pgvector:pg16 --volume-gb 10 --sleep 2h
briq run node --checkout github.com/acme/api --step 'npm ci' --cmd 'npm start' --expose private
briq run nginx:1.27 --port 80 --file /usr/share/nginx/html/index.html=index.html --expose public| Option | Field | Notes |
|---|---|---|
--image <image> | image | A recipe: another tag (postgres:17) or a compatible image |
-e, --env <K=V…> | env | Added to a recipe's env, or replacing one of its values |
--cmd <command> | cmd | Run with sh -c. A language recipe's start command |
--port <n…> | ports | An image's ports, or the port a language recipe's app listens on |
--file <path=local…> | files | Written before the command starts, from a local file |
--on-exit <policy> | onExit | Image only: retain (default), or destroy (destroy after final process exit); the run must have no healthcheck |
--restart <policy> | restart | Image only: on-failure (default), or never to leave a failing process stopped (details) |
--ttl <duration> | ttl | Image only: 5m to 30d. The briq is destroyed that long after it was created, whatever its state (details) |
--size <size> | size | pico, micro, nano, small, medium, large or xlarge. Your plan, your key and the recipe can allow fewer: briq whoami lists the key's sizes |
--sleep <sleep> | sleep | 30m, 3h, 7d: a whole number and m, h or d, from 5 minutes to 7 days. Or never, on the Pro plan and above. See Sleep |
--volume-gb <n> | volume.gb | A whole number from 1 to 500, within your plan's disk. With an image, --volume <mount> too |
--volume-from <name> | volume.from | An image, with --volume: start the volume from the team volume of that name: lowercase letters, digits, dots and dashes. An unknown name starts empty |
--volume-publish | volume.publish | With --volume-from: the volume becomes the named volume's next copy when the briq is destroyed after a clean stop |
--checkout <repo> | checkout.repo | A language recipe: github.com/owner/app. --ref, --path |
--token <NAME> | checkout.token | A private repo: the secret holding its token, its value read from $NAME |
--step <command…> | steps | Run before it starts, in order |
-n, --name, -s, --stack | name, stack | |
--expose <mode> | expose | private (behind a token) or public: a URL in the outputs. A recipe may allow only private |
--no-wait | wait: false | Return before the briq is ready |
A field no flag covers (nginx's routes, a healthcheck) goes in a stack file.
briq up
Bring the stack in briq.yaml up: create each service the stack does not have, leave the others.
See Stack file.
$ briq up --secret STRIPE_KEY --env .env.local
stack shop: 3 created, 1 already there
bq_7kq2m9x1p4ab db postgres:16 running …
…
14 values written to .env.local| Option | Notes |
|---|---|
-f, --file <path> | The stack file. Default: briq.yaml in the current directory or a parent |
-s, --stack <name> | Bring it up as this stack instead of the file's stack |
--secret <NAME[=value]…> | The value of a { secret: NAME } of the file. NAME alone reads $NAME. Without it, briq generates one |
--env <file> | Write the outputs into this dotenv file, mode 600 when new |
--expose | Outputs this machine can use: each database gets a TLS endpoint, and the connection strings name it. As fork --expose |
--no-wait | Return before the new briqs are ready |
It prints an endpoint that cannot be opened yet as a warning, and exits with 1 when a briq of
the stack is in error. An agent's permission prompt can allow one command: Bash(briq up:*).
Environment variables
| Variable | What it sets | Default |
|---|---|---|
BRIQ_API_KEY | The key every call uses, over the saved sign-in | none |
BRIQ_API_URL | The API, and so the environment: https://api.stg.briq.cloud for staging, http://localhost:3001 for a local stack | https://api.briq.cloud, or the API of the saved sign-in |
BRIQ_CONFIG_DIR | Where the sign-in is saved | ~/.config/briq ($XDG_CONFIG_HOME/briq) |
The config file holds one sign-in and the API it is for, readable by you only (mode 600).
Exit codes
| Code | Meaning |
|---|---|
0 | Done |
1 | The API refused the call, or could not be reached. The error code comes first: not_found: … |
2 | A wrong command, flag or argument |
3 | Not signed in, or the credential was refused (revoked, expired). Run briq login |
briq exec and briq exec-result exit with the command's own code.
Good to know
briq loginuses the device flow (RFC 8628), as agents on a server do: see Setup for agents.- Prefer piping a key to
--key: a key on the command line stays in your shell history. - A 5xx error prints a
request id. Quote it when you ask for help. - To fork a stack per git branch with hooks, see Give each Claude Code worktree its own database.
Interactive shell
briq shell my-sandboxOpens sh -i in the briq. Its image needs sh. Window resizes and Ctrl-C reach the remote
terminal; exit returns its exit code. Sessions last at most one hour; reaching that limit ends
the shell with a nonzero exit. Closing your terminal closes the connection. A lost connection
ends the session; the CLI also restores your terminal if the server goes silent for 90 seconds.
Run the command again to open a new shell: it never reconnects automatically. Providers without
interactive terminals refuse the request; use briq exec for scripted commands.