Bodygram

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

PropertyTypeValuesDescription
clientKeystringYour unique client key provided by Body2Fit.
countryCodestring"US", "JP"The country code for your target market.
languageCodestring"en", "ja"The language code for the widget interface.
brandIdstringYour unique brand identifier.
garmentSKUstringThe SKU of the specific garment for size recommendations.
preferredMeasurementSystemstring"metric", "imperial"The measurement system to use for the widget.

Optional Configuration

PropertyTypeDefaultValuesDescription
priorityFlowstring"stats""stats", "upload", "selfie", "full-body"Determines the priority flow for the widget experience.
featuresstring[][]Array of feature flags to enable specific functionality.
brandLogoURLstringValid URLURL to your brand logo image.
garmentImageURLstringValid URLURL to the garment product image.
garmentNamestringDisplay name for the garment.
slideInDirectionstring"right""left", "right", "top", "bottom"Direction from which the widget slides in.
preferredGenderstring"male""male", "female"Default gender preference for the widget.
themeobject{}Custom theme configuration for styling.
additionalParamsobject{}Custom key-value pairs for integration-specific data.
session.clientSessionIdstringA 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:

ErrorCause
clientKey is requiredclientKey was not provided.
brandId is requiredbrandId was not provided.
garmentSKU is requiredgarmentSKU was not provided.
countryCode is requiredcountryCode was not provided or is invalid.
languageCode is requiredlanguageCode was not provided or is invalid.
measurementSystem is requiredpreferredMeasurementSystem was not provided or is invalid.

On this page