Reference
CLI Reference
Installation
The StackBlaze CLI is distributed as an npm package. Install it globally to use the stackblaze command from anywhere.
# Install globally (requires Node.js 18+)
$ npm install -g @stackblaze/cli
# Or with pnpm
$ pnpm add -g @stackblaze/cli
# Verify installation
$ stackblaze --version
@stackblaze/cli 2.14.0
# Authenticate
$ stackblaze login
Opening browser for authentication...
Authenticated as alex@acmecorp.com
Global flags
| Flag | Description |
|---|---|
| --project NAME | Target a specific project (overrides active project) |
| --token TOKEN | Use a specific API token (overrides stored credentials) |
| --output json | Output results as JSON instead of human-readable format |
| --no-color | Disable ANSI color codes (useful for CI environments) |
| --debug | Enable verbose debug logging |
| --help | Show help for any command |
| --version | Print the CLI version and exit |
Authentication
| stackblaze login | Authenticate with your StackBlaze account (browser-based OAuth flow) |
| stackblaze login --ssh | Authenticate using an SSH key pair (non-interactive) |
| stackblaze logout | Log out and revoke the local session token |
| stackblaze whoami | Print the currently authenticated user and project |
Deploying
| stackblaze deploy | Deploy the current directory (requires stackblaze.yaml) |
| stackblaze deploy --service NAME | Deploy a specific service by name |
| stackblaze deploy --branch BRANCH | Deploy a specific branch (overrides configured trigger branch) |
| stackblaze deploy --no-wait | Queue the deploy and return immediately without streaming logs |
| stackblaze rollback | Roll back the current service to its previous successful deploy |
| stackblaze rollback --service NAME | Roll back a specific service |
| stackblaze rollback --deployment ID | Roll back to a specific deployment by ID |
Logs
| stackblaze logs | Stream live logs for the current service |
| stackblaze logs --service NAME | Stream logs for a specific service |
| stackblaze logs --tail 100 | Show the last 100 lines then exit |
| stackblaze logs --since 1h | Show logs from the past hour (supports: 1h, 30m, 2d) |
| stackblaze logs --level error | Filter to error-level log lines only |
Environment variables
| stackblaze env list | List all environment variables for the current service |
| stackblaze env list --service NAME | List env vars for a specific service |
| stackblaze env set KEY=VALUE | Set a plain environment variable |
| stackblaze env set KEY=VALUE --secret | Set a secret (encrypted, redacted in UI) |
| stackblaze env unset KEY | Remove an environment variable |
| stackblaze env import .env | Import all variables from a .env file |
Services
| stackblaze ps | List all running services and their status |
| stackblaze open | Open the current service URL in your browser |
| stackblaze open --service NAME | Open a specific service URL |
| stackblaze run "COMMAND" | Run a one-off command in a temporary container (same image as service) |
| stackblaze run --service NAME "COMMAND" | Run a command in a specific service's container |
| stackblaze scale --replicas N | Scale a service to N replicas |
Project
| stackblaze init | Create a stackblaze.yaml configuration file in the current directory |
| stackblaze up | Apply a stackblaze.yaml blueprint to create or update services |
| stackblaze down | Destroy all services defined in the local stackblaze.yaml |
| stackblaze status | Show the full status of all project services |
Running one-off commands
stackblaze run spins up a temporary container using your service's current Docker image and runs the specified command inside it. The container is destroyed after the command exits. All environment variables configured for the service are injected.
# Run database migrations
$ stackblaze run --service my-api "npx prisma migrate deploy"
Running command in temporary container...
3 migrations applied successfully
# Open a Rails console
$ stackblaze run --service rails-app "rails console"
# Seed the database
$ stackblaze run --service my-api "node scripts/seed.js"
Using the CLI in CI/CD
In CI environments, authenticate using an API token rather than browser OAuth. Set the STACKBLAZE_TOKEN environment variable or pass --token to any command. All commands support --output json for machine-readable output.
# In your CI environment:
export STACKBLAZE_TOKEN=sb_live_xxxxxx
$ stackblaze deploy --service my-api --no-wait
$ stackblaze run --service my-api "npx prisma migrate deploy"