The commercetools CLI is a unified command-line interface for managing your Projects and resources.
commercetools) is an open-source command-line tool for developers, operators, and AI coding agents. It lets you work with commercetools APIs directly from the terminal. The CLI groups its commands into topics, and each topic covers a different API surface.Topics and commands
| Topic or command | Description |
|---|---|
auth | Authenticates and shows the active session |
sphere | Manages API resources |
integration-layer | Authors, runs, and publishes Commerce Integration Layer extensions (installed as a plugin) |
connect | Manages Connect deployments and connectors |
import | Manages Import API containers, operations, and summaries |
ai | Installs the commercetools AI plugin into your coding agent |
doctor | Checks the installation, authentication, and AI agent setup |
plugins | Installs, lists, and removes optional topics |
Installation
The CLI is distributed via npm. It requires one of these Node.js versions:
- 22.23.4 or later on the 22 line
- 24.22.1 or later on the 24 line
- 26.12.1 or later
npm install -g @commercetools/cli
Verify the installation:
commercetools --version
Authentication
All commands that interact with commercetools APIs require an authenticated session. This section is the single place where authentication is described, and the topic pages link here.
Create an API Client in the Merchant Center, then run the login command once. Your credentials are persisted locally.
commercetools auth login \
--client-credentials \
--client-id <client-id> \
--client-secret <client-secret> \
--project-key <project-key> \
--region <region>
--region flag takes the Region of your Project, for example europe-west1.gcp. Use the optional --scope flag to request specific scopes for the access token.integration-layer topic needs the manage_project scope. If a command needs a session and you are not logged in, it stops and tells you to run commercetools auth login.To view the active session:
commercetools auth whoami
--json to print the session as JSON, for example {"authenticated": true, "projectKey": "my-project", ...}. When no session exists, the output is {"authenticated": false}.Authenticate in CI
In CI pipelines, keep the client credentials in your secret store, such as GitHub Secrets or another secret manager. Expose them to the step as environment variables. Do not write them into scripts or commit them to your repository.
- name: Log in to commercetools
env:
CLIENT_ID: ${{ secrets.CTP_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CTP_CLIENT_SECRET }}
PROJECT_KEY: ${{ secrets.CTP_PROJECT_KEY }}
run: |
npm install -g @commercetools/cli
commercetools auth login --client-credentials \
--client-id "$CLIENT_ID" --client-secret "$CLIENT_SECRET" \
--project-key "$PROJECT_KEY" --region europe-west1.gcp
Common flags
--help, which displays the usage, flags, and examples of the command.Commands that are meant to be scripted or run by AI agents also support these flags:
| Flag | Description | Available on |
|---|---|---|
--json | Print machine-readable JSON | auth whoami, doctor, ai install, plugins |
--dry-run | Show what would happen without changing anything | ai install, connect deployment delete |
--yes | Skip the confirmation prompt | connect deployment delete |
Output format
sphere and import topics output pretty-printed JSON, which makes them easy to compose with tools like jq:commercetools sphere products list --limit 5 | jq '.results[].key'
connect topic prints human-readable output such as tables and logs.Plugins
integration-layer topic:commercetools plugins install @commercetools/cli-topic-integration-layer
integration-layer topic reference:commercetools integration-layer --help
To list the installed plugins or remove one:
commercetools plugins
commercetools plugins uninstall @commercetools/cli-topic-integration-layer