@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
Custom APIs client configuration including shortCode and tenantId
auth
Authentication strategy (typically OAuth)
Returns
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') }
}
});