CLI
The stackblaze CLI deploys and operates your apps from a terminal or CI. It is a client for the same REST API the dashboard uses, so it can only do what your account or token is allowed to do.
Every command prints its own help: stackblaze --help, stackblaze <command> --help and stackblaze <command> <subcommand> --help. The command reference below covers every command, flag and example.
Install
The installers download a standalone binary. No Node.js is needed, and there is no npm package.
curl -fsSL https://stackblaze.com/install.sh | shirm https://stackblaze.com/install.ps1 | iexbrew tap stackblaze/tap && brew install stackblazeOn Linux and macOS the binary goes to ~/.local/bin (or /usr/local/bin when run as root); on Windows to %LOCALAPPDATA%\StackBlaze\bin, which is added to your user PATH. If Homebrew refuses to load the formula from an untrusted tap, run brew trust --tap stackblaze/tap once and install again.
| Installer variable | Purpose |
|---|---|
STACKBLAZE_VERSION | Install a specific version, e.g. 1.0.0 (default: newest on the channel) |
STACKBLAZE_CHANNEL | stable (default) or dev (prereleases) |
STACKBLAZE_INSTALL_DIR | Install location (both installers) |
INSTALL_DIR | Older install.sh name for the install location; STACKBLAZE_INSTALL_DIR wins when both are set |
Update with stackblaze upgrade, or brew upgrade stackblaze for a Homebrew install. See upgrade.
Authenticate
stackblaze loginlogin prints a one-click URL and a code, opens your browser, and waits until you approve. The token is saved to ~/.config/stackblaze/config.json on macOS and Linux (under $XDG_CONFIG_HOME/stackblaze when that is set) and to %APPDATA%\StackBlaze\config.json on Windows, with mode 600; override the path with STACKBLAZE_CONFIG. On a server or over SSH, use stackblaze login --browserless. With an API token, use stackblaze login --token kbr_pat_…; with email and password (2FA supported, terminal only), stackblaze login --password.
Create API tokens in the dashboard under Settings → API tokens. A token belongs to your organization and carries your permissions. In CI, skip login and set both variables; commands read them on every run:
export STACKBLAZE_API_URL=https://api.stackblaze.cloud
export STACKBLAZE_TOKEN=kbr_pat_…
stackblaze whoamiFlags (--token, --api-url) override the environment, which overrides the saved login.
Quick start
stackblaze init # create a project and link this directory
stackblaze up # create the app and stream the build
stackblaze logs -f # follow the app's logs
stackblaze open # open the app's dashboard page (--app-url opens the app)In a git checkout with a remote, up builds the remote and current branch, not local files, so push first. In a folder without a git remote (or with --local) it uploads the folder and builds that. Run up again to ship changes. See up.
stackblaze init creates and links the project; stackblaze up builds the pushed branch and streams the build.
Scope and common flags
Most commands act on one app, identified by a project, an environment and an app. They are resolved in this order:
- Flags:
-p, --project,-e, --env,-a, --app - Environment:
STACKBLAZE_PIPELINE,STACKBLAZE_PHASE,STACKBLAZE_APP - The nearest
.stackblaze/project.json, searching upward from the current directory (written byinit,linkandup)
The CLI says project and environment, and so do its flags; --pipeline and --phase still work. The variables and the keys in JSON output keep the API's names, pipeline and phase. When the environment is still unknown, app commands use production. Run stackblaze context to see what resolves.
Global options
These work on every command that uses them. --api-url, --token, --org and -y also go before the command name: stackblaze --org acme apps list.
| Option | Purpose |
|---|---|
--api-url <url> | API base URL (env STACKBLAZE_API_URL) |
--token <token> | API token, kbr_pat_… (env STACKBLAZE_TOKEN) |
--org <slug> | Run this one command in another organization (not saved; see orgs switch) |
-p, --project <name> | Project (env STACKBLAZE_PIPELINE; --pipeline still works) |
-e, --env <name> | Environment, default production (env STACKBLAZE_PHASE; --phase still works) |
-a, --app <name> | App (env STACKBLAZE_APP) |
--json, -o json | Print one JSON document on stdout |
-y, --yes | Never ask for confirmation |
Note
up, apps create, apps update and templates deploy, --env KEY=value sets variables, so pass the environment with --phase there.When stdin is not a terminal (CI, pipes, AI agents), the CLI never prompts: a command that would ask fails at once with exit 1 and changes nothing. Pass -y to confirm, or the value as a flag.
Output and exit codes
Results go to stdout. Progress, prompts, warnings and errors go to stderr, so you can pipe a result without catching progress messages. With -o json (or --json), stdout carries only the JSON result:
stackblaze apps list -o json | jq -r '.[].app'Streaming commands write one JSON record per line (NDJSON) instead: up --ci, builds logs --ci, logs -f --json, cron logs -f --json, metrics --watch --json, and --ci on cron run and addons backups create|restore. Commands that take --wait print one JSON document with --wait --json, with the readiness check under wait; a wait that does not end with the app running exits 1. Interactive commands (ssh, shell, connect, run) and local tooling (setup, completion, upgrade, docs) have no JSON mode. Set NO_COLOR=1 to turn off colour.
| Exit code | Meaning |
|---|---|
| 0 | Success |
| 1 | Usage or validation error, failed build or deploy, an app that did not become ready, or a declined confirmation |
| 2 | Missing or invalid credentials: no token, HTTP 401, or a wrong login password. Log in again |
| 3 | The API refused or failed the request: any other 403 (permission, a feature switched off for your organization, a suspended account), 402 upgrade required, another API error, an unreachable API, or a timeout. The server's message is printed |
| 127 | stackblaze run: the local command was not found |
A 403 means you are signed in and the request was refused, so it exits 3, not 2. With --json, an error is printed on stderr as one JSON document, {"error":{"message":…,"code":…,"status":…}}, with the same exit codes. Commands that wait (--wait, wait) take --timeout <seconds> (default 600 unless the command says otherwise).
Destructive commands ask for confirmation. Without a terminal the prompt gets no answer and the command exits 1 without changing anything, so pass -y in scripts. stackblaze run exits with the code of the command it runs (127 when the program is not found), and ssh with the code of the remote shell.
Environment variables
| Variable | Purpose |
|---|---|
STACKBLAZE_TOKEN | API token, required when there is no saved login |
STACKBLAZE_API_URL | API base URL (default https://api.stackblaze.cloud) |
STACKBLAZE_PIPELINE, STACKBLAZE_PHASE, STACKBLAZE_APP | Default project, environment and app |
STACKBLAZE_CONFIG | Path of the saved login file |
XDG_CONFIG_HOME | Linux and macOS: the config directory becomes $XDG_CONFIG_HOME/stackblaze |
STACKBLAZE_HTTP_TIMEOUT | Seconds per request (default 60; 0 disables) |
STACKBLAZE_HTTP_RETRIES | Extra attempts for read requests (default 2) |
STACKBLAZE_BUILD_STREAM | Set to poll to follow builds by polling instead of the live stream |
STACKBLAZE_DASHBOARD_URL | Dashboard address used by open |
NO_COLOR | Set to 1 to turn off colour |
CI and GitHub Actions
stackblaze up is safe to re-run, so the same command works on every push: the first run creates the app, later runs update it and build again. With --ci it streams the build as NDJSON, and the job fails when the build fails.
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
env:
STACKBLAZE_API_URL: https://api.stackblaze.cloud
STACKBLAZE_TOKEN: ${{ secrets.STACKBLAZE_TOKEN }}
STACKBLAZE_PIPELINE: my-project
STACKBLAZE_PHASE: production
STACKBLAZE_APP: web
steps:
- uses: actions/checkout@v4
- name: Install StackBlaze CLI
run: |
curl -fsSL https://stackblaze.com/install.sh | sh
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Deploy
run: stackblaze up --ci --waitKeep the actions/checkout step: up reads the repository and branch from the checkout, and builds exactly the pushed commit (the pull request's head commit on pull_request events). The very first build of a brand-new app uses the head of the branch. --wait also waits up to 10 minutes for the new version to be running; drop it to finish when the build succeeds. If the app already auto-deploys on push, you do not need this workflow.
up --ci records
| type | Fields | When |
|---|---|---|
| deploy | pipeline, phase, app, mode (git, upload or docker), action (created or updated), changed, plus source details | Once, after the app is created or updated |
| build | build, state; the final record also has success | First seen, then on every state change |
| log | build, container, message | Each build log line, as it is written |
| error | message | The build failed or timed out |
| status | ready, pipeline, phase, app, and when known phaseStatus, url, message, failed, timedOut | With --wait, after the build |
| status | state: submitted, ready: null, pipeline, phase, app | Image deploys without --wait: the deploy was accepted, nothing checked that it runs |
Tip
Command reference
Deploy and builds
Deploy a folder, a git repository or an image, follow builds, and roll back.
up · deploy · redeploy · restart · wait · builds · deployments · inspect
Variables and environment
Manage environment variables, stage changes, and run local commands with an app's variables.
variables · pending · env pull · run · shell
Scaling and pausing
Set replicas and autoscaling, or pause an app and bring it back as it was.
scale · down · resume
Scheduled tasks
List, run, follow, create and remove an app's scheduled tasks.
cron
Logs and debugging
Read and search logs, check resource use, diagnose problems, and open a shell in your app.
logs · metrics · events · diagnose · ssh
Databases and add-ons
Attach managed services and open a database shell through a private tunnel.
connect · addons · addons backups · addons expose
Domains and App Shield
Add custom domains with automatic HTTPS, and turn on the per-app web application firewall.
domain · waf · cdn purge
Backups and restore
Recovery points of a whole environment: back up now, restore in place or as copies.
backups
Volumes, files and snapshots
Attach persistent volumes, work with the files on them, and snapshot them.
volume · files · snapshots
Templates
Deploy apps from the template catalog.
templates
Projects and apps
Create and link projects, manage environments, and manage apps directly.
init · link · unlink · context · projects · phases · apps · open
Infrastructure as Code
Export projects and apps as manifests, preview changes, apply them, and tear them down.
status · export · plan · apply · destroy
AI agent and MCP
Chat with the StackBlaze agent from your terminal and set up coding tools.
agent · setup
Account and tooling
Sign in and out, switch organizations, manage API tokens and members, call the API, read the audit log and billing, and keep the CLI up to date.
login · logout · whoami · orgs · tokens · members · api · audit · billing · completion · upgrade · docs