---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [clients](../index.md) / createMetricsClient

# Function: createMetricsClient()

> **createMetricsClient**(`config`, `auth`): [`MetricsClient`](../type-aliases/MetricsClient.md)

Defined in: [packages/b2c-tooling-sdk/src/clients/metrics.ts:142](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/67fb8580ac3c5b372617ee3ec3fc8f2bc9f16174/packages/b2c-tooling-sdk/src/clients/metrics.ts#L142)

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

[`MetricsClientConfig`](../interfaces/MetricsClientConfig.md)

Metrics client configuration including shortCode and tenantId

### auth

[`AuthStrategy`](../../auth/interfaces/AuthStrategy.md)

Authentication strategy (typically OAuth client-credentials)

## Returns

[`MetricsClient`](../type-aliases/MetricsClient.md)

Typed openapi-fetch client

## Example

```ts
const auth = new OAuthStrategy({ clientId: '...', clientSecret: '...' });
const client = createMetricsClient({ shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' }, auth);
```
