Configuration
All options available when initializing the Body2Fit SDK.
Configuration Object
The Body2Fit SDK is initialized with a configuration object that contains all the necessary settings:
const config = {
// Required fields
clientKey: "your-client-key",
countryCode: "US",
languageCode: "en",
brandId: "your-brand-id",
garmentSKU: "your-garment-sku",
preferredMeasurementSystem: "metric",
// Optional fields
priorityFlow: "stats",
features: ["feature1", "feature2"],
brandLogoURL: "https://example.com/logo.png",
garmentImageURL: "https://example.com/garment.jpg",
garmentName: "Premium T-Shirt",
slideInDirection: "right",
preferredGender: "male",
theme: {
colors: {
primary: "#007bff"
}
},
additionalParams: {
customParam: "value"
},
session: {
clientSessionId: "your-client-session-id",
},
};
const widget = new Body2FitSDK(config);Required Configuration
| Property | Type | Values | Description |
|---|---|---|---|
clientKey | string | — | Your unique client key provided by Body2Fit. |
countryCode | string | "US", "JP" | The country code for your target market. |
languageCode | string | "en", "ja" | The language code for the widget interface. |
brandId | string | — | Your unique brand identifier. |
garmentSKU | string | — | The SKU of the specific garment for size recommendations. |
preferredMeasurementSystem | string | "metric", "imperial" | The measurement system to use for the widget. |
Optional Configuration
| Property | Type | Default | Values | Description |
|---|---|---|---|---|
priorityFlow | string | "stats" | "stats", "upload", "selfie", "full-body" | Determines the priority flow for the widget experience. |
features | string[] | [] | — | Array of feature flags to enable specific functionality. |
brandLogoURL | string | — | Valid URL | URL to your brand logo image. |
garmentImageURL | string | — | Valid URL | URL to the garment product image. |
garmentName | string | — | — | Display name for the garment. |
slideInDirection | string | "right" | "left", "right", "top", "bottom" | Direction from which the widget slides in. |
preferredGender | string | "male" | "male", "female" | Default gender preference for the widget. |
theme | object | {} | — | Custom theme configuration for styling. |
additionalParams | object | {} | — | Custom key-value pairs for integration-specific data. |
session.clientSessionId | string | — | — | A unique identifier to correlate size recommendations with purchase decisions. Generate a unique ID per user session and pass it here to enable order tracking. See Order Confirmation. |
Configuration Validation
The SDK validates your configuration and throws descriptive errors for missing or invalid required fields:
try {
const widget = new Body2FitSDK({
clientKey: "demo-key",
// Missing required fields
});
} catch (error) {
console.error("Configuration error:", error.message);
// Error: Body2Fit: brandId is required
}Common validation errors:
| Error | Cause |
|---|---|
clientKey is required | clientKey was not provided. |
brandId is required | brandId was not provided. |
garmentSKU is required | garmentSKU was not provided. |
countryCode is required | countryCode was not provided or is invalid. |
languageCode is required | languageCode was not provided or is invalid. |
measurementSystem is required | preferredMeasurementSystem was not provided or is invalid. |
