Try-on Docs

API Reference

Complete reference for the Try-on API

API Reference

window.fitting('init', options)

Initializes the widget. Call this once, before any other methods.

ParameterTypeRequiredDescription
apiKeystringYesYour widget API key
window.fitting('init', {
  apiKey: 'pk_live_xxx',
});

window.fitting('create', options)

Opens the virtual try-on experience.

ParameterTypeRequiredDescription
targetElementIdstringYesID of the container element where the widget renders
tryonItemsTryonItem[]YesArray of items available for try-on
displayMode'inline' | 'modal'NoWidget display mode
model'balanced' | 'quality' | 'performance'NoRendering model (default: 'balanced')
configStyleTypeNoWidget appearance settings. See Styling for details.
callbackDataAnyNoCustom data that will be sent to your server (Webhook) upon successful generation. The Webhook URL is configured in the admin panel.
onSuccessfunctionNoCallback fired after successful generation
onClosefunctionNoCallback fired after widget is closed

TryonItem

FieldTypeDescription
productNamestringDisplay name of the garment
urlstringFull URL to the garment image

Styling

You can customize the widget's appearance in the dashboard: API Keys → Your Key → Customize.

You can also override the styles programmatically at initialization by passing the config object to the window.fitting('create', ...) method. Parameters passed in config take precedence and will override the settings from the dashboard:

ПараметрТипОбязателенОписание
title_colorstring"#404040"Color of main headings
description_colorstring"#9ca3af"Color of subheadings, labels, and description texts
background_colorstring"#ffffff"Background color of the modal window or widget container
loaderstring".../loader.json"Direct URL to a Lottie JSON animation for the loading screen
primary_btn_bg_colorstring"#111827"Background color of the primary call-to-action button
primary_btn_text_colorstring"#ffffff"Text color of the primary call-to-action button
secondary_btn_bg_colorstring"#f5f5f5"Background color of secondary buttons
secondary_btn_text_colorstring"#262626"Text color of secondary buttons
close_cross_colorstring"#404040"Color of the close ("X") modal button icon
show_logostringtrueVisibility flag for the service branding logo
show_back_btn_post_genstringtrueVisibility flag for the "Back" button on the post-generation result screen
window.fitting('create', {
  targetElementId: 'widget-container',
  model: 'balanced',
  tryonItems: [
    {
      productName: 'Denim Jacket',
      url: 'https://example.com/jacket.png',
    },
  ],
});