No results for ""
EXPAND ALL
  • Home
  • API docs

GIVE DOCS FEEDBACK

LaunchDarkly CLI

Read time: 3 minutes
Last edited: May 16, 2024

Overview

This topic describes how to get started with the LaunchDarkly CLI.

LaunchDarkly provides a command line interface (CLI) so that you can set up and manage your feature flags, account members, projects, environments, teams, and other resources directly from the command line.

Installation

To install the LaunchDarkly CLI:

brew tap launchdarkly/homebrew-tap
brew install ldcli

To update to the latest version of the LaunchDarkly CLI:

brew upgrade ldcli

Common commands in ldcli

To get started with the LaunchDarkly CLI, you need to authenticate with an access token. The config command controls authorization and other configuration values.

Here's how to configure your credentials:

# you only need to run this once
ldcli config --set access-token "<your access token>"

To learn how to create an access token, read API access tokens.

The setup command provides a step-by-step guide to create a flag, install an SDK, and toggle that flag:

ldcli setup

The majority of the LaunchDarkly commands are resource commands. These commands provide direct access to LaunchDarkly APIs.

To view available commands:

ldcli

Input and output formats

For each LaunchDarkly CLI resource command, you can use command line arguments, or use your shell to provide an input file.

For example, here's how to create a flag using data from the command line:

ldcli flags create --project default -d '{"name": "Example flag", "key": "example-flag"}'

Here's how to create the same flag using data from a file:

ldcli flags create --project default -d "$(cat data.json)"

By default, resource commands return a simplified plaintext output. For example, the default output message for creating the new flag in the example above is Successfully created Example flag (example-flag).

To view the full JSON response from any resource command, use the --output json flag. Optionally, pipe the result through jq for improved formatting. Here's how:

ldcli flags create --project default -d '{"name": "Example flag", "key": "example-flag"}' --output json | jq

If you prefer a particular output format, you can use the config command to set that preference:

ldcli config --set output "json" # or "plaintext"

Additional documentation

Use the ldcli [command] --help command to view usage information for all commands for the LaunchDarkly CLI.

To view and contribute to the LaunchDarkly CLI source code, or to file issues for our team, visit the LaunchDarkly CLI GitHub repository.