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

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

Function: createCustomApisClient()

createCustomApisClient(config, auth): CustomApisClient

Defined in: packages/b2c-tooling-sdk/src/clients/custom-apis.ts:112

Creates a typed Custom APIs DX 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.custom-apis (or custom via config.scopes)
  • Tenant scope: SALESFORCE_COMMERCE_API:{tenantId}

Parameters

config

CustomApisClientConfig

Custom APIs client configuration including shortCode and tenantId

auth

AuthStrategy

Authentication strategy (typically OAuth)

Returns

CustomApisClient

Typed openapi-fetch client

Example

ts
// Create Custom APIs client - scopes are handled automatically
const oauthStrategy = new OAuthStrategy({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
});

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

// Get all Custom API endpoints
const { data, error } = await client.GET('/organizations/{organizationId}/endpoints', {
  params: {
    path: { organizationId: toOrganizationId('zzxy_prd') }
  }
});

All rights reserved.