| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Command-line interface for the GrowthBook REST API.
The recommended way to install is via npm, which installs a small launcher that downloads the prebuilt binary for your platform:
npm i -g growthbookPrefer a standalone binary with no Node.js dependency? An install script, go install, and prebuilt downloads are covered under CLI Installation below.
This CLI follows semantic versioning: breaking changes ship only in a major release and are called out in the changelog. Additive changes (new commands, flags, or response fields) are minor releases; fixes are patch releases. We recommend pinning to a version you have tested.
The CLI checks for a newer release at most once a day and prints a one-line notice to stderr (never stdout) when one is available and compatible with your server. Disable it with --no-update-check or GBCLI_NO_UPDATE_CHECK=1; it is also off automatically in CI and non-interactive shells.
Each command group targets the newest version of its API endpoint — e.g. features is the latest (v2) feature API. When a command is superseded, the previous version stays available under a version suffix (e.g. features-v1), deprecated and printing a one-line notice to stderr. When a newer API version lands, the base group advances to it and the prior version becomes the next -vN.
Because the bare command then returns the newer version's response shape, re-pointing a base command is a breaking change: it ships as a major release with the change called out in the changelog — so you can pin the prior major or move to the explicit -vN command on your own schedule.
GrowthBook REST API: A command-line interface for GrowthBook — manage feature flags, experiments, metrics, and more from your terminal.
Endpoints are versioned by path prefix: /v1 (stable) and /v2 (improved shapes). Each command group targets the newest version of its endpoint; superseded versions remain available under a -vN suffix.
Authenticate with a Secret Key or Personal Access Token via --bearer-auth (or the GBCLI_BEARER_AUTH environment variable). Run growthbook configure to store credentials, or growthbook whoami to check the active configuration.
curl -fsSL https://raw.githubusercontent.com/growthbook/cli/main/scripts/install.sh | bashiwr -useb https://raw.githubusercontent.com/growthbook/cli/main/scripts/install.ps1 | iexAlternatively, install directly via Go:
go install github.com/growthbook/cli/v2/cmd/growthbook@latestDownload pre-built binaries for your platform from the releases page.
Shell completions are available for Bash, Zsh, Fish, and PowerShell.
# Add to ~/.bashrc:
source <(growthbook completion bash)
# Or install permanently:
growthbook completion bash > /etc/bash_completion.d/growthbook# Add to ~/.zshrc:
source <(growthbook completion zsh)
# Or install permanently:
growthbook completion zsh > "${fpath[1]}/_growthbook"growthbook completion fish | source
# Or install permanently:
growthbook completion fish > ~/.config/fish/completions/growthbook.fishgrowthbook completion powershell | Out-String | Invoke-Expressiongrowthbook get-SDK-payload --bearer-auth 'Bearer test_token' --key '<key>'
Authentication credentials can be configured in four ways (in order of priority):
Pass credentials directly as flags to any command:
growthbook --bearer-auth <value> --username <value> --password <value> <command> [arguments]Set credentials via environment variables:
| Variable | Description |
|---|---|
| GBCLI_BEARER_AUTH | Bearer auth token: your Secret Key or Personal Access Token, sent as an Authorization Bearer header. |
| GBCLI_USERNAME | HTTP Basic auth: use your GrowthBook Secret Key as the username and leave the password empty. username |
| GBCLI_PASSWORD | HTTP Basic auth: use your GrowthBook Secret Key as the username and leave the password empty. password |
Credentials are stored securely in your operating system's keychain when you run:
growthbook configureSecret credentials (tokens, API keys, passwords) are automatically stored in:
If no keychain is available (e.g., in CI environments), credentials fall back to the config file.
Run the interactive configure command to store non-secret settings:
growthbook configureConfiguration is stored in ~/.config/growthbook/config.yaml.
Profiles let you switch between GrowthBook environments (e.g. cloud, staging, self-hosted), each with its own server URL and API key. Keys are stored in your OS keychain, not in plaintext config.
# Create or update a profile (the key comes from --bearer-auth, stored in the keychain)
growthbook profiles set staging --server-url https://gb.staging.example.com/api --bearer-auth secret_xxx
growthbook profiles use staging # make it the active profile
growthbook profiles list # show configured profiles
growthbook profiles remove staging # delete oneSelect a profile for a single command with --profile <name>, or set GBCLI_PROFILE in your environment. (Upgrading from the legacy CLI? An existing ~/.growthbook/config.toml is imported into profiles automatically on first run — see MIGRATION.md.)
generate-types fetches all of your features and writes a TypeScript AppFeatures definition, giving you type-safe feature keys and values in the GrowthBook SDK:
growthbook generate-types # → ./growthbook-types/app-features.ts
growthbook generate-types --output ./src/types --filename growthbook.ts
growthbook generate-types --project prj_123 # limit to one projectOperations that accept a request body support three input methods, with a clear priority chain:
growthbook <command> --name "Jane" --age 30Provide the entire request body as a JSON string:
growthbook <command> --body '{"name": "John", "age": 30}'Individual flags override --body values:
# Result: {name: "Jane", age: 30}
growthbook <command> --body '{"name": "John", "age": 30}' --name "Jane"Pipe JSON into any command that accepts a request body:
echo '{"name": "John", "age": 30}' | growthbook <command>Individual flags override stdin values:
# Result: {name: "Jane", age: 30}
echo '{"name": "John", "age": 30}' | growthbook <command> --name "Jane"This is useful for chaining commands, reading from files, or scripting:
# Read body from a file
growthbook <command> < request.json
# Pipe from another command
curl -s https://example.com/data.json | growthbook <command>When multiple input methods are used, the priority is:
| Priority | Source | Description |
|---|---|---|
| 1 (highest) | Individual flags | --name "Jane" always wins |
| 2 | --body flag | Whole-body JSON via flag |
| 3 (lowest) | Stdin | Piped JSON input |
Use --server <index> to select a server by its zero-based index (default: 0):
| # | Server | Variables | Description |
|---|---|---|---|
| 0 | https://api.growthbook.io/api | GrowthBook Cloud | |
| 1 | https://{domain}/api | domain | Self-hosted GrowthBook |
growthbook --server <index> <command> [arguments]Some server URLs contain template variables (e.g., https://{hostname}:{port}/v1). Set these via dedicated flags:
| Variable | Flag | Default | Description |
|---|---|---|---|
| domain | --domain <value> | "localhost:3100" | Your self-hosted GrowthBook host (and port) |
growthbook --domain value <command> [arguments]Server variable flags are combined with the selected server URL to produce the final endpoint.
Use --server-url to override the server URL entirely, bypassing any named or indexed server selection:
growthbook --server-url https://custom-api.example.com <command> [arguments]Precedence: --server-url > --server > default
Every command supports a --output-format flag that controls how the response is rendered to stdout.
| Format | Flag | Description |
|---|---|---|
| Pretty | --output-format pretty (default) | Aligned key-value pairs with color, nested indentation. Human-readable at a glance. |
| JSON | --output-format json | JSON output. Passthrough when the response is already JSON (preserves original field order and numeric precision). Falls back to typed marshaling otherwise. |
| YAML | --output-format yaml | YAML output via standard marshaling. |
| Table | --output-format table | Tabular output for array responses. |
| TOON | --output-format toon | Token-Oriented Object Notation — a compact, line-oriented format that typically uses 30–60% fewer tokens than JSON. Well-suited for piping responses into LLM prompts. |
# Default pretty output
growthbook <command>
# Machine-readable JSON
growthbook <command> --output-format json
# TOON for LLM-friendly compact output
growthbook <command> --output-format toon
# Pipe JSON to jq without using --output-format
growthbook <command> --output-format json | jq '.fieldName'Use --jq to filter or transform the response inline using a jq expression. This always outputs JSON and overrides --output-format:
# Extract a single field
growthbook <command> --jq '.name'
# Filter an array
growthbook <command> --jq '.items[] | select(.active == true)'Use --color to control terminal colors:
| Value | Behavior |
|---|---|
| auto (default) | Color when stdout is a TTY, plain text otherwise |
| always | Always colorize |
| never | Never colorize |
The NO_COLOR and FORCE_COLOR environment variables are also respected.
When using --all (pagination) or streaming operations, output is written incrementally as items arrive:
| Format | Streaming behavior |
|---|---|
| json | One compact JSON object per line (NDJSON) |
| yaml | YAML documents separated by --- |
| toon | One TOON-encoded object per block, separated by blank lines |
| pretty (default) | Pretty-printed items separated by blank lines |
Some operations in this CLI support automatic pagination. These operations accept --all to automatically fetch all pages and stream results incrementally.
# Fetch a single page (default behavior)
growthbook <command> --page 1
# Automatically fetch all pages
growthbook <command> --allUse --max-pages to cap the number of pages fetched:
# Fetch at most 5 pages
growthbook <command> --all --max-pages 5When using --all, results are streamed as each page is fetched:
| Format | Behavior |
|---|---|
| --output-format json | One JSON object per line (NDJSON) |
| --output-format yaml | YAML documents separated by --- |
| --output-format toon | One TOON-encoded block per item, separated by blank lines |
| Default (pretty) | Pretty-printed items separated by blank lines |
# Stream all results as NDJSON
growthbook <command> --all --output-format json
# Pipe to jq for further processing
growthbook <command> --all --output-format json | jq '.fieldName'
# Use the built-in --jq flag
growthbook <command> --all --jq '.fieldName'Under the hood, --all calls the operation once, then follows the underlying Next() pagination closure to fetch subsequent pages. Results are written to stdout as they arrive rather than buffered in memory, so this works well even with large result sets.
Without --all, paginated operations behave like any other command — pass cursor, page, offset, or limit flags manually and get a single page of results.
The CLI uses standard exit codes to indicate success or failure:
| Exit Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (API error, invalid input, etc.) |
On success, the response data is printed to stdout as JSON. On failure, error details are printed to stderr.
# Capture output and handle errors
growthbook ... > output.json 2> error.log
if [ $? -ne 0 ]; then
echo "Error occurred, see error.log"
fiThe CLI includes two diagnostic flags available on all commands:
Preview what would be sent without making any network calls:
growthbook <command> --dry-runOutput goes to stderr and includes:
The command exits successfully without contacting the API. This is useful for verifying request construction before executing.
Log request and response diagnostics while running normally:
growthbook <command> --debugDebug output goes to stderr and includes:
The command still executes normally and produces its regular output on stdout.
If both --dry-run and --debug are set, --dry-run takes precedence and no network calls are made.
Sensitive information is automatically redacted in diagnostic output:
Diagnostic output should still be treated as potentially sensitive operational data.
This CLI follows semantic versioning and a stable command-versioning convention — see Versioning and stability at the top of this README. We recommend pinning to a version you have tested.
While we value open-source contributions to this CLI, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
| Back | FazBrowse Home | New Git URL |