@salesforce/b2c-tooling-sdk / clients / createMrtClient
Function: createMrtClient()
createMrtClient(
config,auth):MrtClient
Defined in: packages/b2c-tooling-sdk/src/clients/mrt.ts:124
Creates a typed Managed Runtime 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.
Parameters
config
MRT client configuration
auth
Authentication strategy (typically ApiKeyStrategy)
Returns
Typed openapi-fetch client
Examples
ts
// Create MRT client with API key auth
const apiKeyStrategy = new ApiKeyStrategy(apiKey, 'Authorization');
const client = createMrtClient({}, apiKeyStrategy);
// Push a bundle to a project
const { data, error } = await client.POST('/api/projects/{projectSlug}/builds/', {
params: {
path: { projectSlug: 'my-project' }
},
body: {
message: 'My bundle',
encoding: 'base64',
data: bundleData,
ssr_parameters: {},
ssr_only: ['ssr.js'],
ssr_shared: ['shared.js']
}
});ts
// List all projects
const { data, error } = await client.GET('/api/projects/', {});ts
// Get a specific target/environment
const { data, error } = await client.GET('/api/projects/{projectSlug}/target/{targetId}/', {
params: { path: { projectSlug: 'my-project', targetId: 'staging' } }
});