Get started

Version: 3.4

This topic provides information about how to install and configure Sitecore Content Hub command-line interface (CLI) on the supported platforms.

Installation

First steps

Note

Depending on the installation method or operation system, ch-cli in the following examples might need to be replaced with one of the following:

  • Windows: ch-cli.exe
  • macOS or Linux: ./ch-cli
  • Docker: docker run --rm -it -v ch-cli-data:/root/.ch-cli scr.sitecore.com/sch/ch-cli

Help

The --help option is available on all levels and helps you to explore the available commands or options.

Examples

Get an overview of the available commands and options on the root level:

RequestResponse
ch-cli --help

Narrow down the help output to the login command:

RequestResponse
ch-cli endpoint --help

Login

To interact with your Sitecore Content Hub instance, you need to log in first.

After you execute the login command, you are redirected to the specified Sitecore Content Hub instance and, once logged in, can grant permissions to the client. Available commands include:

RequestResponse
ch-cli endpoint add --name <name> --url https://your.content.hub.url/ --client-id <OAuth client ID> --client-secret <OAuth client secret>
Important

The redirect URL of the OAuth client and the one in the CLI need to be an exact match. The default is http://localhost:9000/, but can be overridden using the --redirect-uri argument:
ch-cli endpoint add --name <name> --url https://your.content.hub.url/ --client-id <OAuth client ID> --client-secret <OAuth client secret> --redirect-uri http://localhost:9123/

Once executed, you are redirected to the specified Sitecore Content Hub instance to grant permissions to the client. If you accept, you are logged in and can start executing commands, otherwise not.

Breakdown

  • name - is a unique identifier that allows you to manage multiple connections to different instances (for example, staging and production or entirely different projects/customers).
  • url - is the base URL to your instance.
  • client-id - the OAuth client ID that you want to use for the authentication flow.
  • client-secret - the client secret for the specified OAuth client.
  • redirect-uri - allows to override the redirect URL to complete the authorization (optional).

Configuration

All CLI related configuration is stored in JSON files in the .ch-cli directory, in the current user's directory:

OSPath
Windows%USERPROFILE%\.ch-cli
Linux/macOS$HOME/.ch-cli
Docker<your volume>

Do you have some feedback for us?

If you have suggestions for improving this article,