Documentation

SDK 2.0 · REFERENCE

Web SDK API reference

The public integration surface verified against the v3.0.0 npm package.

init(options)

Returns Promise<SpreeAISDK | null>. On success, the object exposes renderTryOnButton(options): Promise<void>. Check for null before rendering.

OptionTypeDefaultPurpose
clientIdstringRequiredIssued browser client identifier.
baseApiURLstringhttps://api.spreeai.comApproved API origin. Change only for an issued environment.
baseURLstringhttps://vton.spreeai.comApproved hosted fitting-room origin.

partnerId is not an init option in v3. The partner is resolved from the authenticated client. No standalone sizing render method is returned.

renderTryOnButton(options)

OptionTypeDefault / requirementPurpose
elementIdstringRequiredID of the existing host element.
garmentsGarmentInput[]Required choiceRecommended garment input. Use a non-empty array.
garmentIdstringDeprecated alternativeLegacy single-garment input. Prefer garments.
variantVariantOptionsDeprecatedLegacy filter with garmentId; prefer per-item variant.
classNamestringOptionalAdditional button class.
button{ text?: string }OptionalButton label; overridden by features.tryOnButton.text.
featuresTryOnFeaturesOptionalButton styling configuration.
eventsTryOnButtonEventsOptionalClick and add-to-cart handlers.
enableAddToCartbooleanfalseDisplay the add-to-cart functionality. Implement the handler.
enableSizingRecommendationbooleanfalseRequest sizing recommendations inside try-on.
showSizesbooleanfalseShow supplied availableSizes.
showPricesbooleanfalseShow supplied price.
defaultUnits"metric" | "imperial"OptionalStarting unit system for profile measurements.

GarmentInput

FieldTypePurpose
garmentIdstringRequired SPREEAI garment identifier.
variantVariantOptionsOptional color, fit, gender or style filter.
availableSizesstring[]Optional current display size labels.
pricestringOptional display price, shown as supplied.

Validation and fallback

For a single garment, eligibility and any pinned variant are checked before rendering. Multi-garment requests look for an available matching outfit. If none is found, the SDK validates and renders the first garment instead. If validation fails, no button is rendered and the reason is logged to the console.

Callbacks

CallbackPayload
onTryOnButtonClickname: "spreeai-try-on-button-clicked"
onAddToCartClickedname: "spreeai-add-to-cart-clicked", garments, setIsLoading, closePopUp, onError

Cart garments contain required id, partner_id, available and name, plus optional description and other data. Validate before mapping to your cart. See cart implementation and button styling for examples.

Not part of this surface

No documented per-view switches, standalone Compare launcher or standalone sizing method are exposed on the returned v3.0.0 SDK. features.loadingScreen has been removed. Do not infer callable methods from leftover exported types or stale comments.

Source references

Search page titles and content. Escape closes search.

Choose your language.