# CLI overview

**The commercetools CLI is a unified command-line interface for managing your Projects and resources.**

The commercetools CLI (`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`](/dev-tooling/cli/overview.md#authentication) | Authenticates and shows the active session |
| [`sphere`](/dev-tooling/cli/sphere.md) | Manages API resources |
| [`integration-layer`](/dev-tooling/cli/integration-layer.md) | Authors, runs, and publishes Commerce Integration Layer extensions (installed as a plugin) |
| [`connect`](/dev-tooling/cli/connect.md) | Manages Connect deployments and connectors |
| [`import`](/dev-tooling/cli/import.md) | Manages Import API containers, operations, and summaries |
| [`ai`](/dev-tooling/cli/ai-agents.md) | Installs the commercetools AI plugin into your coding agent |
| [`doctor`](/dev-tooling/cli/ai-agents.md#check-your-setup-with-doctor) | Checks the installation, authentication, and AI agent setup |
| [`plugins`](/dev-tooling/cli/overview.md#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

```bash title="Install the CLI"
npm install -g @commercetools/cli
```

Verify the installation:

```bash title="Check the CLI version"
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.

```bash title="Log in with client credentials"
commercetools auth login 
  --client-credentials 
  --client-id <client-id> 
  --client-secret <client-secret> 
  --project-key <project-key> 
  --region <region>
```

The `--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.

Give the API Client the scopes that the commands need. For example, the [`integration-layer`](/dev-tooling/cli/integration-layer.md) 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:

```bash title="Show the active session"
commercetools auth whoami
```

Add `--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.

```yaml title="GitHub Actions example"
- 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

Every command accepts `--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

The `sphere` and `import` topics output pretty-printed JSON, which makes them easy to compose with tools like `jq`:

```bash title="Pipe output to jq"
commercetools sphere products list --limit 5 | jq '.results[].key'
```

The `connect` topic prints human-readable output such as tables and logs.

## Plugins

Some topics are not bundled with the CLI. You can add them at runtime as plugins. For example, to install the `integration-layer` topic:

```bash title="Install the integration-layer topic"
commercetools plugins install @commercetools/cli-topic-integration-layer
```

After the installation, the commands of the topic are available like any other command. See the [`integration-layer` topic reference](/dev-tooling/cli/integration-layer.md):

```bash title="Show the topic help"
commercetools integration-layer --help
```

To list the installed plugins or remove one:

```bash title="List and remove plugins"
commercetools plugins
commercetools plugins uninstall @commercetools/cli-topic-integration-layer
```

## Next steps

- [Use the CLI with AI coding agents](/dev-tooling/cli/ai-agents.md)
- [`sphere` topic reference](/dev-tooling/cli/sphere.md)
- [`integration-layer` topic reference](/dev-tooling/cli/integration-layer.md)
- [`connect` topic reference](/dev-tooling/cli/connect.md)
- [`import` topic reference](/dev-tooling/cli/import.md)

## Related pages

- [Area overview page with navigation](/dev-tooling.md)
- [Next page: Sphere](/dev-tooling/cli/sphere.md)
- [Search documentation and API specs](/search.md)