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

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

# Function: createCdnZonesClient()

> **createCdnZonesClient**(`config`, `auth`, `options?`): [`CdnZonesClient`](../type-aliases/CdnZonesClient.md)

Defined in: [packages/b2c-tooling-sdk/src/clients/cdn-zones.ts:207](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/e7c16f1ae423da0aa47b3e10be88f9770b53619b/packages/b2c-tooling-sdk/src/clients/cdn-zones.ts#L207)

Creates a typed CDN Zones 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.cdn-zones` (read) or `sfcc.cdn-zones.rw` (read-write)
- Tenant scope: `SALESFORCE_COMMERCE_API:{tenantId}`

## Parameters

### config

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

CDN Zones client configuration including shortCode and tenantId

### auth

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

Authentication strategy (typically OAuth)

### options?

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

Optional settings like readWrite scope

## Returns

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

Typed openapi-fetch client

## Examples

```ts
// Create CDN Zones client for read-only operations
const oauthStrategy = new OAuthStrategy({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
});

const client = createCdnZonesClient(
  { shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' },
  oauthStrategy
);

// List all zones
const { data, error } = await client.GET('/organizations/{organizationId}/zones/info', {
  params: {
    path: { organizationId: toOrganizationId('zzxy_prd') }
  }
});
```

```ts
// Create CDN Zones client for read-write operations (e.g., cache purge)
const rwClient = createCdnZonesClient(
  { shortCode: 'kv7kzm78', tenantId: 'zzxy_prd' },
  oauthStrategy,
  { readWrite: true }
);

// Purge cache
const { data } = await rwClient.POST('/organizations/{organizationId}/zones/{zoneId}/cachepurge', {
  params: {
    path: { organizationId: toOrganizationId('zzxy_prd'), zoneId: 'zone-id' }
  },
  body: { path: ['/some/path'] }
});
```
