Product Metrics CLI
productmetrics, the Product Metrics command line: every public API operation as a command, with JSON output and exit codes for scripts and agents.
productmetrics is the Product Metrics command line. It calls the public API (/api/public/v1) and builds its commands, flags and help from the server’s own list of operations, so a new API operation works without a new CLI release.
By the end of this page you will:
- Run
productmetricsand read its help - Sign in in a browser
- Run your first command and read it as JSON
Install and run
Install it from npm (Node.js 22 or later):
npm install -g @productmetrics/cli
productmetrics --help
# or once, without installing
npx @productmetrics/cli --helpThe examples on these pages write productmetrics. By default it talks to https://prod-backend.productmetrics.io. productmetrics status shows which API it uses.
Help
# every command and API group
productmetrics --help
# the commands of one group
productmetrics google-ads --help
# one command: request, scope, flags, examples
productmetrics settings update --help
# how an AI agent should use productmetrics
productmetrics help agentsproductmetrics, productmetrics help and every --help print the same layout: usage, commands, flags with their types, defaults and allowed values, and examples.
- Add
--jsonfor a machine-readable description. - Help topics:
productmetrics help agents,productmetrics help exit-codes,productmetrics help json.
Quickstart
# opens the browser; click Connect Product Metrics CLI
productmetrics login
# your account (email) and properties
productmetrics whoami
# find an operation
productmetrics capabilities --search settings
productmetrics settings get --property-id <property_id> --jsonThe last command prints the settings as JSON:
{
"ok": true,
"data": {
"labelizer_settings": { … },
"settings_version": 4,
…
},
"request_id": "…"
}How commands map to the API
Every API operation is a command. Its capability id gives the command: group.command, with _ turned into -.
| Capability id | Command |
|---|---|
google_ads.list_accounts | productmetrics google-ads list-accounts |
settings.recommend_min_clicks | productmetrics settings recommend-min-clicks |
merchant_center.apply_auto_setup | productmetrics merchant-center apply-auto-setup |
Each path parameter, query parameter and top-level body field is a kebab-case flag:
| Field | Flag |
|---|---|
propertyId | --property-id |
feed_scope | --feed-scope |
labelizer_settings | --labelizer-settings '{…}' |
productmetrics call <capability-id> runs the same operation by its id. See Commands.
Built-in commands
| Command | What it does |
|---|---|
productmetrics login | Sign in to Product Metrics in a browser |
productmetrics logout | Sign out of this API origin |
productmetrics status | Show which API productmetrics uses and whether you are signed in |
productmetrics whoami | Check the sign-in against the API: your account and properties |
productmetrics capabilities | List every API operation |
productmetrics call | Run an operation by its id |
productmetrics feedback | Tell the Product Metrics team what worked or did not |
productmetrics mcp-config | Show how to add Product Metrics to Claude, ChatGPT or Cursor |
productmetrics help | Help for a command or topic |
productmetrics agents is short for productmetrics help agents.
Global flags
| Flag | What it does |
|---|---|
--api <origin> | The Product Metrics API to use (default https://prod-backend.productmetrics.io, env PM_API_URL) |
--json | Print one JSON document on stdout ({ok, data, request_id} or {ok: false, error, exit_code}) |
--select <path> | Print only part of the JSON document, e.g. .data.properties[].property_id (implies --json) |
-q, --quiet | Print only the primary id of the result, or nothing |
--verbose | Log requests, timings and request ids to stderr (never tokens or bodies) |
--no-input | Never prompt or open a browser (on by default without a terminal; env PM_AGENT=1, CI) |
--no-color | No colours (env NO_COLOR) |
--refresh | Fetch the server’s command list again (it is cached for an hour) |
-h, --help | Show help; with --json, a machine-readable description |
-v, --version | Show the version |
Where things are stored
- Sign-in:
${XDG_CONFIG_HOME:-~/.config}/product-metrics/credentials.json, one entry per API origin, mode 0600 in a 0700 directory. - Command list cache (one hour):
${XDG_CACHE_HOME:-~/.cache}/product-metrics/.
Use it from an AI app instead
productmetrics mcp-config --client claude|chatgpt|cursor prints the MCP server URL and how to add it as a connector. Connectors sign in in the browser and need no token. See MCP.
Where next
- Authentication:
productmetrics login, scopes andPM_TOKEN - Commands: every command group
- For agents: driving
productmetricsfrom Claude Code, Codex or a script - JSON and exit codes