View available commands
The majority of the LaunchDarkly CLI commands are resource commands. These commands provide direct access to LaunchDarkly APIs. To view available commands:Set 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: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:
config command to set that preference:
Example: create and manage experiments
You can use the CLI to create and manage experiments. For example, here’s how to create an experiment using data from the command line:Access SDK credentials
You can access the default SDK credentials for a specific project and environment using theenvironments resource. You need different SDK credentials depending on which SDK you’re working with. To learn more about SDK credentials, read Keys and credentials.
Here’s how:
Use ldcli for local development
The LaunchDarkly CLI includes a dev-server command that you can use to start a local server, retrieve flag values from a LaunchDarkly source environment, and update those flag values locally. This means you can test your code locally, without having to coordinate with other developers in your organization who are using the same LaunchDarkly source environment.
To learn more, use ldcli dev-server --help or read our guides, Using the LaunchDarkly CLI for local testing and LaunchDarkly CLI dev-server reference.
Use ldcli for uploading sourcemaps
The LaunchDarkly CLI includes a sourcemaps command that you can use to upload JavaScript sourcemaps to LaunchDarkly. This means your sourcemaps are available when you access error monitoring in the LaunchDarkly UI. You must be using the Observability plugin with the JavaScript SDK to use the error monitoring feature.
Here’s how to upload your JavaScript sourcemap:
sourcemaps upload command uploads a local version of your sourcemap to LaunchDarkly. To use the command, you must have generated sourcemaps for your project. Exactly how to do this depends on your target environment and JavaScript configuration. Bundlers such as babel, webpack, esbuild, and rollup all provide different ways to enable sourcemap generation. Refer to the documentation for your specific bundler to generate production-ready sourcemaps.
The app-version option takes a string that should match the version you include in the observability plugin options.
The path option defaults to ./build. The command uploads any .map files in the directory specified here.
The base-path option ensures that LaunchDarkly stores the sourcemaps at an appropriate location corresponding to your application’s deployment. For example, suppose your sourcemap file is in ./build/myApp and that when you deploy your app, your code runs from ./dist/myApp. You should provide --path ./build/myApp --basePath ./dist/myApp.
The project option is the LaunchDarkly project key.
If your sourcemap is inline, meaning it’s already shipped as part of your application, then you do not need to upload anything to LaunchDarkly.
To learn more, use ldcli sourcemaps --help.
Use ldcli for uploading symbols
The LaunchDarkly CLI includes a symbols command that you can use to upload mobile application symbol files to LaunchDarkly. When symbol files are available, LaunchDarkly can display readable stack traces on the Errors page for obfuscated, minified, or compiled builds. This feature requires that you use an observability plugin for a supported mobile SDK.
Comparing symbols to sourcemapsThe
symbols upload command is distinct from sourcemaps upload, although both commands provide similar functionality. symbols upload uses a dedicated upload path built for large, multi-segment symbol files. It also keys each upload by a deterministic symbols ID rather than an application version. Always use symbols upload for mobile applications and sourcemaps upload for JavaScript web applications.type option identifies the mobile platform for which you are uploading symbols. LaunchDarkly supports react-native, android, ios, and flutter.
The path option points to the directory that contains your symbol files. For Android build environments, you can omit the path option if you run the symbols upload command from your project root.
ldcli automatically reads the symbols ID from your build environment, either from a *.symbolsid sidecar file (React Native) or from other files in the build directory. If the CLI cannot determine the symbols ID, use the --symbols-id option to provide it.
The project option is the LaunchDarkly project key.
To learn more, use ldcli symbols --help.
Find additional documentation
LaunchDarkly provides the following additional documentation:- For information on how to get started with the LaunchDarkly CLI, read LaunchDarkly CLI.
- For details on how to use the LaunchDarkly CLI to perform local testing and development, read Using the LaunchDarkly CLI for local testing and LaunchDarkly CLI dev-server reference.
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.