/b2c-cli:b2c-metricsfrom b2c-cli
Queries observability metrics from the SCAPI Metrics API for Commerce Cloud performance monitoring, including request volume, latency, error rates, cache performance, and sales metrics.
Ships in b2c-cli. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
::: danger CLOSED BETA The Metrics API is a closed beta feature. It must be enabled for your organization, and its behavior, output, and OAuth scopes may change without notice. :::
Use the b2c metrics commands to query observability metrics from the SCAPI Metrics API (observability/metrics/v1). This provides time-series metrics data for monitoring and analyzing Commerce Cloud technical performance.
Tip: If
b2cis not installed globally, usenpx @salesforce/b2c-cli.
metrics
├── list - list available metric categories
├── overall - system-wide aggregate metrics
├── sales - sales transaction metrics
├── ecdn - edge CDN performance
├── third-party - third-party service integrations
│ └── Flags:
│ └── --third-party-service-id - filter by service ID
├── scapi - SCAPI request volume/latency/errors/cache
│ └── Flags:
│ ├── --api-family - filter by API family
│ └── --api-name - filter by API name
├── scapi-hooks - SCAPI hook execution metrics
├── mrt - Managed Runtime (PWA Kit) metrics
├── controller - SFRA controller performance
└── ocapi - OCAPI request metrics
└── Flags:
├── --ocapi-category - filter by OCAPI category
└── --ocapi-api - filter by OCAPI API
Common Flags (all category commands):
├── --from / --to / --window - time window (relative "1h"/"7d" or ISO 8601)
└── --tags / --no-tags - enrich series with structured tags (default: true)
Values like tenantId, shortCode, clientId, and clientSecret resolve from dw.json / SFCC_* env vars / the active instance / configuration plugins. Examples below show minimal usage; add flags only to override configured values — passing --client-id/--client-secret/--tenant-id/--short-code is usually unnecessary. If a required value is missing, the CLI emits an actionable error pointing at the flag, env var, and config key.
Run b2c setup inspect to see the resolved configuration and which source provided each value (--json for scripting; secrets stay masked by default). For precedence rules and troubleshooting, see the b2c-cli:b2c-config skill.
Relevant overrides:
--tenant-id (alias --tenant) / SFCC_TENANT_ID / tenantId--short-code / SFCC_SHORTCODE / shortCode--client-id / SFCC_CLIENT_ID / clientId--client-secret / SFCC_CLIENT_SECRET / clientSecret--user-auth is not supported)Salesforce Commerce API role with tenant filter for your instancesfcc.metrics (automatically requested by the CLI)::: danger CLOSED BETA The Metrics API is a closed beta feature. It must be enabled for your organization before use. :::
b2c metrics list)b2c metrics overall, b2c metrics scapi)--from/--to/--window — relative like 1h/7d or ISO 8601) or category-specific filters| Command | Description | Category-Specific Filters |
|---|---|---|
b2c metrics overall | System-wide aggregate metrics | None |
b2c metrics sales | Sales transaction metrics | None |
b2c metrics ecdn | Edge CDN performance | None |
b2c metrics third-party | Third-party service integrations | --third-party-service-id |
b2c metrics scapi | SCAPI request volume/latency/errors/cache | --api-family, --api-name |
b2c metrics scapi-hooks | SCAPI hook execution metrics | None |
b2c metrics mrt | Managed Runtime (PWA Kit) metrics | None |
b2c metrics controller | SFRA controller performance | None |
b2c metrics ocapi | OCAPI request metrics | --ocapi-category, --ocapi-api |
::: warning Filter Validation
Category-specific filters are only accepted by the command they apply to. For example, --api-family is only valid for b2c metrics scapi. Passing a filter to a different command results in a "Nonexistent flag" error.
:::
# List all categories (uses configured tenant)
b2c metrics list
# List as JSON
b2c metrics list --json
# Target a different tenant than the active config
b2c metrics list --tenant-id zzxy_prd
# Get overall metrics (last 24 hours by default)
b2c metrics overall
# Get metrics for the last hour
b2c metrics overall --window 1h
# Get a 1-hour window from 7 days ago
b2c metrics scapi --from 7d --window 1h
# Get metrics for a specific ISO 8601 time range
b2c metrics scapi --from "2026-01-25T10:00:00" --to "2026-01-25T11:00:00"
# Get SCAPI metrics filtered by API family
b2c metrics scapi --api-family products
# Get SCAPI metrics for a specific API
b2c metrics scapi --api-family products --api-name shopper-products
# Get third-party metrics for a specific service
b2c metrics third-party --third-party-service-id my-integration
# Get OCAPI metrics filtered by category and API
b2c metrics ocapi --ocapi-category shop --ocapi-api baskets
# Get controller metrics for the last 6 hours
b2c metrics controller --window 6h
# Output as JSON
b2c metrics overall --json
Metrics commands accept flexible time-window specifications via three flags:
--from — Start bound: relative duration (1h, 7d = that long ago) or ISO 8601 timestamp--to — End bound: relative duration or ISO 8601 timestamp--window (alias --for) — Window duration (1h, 30m, 2d)The commands always send an explicit from+to range, defaulting to a 24-hour window. The Metrics API pairs a request that omits to with its own "now" and enforces a 24-hour maximum window, so an open-ended --from older than a day would always be rejected; filling the window client-side makes the behavior predictable.
Resolution rules:
--from + --to → used as given (a range wider than 24h is sent as-is; the API returns its own error)--from + --window → end = start + window (e.g., --from 7d --window 1h = a 1-hour window, 7 days ago)--to + --window → start = end − window--window alone → the last <window> (end = now, start = now − window)--from alone → a 24-hour window forward from it: end = min(start + 24h, now)--to alone → a 24-hour window back from it: start = end − 24hYou can specify at most two of the three flags.
Examples:
# Last hour
b2c metrics overall --window 1h
# Last 7 days
b2c metrics sales --window 7d
# 1-hour window starting 7 days ago
b2c metrics scapi --from 7d --window 1h
# Specific ISO 8601 range
b2c metrics scapi --from "2026-01-25T10:00:00" --to "2026-01-25T11:00:00"
# From 24 hours ago until now (--from alone → default 24h window, capped at now)
b2c metrics overall --from 24h
Data retention: The Metrics API retains 30 days of data. If --from lands at or beyond the retention edge, the CLI adjusts it forward by a small safety margin (5 minutes) and emits a warning.
Wire units: Request bounds are sent to the API as epoch seconds; response timestamps come back as epoch milliseconds (JS-native)
By default, the CLI enriches each data series with a structured tags object to make filtering and grouping easier. The Metrics API returns series identifiers that pack multiple dimensions into a single string (e.g., bdpx_prd.product, bdpx_prd.product MISS, bdpx_prd 4xx, and for eCDN 2xx bdpx.www.example.com). Most categories prefix IDs with <realm>_<environment>; eCDN uses the bare realm. The tags object unpacks these into discrete key-value pairs.
Tag contents (three tiers):
f_ecom_bdpx_prd → realm=bdpx, environment=prd).apiFamily, apiName, host, cacheStatus, statusClass, ocapiCategory, controller, exceptionType, aggregation.--api-family, etc.) is folded in authoritatively, overriding heuristic guesses.Example:
scapi cacheHitRate series bdpx_prd.product MISS → {"realm":"bdpx","environment":"prd","apiFamily":"product","cacheStatus":"MISS"}scapi responseCount series bdpx_prd 4xx → {"realm":"bdpx","environment":"prd","statusClass":"4xx"}controller totalCalls series bdpx_prd.Home-Show → {"realm":"bdpx","environment":"prd","controller":"Home-Show"}Disabling tags:
Pass --no-tags to disable enrichment and return the raw API shape (no tags key on series).
Important framing:
Tag parsing is a client-side, best-effort bridge over the API's current packed-string format. The realm/environment and applied-filter tiers are always reliable; the string-parsed dimensions are heuristic.
Metrics responses contain an array of metrics. Each metric includes:
responseCount)s, %); empty for countsid. A series whose id equals its metricId and has no data is a placeholder (no events in the window)With --json, the response is wrapped as {query, data} where query echoes the resolved time bounds and filters:
{
"query": {
"category": "scapi",
"from": "2026-01-25T10:00:00.000Z",
"to": "2026-01-25T11:00:00.000Z",
"fromEpochSeconds": 1737802800,
"toEpochSeconds": 1737806400
},
"data": [
{
"metricId": "responseCount",
"title": "Response Count",
"description": "Number of responses for SCAPI requests.",
"unit": "",
"dataSeries": [
{
"id": "bdpx_prd 2xx",
"name": "bdpx_prd 2xx",
"tags": {
"realm": "bdpx",
"environment": "prd",
"statusClass": "2xx"
},
"data": [
{"timestamp": 1737802800000, "value": 1500},
{"timestamp": 1737803400000, "value": 1620}
]
}
]
}
]
}
The query object always includes both from/to (and fromEpochSeconds/toEpochSeconds). When a bound was derived from the 24-hour default window (e.g. --from alone, or no time flags), query.defaultedWindow is true; when --from was clamped forward off the retention edge, query.clampedFrom is true.
The Metrics API is also available via the SDK:
import {createMetricsClient} from '@salesforce/b2c-tooling-sdk/clients';
import {getScapiMetrics, getOverallMetrics, resolveMetricsWindow} from '@salesforce/b2c-tooling-sdk';
// Create client
const client = createMetricsClient(
{
shortCode: 'kv7kzm78',
tenantId: 'zzxy_prd',
},
{clientId: 'xxx', clientSecret: 'xxx'},
);
// Get overall metrics
// `from`/`to` accept a Date or epoch milliseconds; the SDK converts to
// the API's epoch-seconds wire format.
const overallMetrics = await getOverallMetrics(client, 'zzxy_prd', {
from: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), // 7 days ago
to: new Date(),
});
// Get SCAPI metrics with filters
const scapiMetrics = await getScapiMetrics(client, 'zzxy_prd', {
from: new Date(Date.now() - 24 * 60 * 60 * 1000), // 24 hours ago
apiFamily: 'product',
apiName: 'shopper-products',
});
// Use resolveMetricsWindow to handle from/to/window resolution
const window = resolveMetricsWindow({from: '7d', window: '1h'});
const historicalMetrics = await getScapiMetrics(client, 'zzxy_prd', {
from: window.from,
to: window.to,
apiFamily: 'product',
});
Available operations: getOverallMetrics, getSalesMetrics, getEcdnMetrics, getThirdPartyMetrics, getScapiMetrics, getScapiHooksMetrics, getMrtMetrics, getControllerMetrics, getOcapiMetrics, getMetricsByCategory.
Available helpers: resolveMetricsWindow({from, to, window}), parseMetricsBound(value), enrichMetricsTags(response, category, context), parseSeriesTags({category, metricId, seriesId, context}).
All operations accept (client, tenantId, options?) and return Promise<MetricsDataResponse>. Time-window from/to accept a Date or epoch milliseconds (converted to the API's epoch-seconds wire format); response data-point timestamps come back in epoch milliseconds. The tenant ID may be bare (e.g., zzxy_prd) or prefixed (e.g., f_ecom_zzxy_prd) — the SDK normalizes it automatically.
tenant-id is required: set --tenant-id (or SFCC_TENANT_ID)--user-authFor full command reference, use b2c metrics --help and see CLI docs (b2c docs read cli-metrics) and Metrics Guide (b2c docs read guide-metrics).
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
commerce-cloud, scapi, observability, performance-monitoring, b2c-cli
npx claudepluginhub salesforcecommercecloud/b2c-developer-tooling --plugin b2c-cli28 skills in this plugin
/b2c-amManage Account Manager resources including API clients, users, roles, and organizations. Use this skill whenever the user needs to create or update API clients, onboard or offboard developers, assign Account Manager roles scoped to tenants, audit user permissions, look up organizations, or provision API clients for CI/CD pipelines. Also use when managing AM role assignments or querying Account Manager data — even if they just say "add a new developer" or "set up an API client". For instance-level Business Manager administration (BM roles, BM users, BM access keys, BM whoami), defer to the `b2c-cli:b2c-bm-users-roles` skill./b2c-bm-users-rolesManage Business Manager users, access roles, role permissions, and per-user access keys on a B2C Commerce instance using the b2c CLI. Use this skill whenever the user needs to list or search BM users on a sandbox or production instance, identify which BM user an OAuth token resolves to ("whoami"), assign or revoke instance-level access roles, edit role permissions, look up a user's WebDAV / OCAPI / Storefront access key, or rotate access keys for SSO-managed users. Also use when the user asks "what's my BM login on sandbox X", "rotate my WebDAV password", "how do I make a custom BM role", "audit BM users on this instance", or "delete a stale BM user from a sandbox"./b2c-capManage Commerce App Packages (CAPs), also called commerce apps or apps, and commerce features using the b2c CLI. Use this skill whenever the user needs to validate, package, install, uninstall, list, or pull commerce apps on B2C Commerce instances, view configuration tasks, or pull app sources for cartridge deployment or Storefront Next development. Also use when checking which apps are installed on an instance, inspecting app details or versions, or managing app lifecycle — even if they just say "what apps do I have", "list my commerce apps", "which CAPs are installed", "install this app", "pull app sources", or "show installed apps"./b2c-cipQuery CIP/CCAC sales, merchandising, payment, traffic, and API/controller analytics with the B2C CLI or MCP. Discover reports/tables, scope SQL, export results, and resolve analytics access./b2c-codeDeploy, download, and manage cartridge code versions on B2C Commerce instances. Use this skill whenever the user needs to upload or download cartridges to/from a sandbox, activate or delete code versions, watch for local file changes during development, or deploy a subset of cartridges. Also use when pushing code to an instance, pulling code from an instance, or setting up a dev workflow with live reload -- even if they just say 'push my code to the sandbox', 'download the code', or 'how do I activate the new version'./b2c-configConfigure B2C CLI/MCP authentication, instances, and project defaults; troubleshoot missing credentials, wrong targets, or configuration precedence. Routine inspection can use config_inspect or b2c setup inspect directly.Other plugins' skills for the same job