Developer Preview — This project is in active development. APIs may change. Provide feedback
Skip to content

@salesforce/b2c-tooling-sdk / clients / createCdnZonesClient

Function: createCdnZonesClient()

createCdnZonesClient(config, auth, options?): CdnZonesClient

Defined in: packages/b2c-tooling-sdk/src/clients/cdn-zones.ts:207

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

CDN Zones client configuration including shortCode and tenantId

auth

AuthStrategy

Authentication strategy (typically OAuth)

options?

CdnZonesClientOptions

Optional settings like readWrite scope

Returns

CdnZonesClient

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'] }
});

Released under the Apache-2.0 License.