Install the CLI
Overview
Contentstack CLI can be installed in macOS, Windows and Linux environments. In this guide, you will learn how to install and update command-line interface (CLI).
Warning During an npm install or update the csdx binary is briefly unavailable, for roughly 30 seconds on a typical machine. A CI pipeline that installs the CLI and invokes it in the very next step can fail with a command-not-found error. Add a readiness check such as csdx --version with a short retry loop rather than assuming the binary is ready the moment the install command exits.
Prerequisites
Install CLI
To install CLI as a global module in your machine, open your terminal (command prompt) and run this command:
npm install -g @contentstack/cli
Once the CLI is successfully installed, you can use the csdx command from your terminal.
The csdx is a top-level namespace in Contentstack that gives you access to Contentstack's extensive range of commands and functionalities.
Additional ResourceVisit our CLI GitHub page for more information. You can also read about Contentstack CLI on the npm page.
Next, let us verify the CLI installation.
Verify installation
Verify your installation by running the following command in your terminal to get a list of commands that will help you to interact with Contentstack.
csdx --help
C:\Users\vxxxh>csdx --help ____ _ _ _ _ / ___|___ _ __ | |_ ___ _ __ | |_ ___| |_ __ _ ___| | __ | | / _ \| '_ \| __/ _ \ '_ \| __/ __| __/ _` |/ __| |/ / | |__| (_) | | | | || __/ | | | |_\__ \ || (_| | (__| < \____\___/|_| |_|\__\___|_| |_|\__|___/\__\__,_|\___|_|\_\ Command-line tool (CLI) to interact with Contentstack VERSION @contentstack/cli/<cli-version> win32-x64 node-v22.11.0 USAGE $ csdx [COMMAND] TOPICS auth Perform authentication-related activities cm Perform content management activities config Perform configuration related activities plugins List installed plugins COMMANDS help Display help for csdx. plugins List installed plugins.
As shown in the above code, the help namespace contains other namespaces within it.
Let us understand these namespaces in detail.
Namespaces
Namespace is used to categorize commands as per their functionality or purpose.
The following namespaces exist within the csdx command:
- auth: To perform authentication-related activities.
- cm: To perform content management activities such as bulk publish, bulk unpublish, import, export, export-to-csv, branches, and migration content.
- help: To list useful commands in the CLI.
- launch: To perform Launch related operations. This namespace is available after you install the Launch plugin with csdx plugins:install @contentstack/cli-launch.
- plugins: To list the installed plugins.
- config: To perform configuration related activities in the CLI.
Note To build your own plugin for csdx, see Create Custom CLI Plugins for Contentstack. The CLI is built on oclif, so the oclif plugin documentation applies as well.
Here are the commands within each namespace:
- auth
- cm
- cm:branches:create
- cm:branches:delete
- cm:branches:diff
- cm:branches:merge
- cm:stacks:bulk-assets
- cm:stacks:bulk-entries
- cm:stacks:bulk-taxonomies
- cm:entries:migrate-html-rte (after you install @contentstack/cli-cm-migrate-rte)
- cm:stacks:export
- cm:export-to-csv
- cm:stacks:import
- cm:stacks:clone
- cm:stacks:migration
- cm:stacks:seed
- cm:stacks:audit
- cm:stacks:audit:fix
- launch (after you install @contentstack/cli-launch)
- config
Refer the section below to check the CLI version on your machine and update it to use the latest version.
Check CLI Version
To check the current version of CLI installed on your machine, run this command in the terminal:
csdx --version
Running this command will display the current version, as shown below:
C:\Users\vxxxh>csdx --version @contentstack/cli/<cli-version> win32-x64 node-v22.11.0
Update CLI Version
As mentioned above, you can check the version of CLI installed on your machine.
To get the latest version of CLI, run the following command in your terminal:
npm update -g @contentstack/cli
Next Steps
- Migrate from Contentstack CLI V1 to V2: if you used CLI 1.x, review the removed commands and flags before you run your existing scripts.
- CLI Authentication and Adding Tokens: log in and add a management token before running any command.
- Create Custom CLI Plugins for Contentstack: build and publish your own csdx commands.