@salesforce/b2c-tooling-sdk / clients / createMetricsClient
Function: createMetricsClient()
createMetricsClient(
config,auth):MetricsClient
Defined in: packages/b2c-tooling-sdk/src/clients/metrics.ts:142
Creates a typed Metrics API client.
Returns the openapi-fetch client directly, with authentication handled via middleware. This gives full access to all openapi-fetch features with type-safe paths, parameters, and responses.
The client automatically handles OAuth scope requirements:
- Domain scope:
sfcc.metrics(or custom via config.scopes) - Tenant scope:
SALESFORCE_COMMERCE_API:{tenantId}
Parameters
config
Metrics client configuration including shortCode and tenantId
auth
Authentication strategy (typically OAuth client-credentials)
Returns
Typed openapi-fetch client
Example
ts
const auth = new OAuthStrategy({ clientId: '...', clientSecret: '...' });
const client = createMetricsClient({ shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' }, auth);