# Authentication Source: https://docs.hemsy.ai/agents/authentication Create a developer account, buy prepaid credits, and authenticate with a Bearer API key. Every `visualize` call, MCP or REST, requires a developer API key with a positive credit balance. There is no unauthenticated or free tier: requests without a valid key return `401`, and requests with an empty balance return `402`. ## 1. Create an account Sign up at [developers.hemsy.ai](https://developers.hemsy.ai). If you already have a Hemsy merchant dashboard login, sign in with the same email. Your developer account and its credit balance are separate from any store's billing. ## 2. Buy credits Credits are prepaid. No subscription. Go to **Credits**, pick a pack, and check out with Stripe. 1 credit is consumed per successful render; failed renders are not charged. ## 3. Create an API key Go to **API keys** and create a key. The full key (`hemsy_…`) is shown **once**: only a hash is stored, so copy it immediately. You can revoke and re-issue keys at any time. ## 4. Send it as a Bearer token Pass the key in the `Authorization` header on every request: ```bash theme={null} Authorization: Bearer hemsy_4f3c9a... ``` This is the same header for the MCP endpoint and the REST endpoint. If an MCP connector UI only supports OAuth or no-auth (and can't send custom headers), use the keyed URL instead: `https://api.hemsy.ai/mcp/hemsy_...` with **no authentication**. See [MCP](/agents/mcp). ## Error responses | Status | Meaning | Fix | | - | - | - | | `401` | Missing, invalid, or revoked key | Create or check your key at [developers.hemsy.ai](https://developers.hemsy.ai) | | `402` | Insufficient credits | Buy a credit pack | | `429` | Rate limit exceeded | Slow down and retry | Error bodies include a `developers_url` pointer so agents can surface the top-up link to their users: ```json theme={null} { "error": "Insufficient credits", "message": "Buy credits at https://developers.hemsy.ai", "remaining_credits": 0, "developers_url": "https://developers.hemsy.ai" } ``` > [!WARNING] > > Treat API keys as secrets. Don't ship them in client-side code. Proxy > calls through your backend, or scope one key per agent deployment so you > can revoke it independently. # MCP Source: https://docs.hemsy.ai/agents/mcp Connect to the Hemsy visualize MCP server from Cursor, Claude, ChatGPT, or any MCP client. The Hemsy MCP server exposes a single tool, `visualize`, over stateless Streamable HTTP. ```text theme={null} Server URL: https://api.hemsy.ai/mcp Auth: Authorization: Bearer hemsy_... Keyed URL: https://api.hemsy.ai/mcp/hemsy_... Auth: none (key is in the path); for connector UIs that only offer OAuth or no-auth ``` ## Connect a client Most MCP clients take a server URL plus optional headers. Use your API key from [developers.hemsy.ai](https://developers.hemsy.ai) (see [Authentication](/agents/authentication)). **Cursor** Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global): ```json theme={null} { "mcpServers": { "hemsy-visualize": { "url": "https://api.hemsy.ai/mcp", "headers": { "Authorization": "Bearer hemsy_..." } } } } ``` **Claude** Claude's remote connector UI only offers **OAuth** or **no authentication**. It cannot send a Bearer header. Use the keyed URL: ```text theme={null} https://api.hemsy.ai/mcp/hemsy_... ``` Register the connector with **no authentication**. The API key in the path is what authenticates the request. **ChatGPT** ChatGPT's connector UI only offers **OAuth** or **no authentication**. It cannot send a Bearer header. Use the keyed URL: ```text theme={null} https://api.hemsy.ai/mcp/hemsy_... ``` Register the connector with **no authentication**. The API key in the path is what authenticates the request. **Other clients** Any client that supports Streamable HTTP MCP works the same way: point it at `https://api.hemsy.ai/mcp` and send the `Authorization: Bearer hemsy_...` header on every request. The server is stateless: no session setup required. If the client UI only supports OAuth or no-auth, use the keyed URL (`https://api.hemsy.ai/mcp/hemsy_...`) with no authentication instead. ## The `visualize` tool ```ts theme={null} { sceneImage: string, // https URL or data URL (room, person, space) products: [{ title?: string, category?: string, // e.g. "bedding", "sofa", "tops" images?: string[], // product image URLs. Required unless productUrl resolves productUrl?: string, // PDP URL. Unlocks merchant fidelity when it matches a Hemsy store productId?: string, // Shopify product id (optional) variantId?: string, // Shopify variant id (optional, best asset match) color?: string, tags?: string[] }], aspect?: "auto" // output matches the scene image } ``` Response (structured content): ```json theme={null} { "ok": true, "image": "data:image/png;base64,...", "products": [ { "index": 0, "fidelity": "merchant", "storeSlug": "acme-home" } ], "usage": { "credits": 1, "balance": 249 } } ``` ## Usage notes * **Pass only what the user picked.** A search tool may suggest ten products; call `visualize` with the one or two the user actually wants to see. One product per call is the common case; multiple products are composed into the same scene. * **`productUrl` is the fidelity signal.** When the product page URL belongs to a Hemsy merchant, that item renders with the merchant's catalog reference assets. The response echoes `storeSlug` so you can reuse it in follow-up calls. * **Renders can take a few minutes.** Set your client's tool timeout to at least 300 seconds, same as the [REST API](/agents/rest-api#timeouts). * **1 credit per successful render.** Errors (`401` no key, `402` no credits, `429` rate limited) are returned before any render starts. # Overview Source: https://docs.hemsy.ai/agents/overview The Visualize API renders any product photorealistically into any scene photo, built for agents, paid per call with prepaid credits. The Visualize API does one job: **product images + a scene photo in, a photoreal localized edit out.** This is not generic image generation. Hemsy edits only the product slots in the user's real photo: room/person, camera, and lighting stay; product references (and merchant color/texture swatches when available) lock silhouette, material, and colorway. That is why it beats "ask the model to invent a bedroom with a navy duvet" for in-space decisions. It is built for AI agents and the tools that power them. A shopping agent recommends a duvet cover; your user wants to see it on their bed. One `visualize` call returns the render: no catalog integration, no merchant onboarding, no permission needed from anyone. ```text theme={null} Input: any product image(s) + any scene image Output: a photorealistic render Payment: prepaid credits, 1 credit per successful render ``` ## Two ways to call it | Surface | For | Endpoint | | - | - | - | | [MCP](/agents/mcp) | MCP-native agents (Cursor, Claude, ChatGPT, custom) | `https://api.hemsy.ai/mcp` | | [REST](/agents/rest-api) | Anything that can make an HTTP request | `POST https://api.hemsy.ai/visualize` | Both surfaces expose the same single tool with the same authentication: a developer API key from [developers.hemsy.ai](https://developers.hemsy.ai). ## Merchant fidelity upgrade If a product you pass belongs to a Hemsy merchant, the render automatically upgrades to that merchant's full catalog fidelity: variant reference imagery, color swatches, and placement rules the merchant configured for their own storefront visualization. You don't need to do anything to get this: pass the product's page URL (`productUrl`) and the upgrade happens automatically when the product resolves to a Hemsy store. The response tells you which products rendered at `merchant` fidelity vs `generic`. > [!NOTE] > > This is **not** the merchant embed/Visualize API. Merchants embedding visualizations on > their own storefront should use the [Merchant Visualize API](/api-reference/merchant-try-on) and Embeds. > The Visualize API is developer-pays: your credits, any product, any scene. ## Pricing 1 credit = 1 successful render, regardless of how many products are composed into the scene. Failed renders are not charged. Buy prepaid credit packs at [developers.hemsy.ai](https://developers.hemsy.ai). No subscription. ## Next steps > **[Authentication](/agents/authentication)** > > Create an account, buy credits, and mint your API key. > **[Connect over MCP](/agents/mcp)** > > Add the server URL to Cursor, Claude, or any MCP client. > **[REST API](/agents/rest-api)** > > Call POST /visualize from anything that speaks HTTP. # REST API Source: https://docs.hemsy.ai/agents/rest-api POST /visualize: the same render as the MCP tool, callable from anything that speaks HTTP. If your agent or backend doesn't use MCP, call the plain HTTP endpoint. It shares the exact same handler, authentication, and billing as the MCP tool. ```text theme={null} POST https://api.hemsy.ai/visualize Authorization: Bearer hemsy_... Content-Type: application/json ``` ## Request ```bash theme={null} curl -X POST https://api.hemsy.ai/visualize \ -H "Authorization: Bearer hemsy_..." \ -H "Content-Type: application/json" \ -d '{ "sceneImage": "https://example.com/my-bedroom.jpg", "products": [{ "title": "Linen Duvet Cover", "category": "bedding", "productUrl": "https://brand.com/products/linen-duvet", "images": ["https://brand.com/cdn/duvet-front.jpg"] }] }' ``` | Field | Type | Notes | | - | - | - | | `sceneImage` | string (required) | https URL or data URL of the scene (room, person, space) | | `products[]` | array (required, 1–6) | Products to compose into the scene | | `products[].images` | string\[] | Product image URLs (https). Required unless `productUrl` resolves to a Hemsy merchant product | | `products[].productUrl` | string | Product page URL. Unlocks merchant fidelity when it matches a Hemsy store | | `products[].title`, `category`, `color`, `tags` | string(s) | Optional descriptors that improve render quality | | `products[].productId`, `variantId` | string | Optional Shopify ids; improve merchant asset matching | | `aspect` | `"auto"` | Output matches the scene image aspect | Prefer https image URLs over base64 data URLs. Inline images are capped at 8 MB each. ## Response ```json theme={null} { "image": "data:image/png;base64,...", "products": [ { "index": 0, "fidelity": "merchant", "storeSlug": "acme-home" } ], "usage": { "credits": 1, "balance": 249 } } ``` `products[].fidelity` is `merchant` when the item matched a Hemsy merchant and rendered with their catalog assets, otherwise `generic`. ## Errors | Status | Body `code` | Meaning | | - | - | - | | `400` | - | Invalid input (missing scene, no renderable products, too many images) | | `401` | - | Missing, invalid, or revoked API key | | `402` | `INSUFFICIENT_CREDITS` | Balance is empty. Top up at [developers.hemsy.ai](https://developers.hemsy.ai) | | `429` | - | Rate limit exceeded | | `502` / `503` | `MODEL_ERROR` / `MODEL_UNAVAILABLE` | Render providers failed. Retry; you were not charged | ## Timeouts Renders can take a few minutes; set your HTTP client timeout to at least 300 seconds. Credits are only consumed on success. See also the interactive [API playground](/api-reference/agent-try-on) for the schema, or [Authentication](/agents/authentication) for key setup. # Agent Visualize Source: https://docs.hemsy.ai/api-reference/agent-try-on api-reference/visualize-openapi.json POST /visualize Render any product(s) into any scene photo, billed to your developer account. Products from Hemsy merchants automatically upgrade to full catalog fidelity. # Merchant Visualize Source: https://docs.hemsy.ai/api-reference/merchant-try-on api-reference/openapi.json POST /api/try-on Generate a visualization for your own storefront's products, billed to your merchant account. ## Attribute orders A successful response includes an `attribution` array. Copy each `{ key, value }` onto the shopper's Shopify cart, either as cart attributes or as line-item properties on the items they visualized. Orders carrying these attributes count toward Hemsy revenue in the dashboard's Analytics page, and the `_hemsy_request_id` value links the order back to this visualization. ```json theme={null} { "image": "data:image/png;base64,...", "attribution": [{ "key": "_hemsy_request_id", "value": "iad1::abc123" }] } ``` Pass Shopify `variantId` or `productId` values in the request (rather than raw image URLs) so the visualization also appears in the store's Top Products. # Deep Links Source: https://docs.hemsy.ai/deep-links Pre-populate a shopper's Hemsy session with products, bundles, shared looks, and attribution data via URL parameters. ## Overview **Deep links** are URLs that configure how Hemsy opens: pre-loaded products or a shared look, bundle metadata on line items, and optional attribution IDs, applied before or as soon as the shopper lands in the session. Use them from product pages, emails, ads, blog posts, collection tiles, or bundle landing pages so customers don't have to rebuild a look from scratch or lose tracking context. Hemsy supports these query parameters for pre-populating or attributing a session: | Param | Purpose | | - | - | | `?closet=` | Base64-encoded payload for **one or more products**, with optional line-item attributes. | | `?product=` | Shortcut for a **single product** by Shopify ID or handle. | | `?share=` | A **shared look** short ID, used by the in-app Share feature. | | `?flow=` | Starts a **guided flow** by its flow ID (copy it from the dashboard's Flows page). | | `?anonymous_id=` | Anonymous visitor ID passed into Hemsy for analytics, attribution, and integrations. | All of these can be combined with `?store=` on [staging](/staging) and preview deployments to target a specific tenant. > [!NOTE] > > `?closet=` is the canonical, structured format. Use it for anything beyond a > single-product deep link, and **always** use it when you need to attach bundle > attributes. > [!NOTE] > > Include `anonymous_id` whenever the storefront has an anonymous visitor ID > available. Today, Hemsy uses it for Twilio Segment tracking and checkout/order > attribution. Longer term, it should be treated as the shared anonymous > identity for all integrations that need to connect Hemsy activity back to > storefront activity. *** ## `anonymous_id`: Visitor attribution `anonymous_id` is an optional query parameter that lets the merchant storefront tell Hemsy which anonymous visitor is opening the experience. Use it when launching Hemsy from: * Embedded storefront buttons * Product page links * Bundle landing pages * Email or ad links where the visitor ID is available * Any integration that wants to reconcile Hemsy events with storefront behavior Example: ```txt theme={null} https://yourstore.hemsy.ai/?anonymous_id=visitor-42 ``` Combined with a closet payload: ```txt theme={null} https://yourstore.hemsy.ai/?closet=&anonymous_id=visitor-42 ``` Combined with a product shortcut: ```txt theme={null} https://yourstore.hemsy.ai/?product=organic-cotton-duvet&anonymous_id=visitor-42 ``` Combined with a shared look: ```txt theme={null} https://yourstore.hemsy.ai/?share=abc123&anonymous_id=visitor-42 ``` ### What `anonymous_id` does When present, Hemsy uses `anonymous_id` to: * Attach the visitor identity to Hemsy analytics events. * Pass the same identity through checkout creation, so it can surface on the Shopify order as an additional detail/custom attribute when the order is placed through Hemsy checkout. * Provide a stable identity key for supported integrations. > [!NOTE] > > Current integration support is focused on Twilio Segment. Merchants should > still pass `anonymous_id` consistently now so Hemsy can use the same identity > for additional integrations as they are added. > [!WARNING] > > If a shopper visits a Hemsy-hosted URL directly, for example by typing > `https://yourstore.hemsy.ai/` into the browser, Hemsy cannot infer the > anonymous visitor ID from the merchant's storefront domain. The storefront > must pass the ID explicitly via `anonymous_id` in the URL or via the embed > script configuration. *** ## `?closet=`: Structured payload ### Format The value of `closet` is a **URL-safe Base64** encoding of a JSON object: ```json theme={null} { "products": [ { "variantId": 1111111111111, "attributes": [ { "key": "_bundleId", "value": "gid://shopify/Product/9999999999999" } ] }, { "productId": 2222222222222 } ] } ``` URL-safe Base64 means the standard Base64 string with: * `+` replaced with `-` * `/` replaced with `_` * Trailing `=` padding stripped Then appended to the URL as `?closet=`. ### Product entry schema Each entry in the `products` array supports the following fields: | Field | Type | Required | Notes | | - | - | - | - | | `variantId` | `number \| string` | one of required | Preferred identifier. Accepts a numeric ID or a Shopify GID: `gid://shopify/ProductVariant/...`. | | `productId` | `number \| string` | one of required | Fallback when you don't know the variant. Accepts a numeric ID or a GID. | | `attributes` | `Array<{ key: string; value: string }>` | optional | Line-item attributes forwarded into the Shopify cart at checkout. | > [!WARNING] > > At least one of `variantId` or `productId` **must** be present. Entries > without either are silently dropped. `variantId` takes precedence when both > are provided. ### Minimal example: single product ```json theme={null} { "products": [{ "variantId": 1111111111111 }] } ``` Base64-encoded and appended: ```txt theme={null} https://yourstore.hemsy.ai/?closet=eyJwcm9kdWN0cyI6W3sidmFyaWFudElkIjoxMTExMTExMTExMTExfV19 ``` With visitor attribution: ```txt theme={null} https://yourstore.hemsy.ai/?closet=eyJwcm9kdWN0cyI6W3sidmFyaWFudElkIjoxMTExMTExMTExMTExfV19&anonymous_id=visitor-42 ``` ### Example: multiple products ```json theme={null} { "products": [ { "variantId": 1111111111111 }, { "variantId": 1111111111112 }, { "productId": 2222222222222 } ] } ``` *** ## Line-item attributes Every entry in `products` may include an `attributes` array. These are key/value pairs that get forwarded verbatim to Shopify's Storefront API `cartCreate` mutation when the shopper checks out, and they surface on the resulting Shopify order. Use attributes to: * Track the **source** of a selection, such as `"utm_campaign"` or `"source"`. * Tag items as part of a **bundle**. * Pass through arbitrary merchant metadata you want on the order. ```json theme={null} { "attributes": [ { "key": "source", "value": "email-campaign" }, { "key": "campaign", "value": "summer-sale" } ] } ``` > [!NOTE] > > Attribute keys that start with an underscore (`_`) are treated as **private** > in Shopify's admin. They appear on the order but are hidden from the > storefront cart UI. Hemsy follows the same convention for its reserved keys. > [!NOTE] > > Use the top-level URL query parameter `anonymous_id` for visitor identity. Do > not put visitor identity into each product's line-item attributes unless the > merchant has a separate order-reporting need for that data at the line-item > level. *** ## Bundles and the `_bundleId` reserved key Closet URLs are the canonical way to launch a **bundle** into Hemsy. A bundle is a group of products a merchant wants a shopper to visualize and check out with together (for example, a "Starter Bedroom Bundle" composed of a sheet set, a blanket, and a pillow insert). To mark items as belonging to the same bundle, attach a set of reserved attributes to **every** product entry in the bundle. ### Reserved bundle attribute keys | Key | Required | Purpose | | - | - | - | | **`_bundleId`** | **yes** | Shopify GID or numeric ID of the parent bundle product. Presence of this key marks the line as a bundle member and is the signal Hemsy uses to enforce bundle behavior. | | `_uniqueId` | recommended | Opaque per-instance identifier, such as `_`. Use the **same** value for every product in a single bundle instance so orders can be reconciled. | | `_bundleTitle` | recommended | Human-readable bundle name. Surfaces on the order in Shopify admin. | | `_bundleHandle` | recommended | The Shopify handle of the parent bundle product. | | `_bundlesource` | optional | Origin of the bundle payload, such as `"hemsy"`. | > [!WARNING] > > **`_bundleId` is reserved.** Do not use this key for anything other than > marking bundle membership. Hemsy treats its presence as authoritative and > applies bundle-specific UX. ### Bundle behavior in Hemsy When any line item in the shopper's closet has a `_bundleId` attribute, Hemsy automatically: * **Hides the "Remove" button** for that item in the final *Review Your Order* step. Bundles ship as a unit, and merchants almost always require every component for checkout to succeed, so customers can't partially dismantle the bundle from the review screen. * Forwards the full attribute set to Shopify's cart so downstream discount rules, bundle-aware fulfillment logic, and order reporting all see the grouping. ### Full bundle example A three-line-item **Campers-Starter-Kit** bundle, Shopify handle `campers-starter-kit`, with the full set of bundle attributes on each line item and the same `_uniqueId` on every entry: ```json theme={null} { "products": [ { "productId": 3333333333333, "attributes": [ { "key": "_uniqueId", "value": "campers-starter-kit_a1b2c3d4-e5f6-7890-abcd-ef1234567890" }, { "key": "_bundleTitle", "value": "Campers-Starter-Kit" }, { "key": "_bundleHandle", "value": "campers-starter-kit" }, { "key": "_bundleId", "value": "gid://shopify/Product/9999999999999" }, { "key": "_bundlesource", "value": "hemsy" } ] }, { "productId": 4444444444444, "attributes": [ { "key": "_uniqueId", "value": "campers-starter-kit_a1b2c3d4-e5f6-7890-abcd-ef1234567890" }, { "key": "_bundleTitle", "value": "Campers-Starter-Kit" }, { "key": "_bundleHandle", "value": "campers-starter-kit" }, { "key": "_bundleId", "value": "gid://shopify/Product/9999999999999" }, { "key": "_bundlesource", "value": "hemsy" } ] }, { "productId": 5555555555555, "attributes": [ { "key": "_uniqueId", "value": "campers-starter-kit_a1b2c3d4-e5f6-7890-abcd-ef1234567890" }, { "key": "_bundleTitle", "value": "Campers-Starter-Kit" }, { "key": "_bundleHandle", "value": "campers-starter-kit" }, { "key": "_bundleId", "value": "gid://shopify/Product/9999999999999" }, { "key": "_bundlesource", "value": "hemsy" } ] } ] } ``` > [!TIP] > > Generate a fresh `_uniqueId`, such as a UUID v4, **per bundle instance**. That > way, if the same person buys the same bundle twice, each purchase is > reconcilable on its own. *** ## `?product=`: Single-product shortcut For the common case of "launch Hemsy with one product pre-loaded", `?product=` accepts either: * A numeric Shopify **product ID**: `?product=8888888888888` * A Shopify **GID**: `?product=gid://shopify/Product/8888888888888` * A product **handle**: `?product=organic-cotton-duvet` ```txt theme={null} https://yourstore.hemsy.ai/?product=organic-cotton-duvet ``` With visitor attribution: ```txt theme={null} https://yourstore.hemsy.ai/?product=organic-cotton-duvet&anonymous_id=visitor-42 ``` This shortcut does **not** support line-item attributes. If you need to attach bundle metadata, UTM tags, or any other attributes, use `?closet=` instead. *** ## `?share=`: Shared-look links `?share=` is reserved for links generated by Hemsy's in-app Share feature. The short ID resolves server-side to a previously saved look: user photo, generated image, and full selection. You don't need to construct these yourself. They're produced by the app when a shopper taps **Share**. If the storefront knows the visitor identity, append `anonymous_id` to shared look links too: ```txt theme={null} https://yourstore.hemsy.ai/?share=abc123&anonymous_id=visitor-42 ``` *** ## Building a Closet URL The URL-safe Base64 step is the only gotcha. In JavaScript: ```js theme={null} function buildClosetUrl(origin, pathname, payload, anonymousId) { const encoded = btoa(JSON.stringify(payload)) .replace(/\+/g, "-") .replace(/\//g, "_") .replace(/=+$/, ""); const params = new URLSearchParams({ closet: encoded }); if (anonymousId) { params.set("anonymous_id", anonymousId); } return `${origin}${pathname}?${params.toString()}`; } ``` In other languages, use that language's standard URL-safe Base64 without padding encoder, such as `base64.urlsafe_b64encode(...).rstrip("=")` in Python. *** ## Validation checklist Before shipping a Closet URL in production, confirm: * [ ] Every product entry has `variantId` **or** `productId`. * [ ] IDs are numeric or full GIDs, not handles. Handles only work with `?product=`. * [ ] Base64 is URL-safe: `-` and `_`, with no trailing `=`. * [ ] `anonymous_id` is included whenever the storefront has an anonymous visitor ID available. * [ ] For bundles: **every** item has `_bundleId`, and all items share the same `_uniqueId`. * [ ] You aren't using `_bundleId` for non-bundle use cases. * [ ] The link round-trips through `atob` and `JSON.parse` successfully. # Checkout vs Cart Resolution Source: https://docs.hemsy.ai/embeds/checkout-vs-cart Choose what the final CTA does: open Shopify checkout, or hand variant data back to your storefront's own cart. When a shopper finishes a visualization, the result screen shows one final CTA. `data-hemsy-action` on the script tag sets the default, and any launcher element can override it with its own `data-hemsy-action`. It applies to every launch mode, including Instant. | Action | CTA label | What happens | | - | - | - | | `checkout` (default) | "Go to Checkout" | Hemsy creates or opens a Shopify checkout/cart URL directly. | | `cart` | "Go to Cart" | Hemsy posts the selected variants back to your page, calls `window.HemsyEmbedConfig.onProductVariantData(payload)`, and closes the modal. | In the [Shopify theme extension](/embeds/shopify), this is the app embed's "When shoppers finish" setting and each trigger block's override, with no attributes to write. The examples below show the equivalent [script install](/embeds/script) markup. Use `cart` when shoppers should land in your store's cart instead of checkout, for example a theme with a custom cart drawer. ```html theme={null} ``` To override the action for a single launcher, put `data-hemsy-action` on the element: ```html theme={null} ``` > [!NOTE] > > The legacy script-level `data-hemsy-mode="cart"` still maps to the cart > action for backward compatibility, but prefer `data-hemsy-action`: > `data-hemsy-mode` should be reserved for `"instant"`. (`data-hemsy-mode="checkout"` > has no effect; checkout is simply the default action.) ## Native cart strategy By default the `cart` action hands items to *your* code via `onProductVariantData`, which means writing a callback. If your storefront is a standard Shopify theme, skip that entirely with `data-hemsy-cart-strategy="native"`: ```html theme={null} ``` With the native strategy, when the shopper clicks the final CTA Hemsy: 1. Adds the returned items to the Shopify cart via the Ajax API (`/cart/add.js`), converting variant GIDs to numeric IDs and mapping item attributes to line-item properties. 2. Dispatches `cart:refresh`, `cart:updated`, and `cart:change` events on `document` with the updated cart, so cart drawers and count bubbles that listen for them update in place. 3. Closes the modal once the add completes (unless `data-hemsy-auto-close="false"`). Callbacks still fire if you define them, so you can layer analytics on top. A cart failure never traps the shopper: the modal closes regardless and the error is logged to the console. > [!NOTE] > > The [Shopify theme extension](/embeds/shopify) uses the native strategy > automatically, so merchants who install through the theme editor get a working > cart handoff with zero code. ## Event callbacks Callbacks are configured on `window.HemsyEmbedConfig` (not data attributes). Define it before the embed script loads: ```html theme={null} ``` | Callback | Payload | Fires when | | - | - | - | | `onItemAdded` | `{ variantId: string, quantity: number }` | An item is added to the bag inside Hemsy | | `onItemRemoved` | `{ variantId: string }` | An item is removed from the bag inside Hemsy | | `onProductVariantData` | `{ items: Array<{ variantId: string, quantity: number, attributes?: Array<{ key: string, value: string }> }> }` | `action: "cart"` and the final CTA is clicked | `onItemAdded` and `onItemRemoved` fire live as the shopper edits their bag, regardless of action. `onProductVariantData` is the cart handoff itself: the `items` array includes any line-item attributes from the original payload (bundle keys and so on), so pass them through to your cart. ### Keeping the modal open By default, Hemsy closes the modal after the cart handoff. Set `data-hemsy-auto-close="false"` on the script tag (or `autoClose: false` on `HemsyEmbedConfig`) to keep it open (for example if you show your cart drawer next to the modal). # Incrementality Source: https://docs.hemsy.ai/embeds/incrementality Run a storefront holdout so you can measure the revenue Hemsy actually adds, and only after the embed is opted in. Incrementality mode is an A/B holdout. 90% of shoppers see your Hemsy calls to action as usual. A random 10% never see them. Comparing the two groups is how the dashboard estimates lift and net new revenue. You configure the test in the Hemsy dashboard (**Incrementality**). The storefront does **not** start that test from the dashboard toggle alone. ## The embed must opt in `hemsy-embed.js` calls `/api/incrementality/init` only when the script is explicitly opted in. Without that flag, the holdout never starts: no bucketing, no hiding, no cart tags. Existing installs (including a typical Shopify homepage script) do **not** include this attribute. That is intentional. A store with incrementality off in the dashboard should not hit Hemsy on every new session. Add **one** of these on the same page as the embed: ```html theme={null} ``` Or: ```html theme={null} ``` Accepted values: `true`, `"true"`, or `"1"`. Anything else (or omitting the flag) leaves incrementality off. > [!NOTE] > > The [Shopify theme app embed](/embeds/shopify) has no incrementality setting. > If you installed from the theme editor, add the `HemsyEmbedConfig` snippet > above to your theme code (for example in `theme.liquid`), and the app embed's > script picks it up. Turning the dashboard toggle **on** without the script flag does nothing on the storefront. Turning the toggle **off** still matters: even an opted-in embed gets `{ enabled: false }` from init and will not hide CTAs or tag carts. ## What happens when it is on Both of these must be true: 1. The embed is opted in (`data-hemsy-incrementality` or `HemsyEmbedConfig.incrementality`). 2. **Incrementality Mode** is enabled on the store in the dashboard. Then, once per tab session: 1. The embed POSTs `/api/incrementality/init` with the store slug and a visitor id. 2. Hemsy assigns the visitor to **treatment** (90%) or **control** (10%). The assignment is stable for that visitor. 3. Control visitors get a CSS hide on the selectors you saved in the dashboard (your Hemsy buttons, nav links, and any other CTAs). 4. The Shopify Ajax cart is tagged with `hemsy_group` and `hemsy_visitor_id` so later orders can be bucketed. The result is cached in `sessionStorage` for the rest of that tab. Later pages in the same tab do not call init again. The hide styles are re-applied from that cache on each page load. > [!NOTE] > > Add at least one CSS selector before enabling the dashboard toggle. One > selector per line: IDs or class names of every Hemsy CTA on the storefront. > If the holdout group has nothing to hide, both groups see Hemsy and the test > measures nothing. ## Dashboard On **Incrementality** you can: * Enable or disable Incrementality Mode * Edit the holdout CSS selectors * Compare baseline vs Hemsy conversion, lift, and net new revenue over a date range Shopify must be connected. Metrics stay available when the mode is off; they reflect any earlier test data in the selected period. Dollar estimates stay hidden until there is enough data: at least 100 sessions in each group and at least 5 orders in the holdout group. The holdout split is fixed at 10% control. It is not merchant-configurable. Changing it mid-test would reassign visitors and contaminate the results. # JavaScript API Source: https://docs.hemsy.ai/embeds/javascript-api Open and close Hemsy programmatically with window.HemsyEmbed, and configure the embed with window.HemsyEmbedConfig. If you'd rather open Hemsy from JavaScript than from launcher attributes (for dynamic elements, custom routing, or your own event handling), use `window.HemsyEmbed`. The embed script must be loaded on the page. Either install path works, since the [theme extension](/embeds/shopify) and the [script install](/embeds/script) load the same script. > [!NOTE] > > The API uses the original mode identifiers: `"scratch"` is Sandbox mode and > `"closet"` is Bundle mode. ## Opening ```js theme={null} // Sandbox (blank interactive experience) HemsyEmbed.open("scratch"); // Product context, auto-built from the current page HemsyEmbed.open({ payload: { autoProductContext: true } }); // Bundle (explicit payload) HemsyEmbed.open("closet", { closet: "YOUR_URLSAFE_BASE64_PAYLOAD" }); // Shared look by short ID HemsyEmbed.open("share", { share: "FreyjHz4" }); // Guided flow with an empty look (same as a flow-only launcher) HemsyEmbed.open({ payload: { flow: "YOUR_FLOW_ID" } }); // Instant generation with a model and payload HemsyEmbed.open("instant", { model: "YOUR_MODEL_ID", closet: "YOUR_URLSAFE_BASE64_PAYLOAD", }); // Override the final action for this open only (checkout is the default) HemsyEmbed.open("scratch", { action: "cart" }); ``` Every call resolves its own mode and action: instant opens work without any script-level configuration, and instant and share opens coexist on the same page. Passing `action` in the payload overrides the page-level `data-hemsy-action` for that open only. ## Closing ```js theme={null} HemsyEmbed.close(); ``` ## Configuration with `HemsyEmbedConfig` `window.HemsyEmbedConfig` is the JavaScript alternative to script-tag data attributes, and the only place to register [event callbacks](/embeds/checkout-vs-cart#event-callbacks). Define it before the embed script loads: ```js theme={null} window.HemsyEmbedConfig = { subdomain: "your-store-subdomain", selector: ".hemsy-launcher", mode: "instant", // optional; page-wide instant default, same as data-hemsy-mode action: "cart", // optional; default action, same as data-hemsy-action cartStrategy: "native", // optional; same as data-hemsy-cart-strategy anonymousId: "visitor-42", // optional; same as data-hemsy-anonymous-id autoClose: false, // optional; same as data-hemsy-auto-close incrementality: true, // optional; same as data-hemsy-incrementality onItemAdded: (item) => {}, onItemRemoved: (item) => {}, onProductVariantData: (payload) => {}, }; ``` > [!NOTE] > > When the same setting appears both on `HemsyEmbedConfig` and as a script-tag > data attribute, the **script attribute wins**. Keep each setting in one place > to avoid surprises. # Launch Modes Source: https://docs.hemsy.ai/embeds/launch-modes Control what each click opens: Sandbox, PDP, Bundle, Share, Flow, or Instant Mode. Every launcher element decides its own launch mode from the attributes on that exact clicked element. The attributes are the same whether the [Shopify trigger block](/embeds/shopify) emits them from theme editor settings or you write them by hand with the [script install](/embeds/script). This page covers each mode and the order they're resolved in. ## Resolution order When a launcher is clicked, Hemsy picks the launch mode by checking, in order: 1. **Instant**: instant is requested (`data-hemsy-mode="instant"` on the element itself, or on the script tag as a page-wide default) **and** the element has `data-hemsy-model`. 2. **Share**: the element has `data-hemsy-share`. 3. **Product**: the element has `data-hemsy-auto-product-context="true"`. 4. **Bundle**: the element has `data-hemsy-closet`. 5. **Sandbox**: none of the above; opens the full experience blank. `data-hemsy-flow` starts a guided flow when the launch has an empty look (Sandbox, or a flow-only launcher). Bundle (`data-hemsy-closet`) and Share launches skip the guided flow: closet bypass jumps straight to visualization after a photo is chosen, and share opens the shared-look viewer. `data-hemsy-action` (checkout vs cart) is independent of launch mode. It only changes what the final CTA does. See [Checkout vs Cart](/embeds/checkout-vs-cart). ## Launcher attributes | Attribute | Example | Description | | - | - | - | | `data-hemsy-share` | `"FreyjHz4"` | Opens a previously shared look by its short ID. | | `data-hemsy-auto-product-context` | `"true"` | Auto-builds a product payload from the current PDP variant. Falls back to Sandbox if no variant is detected. | | `data-hemsy-closet` | `"eyJwcm9k..."` | Explicit URL-safe base64 product payload. Use for Bundle mode. | | `data-hemsy-flow` | `""` | Starts a guided flow on an empty-look launch. Ignored for Bundle and Share. Must be on the clicked element. | | `data-hemsy-mode` | `"instant"` | Requests Instant mode for this launcher. `"instant"` is the only value with meaning at the launcher level. | | `data-hemsy-model` | `""` | Model UUID for Instant mode. Takes effect when instant is requested on the element or the script tag. | | `data-hemsy-action` | `"cart"` | Overrides the final CTA (`checkout` or `cart`) for this launcher only. See [Checkout vs Cart](/embeds/checkout-vs-cart). | ## Sandbox The default. No launcher attributes needed. The shopper starts blank and builds a look from your full catalog. ```html theme={null} Design a look ``` ## Product context (PDP) Launch with the product the shopper is currently viewing. Hemsy reads the selected variant from the page (the add-to-cart form or a `?variant=` URL parameter) and pre-loads it. ```html theme={null} ``` If no variant can be detected, the launcher falls back to Sandbox mode. ## Bundle Pre-load one or more specific products, curated looks, bundles, or campaign selections, with an explicit payload on `data-hemsy-closet`. ```html theme={null} ``` The payload is a URL-safe base64 encoding of a JSON object listing products: ```json theme={null} { "products": [ { "variantId": 1234567890, "attributes": [{ "key": "_bundleTitle", "value": "Starter Bundle" }] } ] } ``` > [!NOTE] > > The attribute is named `data-hemsy-closet` for historical reasons. A "closet" > payload is how Bundle mode describes its products. The same payload format > powers `?closet=` deep links. For the full payload schema, bundle attribute keys (`_bundleId`, `_uniqueId`, and friends), encoding helpers, and a validation checklist, see [Deep Links](/deep-links#closet--structured-payload). Always wrap `data-hemsy-closet` values in quotes. ## Share Open a previously shared look by its short ID. Useful for marketing campaigns, emails, or featuring shopper-created looks on your storefront. ```html theme={null} ``` Share IDs are generated by Hemsy's in-app Share feature; you don't construct them yourself. ## Flow Launch a guided, step-by-step flow with an empty look: ```html theme={null} ``` Copy flow IDs from the dashboard. The shopper walks the steps, then can exit into free browse. Do not combine `data-hemsy-flow` with Bundle or Share launchers: those paths skip the guided flow. ## Instant Instant mode skips model selection and immediately generates a visualization with a specific model and product payload. The shopper clicks, sees the generation loading state, and lands on the result. Instant requires **both** pieces on the launcher element: 1. `data-hemsy-mode="instant"` to request the instant path. (Putting it on the script tag instead makes instant the default for every launcher with a model.) 2. `data-hemsy-model` for the model to generate with. Add `data-hemsy-closet` for the products to place on that model. If the model is missing, the instant path is skipped. ```html theme={null} See it on a model ``` ### Getting model IDs Model IDs are UUIDs assigned to each image in your store's model library: 1. Go to your store's **Models** page in the Hemsy dashboard. 2. Hover over any model image. 3. Click the copy icon in the bottom-left corner. ### Instant is per-launcher Instant only affects the launcher that requests it. Share buttons, `?share=` links, and programmatic opens on the same page all work normally alongside instant launchers, with no separate script tags needed. Instant combines normally with `data-hemsy-action="cart"` if your storefront owns cart state. See [Checkout vs Cart](/embeds/checkout-vs-cart). ## URL auto-open The embed script watches the page URL for `?share=` and `?closet=` parameters and opens the modal automatically on page load: ``` https://your-store.com/?share=FreyjHz4 https://your-store.com/?closet=eyJwcm9kdWN0cy... ``` This powers share links (recipients see the look immediately) and marketing campaigns (pre-load products from ads or emails). The parameter is removed from the URL after opening so a refresh doesn't re-trigger it. For SPAs, the script also intercepts `history.pushState` to catch client-side navigations. > [!NOTE] > > `?closet=` always opens a normal Bundle launch rather than instant > generation, since no model ID travels in the URL. For constructing these URLs, see [Deep Links](/deep-links). # Overview Source: https://docs.hemsy.ai/embeds/overview Add the Hemsy embed to your storefront: pick an install path, then configure launchers and what happens at checkout. Hemsy Embeds let shoppers open the full Hemsy visualization experience in a modal on your own storefront. Any element on the page can become a launcher. However it's installed, an embed comes down to three knobs: | Knob | Where it's set | What it controls | | - | - | - | | **Embed setup** | Once per storefront (theme editor or script tag) | Your store subdomain, which elements are launchers, and page-wide defaults | | **Launch mode** | Per launcher | What that click opens: Sandbox, product context, Bundle, Share, Flow, or Instant | | **Final action** | Page-wide default, overridable per launcher | What the final CTA does: Shopify checkout (default) or handing items to your cart | Everything else in these docs is payload detail or recipes for those three knobs. ## Choose your install There are two ways to put Hemsy on a storefront. Both load the same embed script and use the same launcher attributes. The only difference is who writes the markup. > **[Shopify theme extension](/embeds/shopify)** > > For Online Store themes. Enable the app embed and add trigger blocks from > the theme editor. No code, and Hemsy handles the cart for you. > **[Script tag](/embeds/script)** > > For editing your theme code directly, or any page where you own the > markup. One script tag plus launcher attributes. | How you want to install | Install path | | - | - | | From the Shopify theme editor, no code | [Theme extension](/embeds/shopify) | | By editing your Shopify theme code | [Script tag](/embeds/script) | | On any other page you control (e.g., You own web app) | [Script tag](/embeds/script) | ## Configure it These pages apply to both install paths. The theme extension's settings map one-to-one onto the same launcher attributes you'd write by hand. > **[Launch modes](/embeds/launch-modes)** > > Sandbox, product context, Bundle, Share, Flow, and Instant, plus which one > wins when a launcher has multiple attributes. > **[Checkout vs Cart](/embeds/checkout-vs-cart)** > > Decide what the final CTA does, and sync Hemsy with your own cart state. > **[JavaScript API](/embeds/javascript-api)** > > Open and close Hemsy programmatically with `window.HemsyEmbed`. > **[Deep Links](/deep-links)** > > Payload schemas, bundle attributes, and URL encoding shared by embeds and > hosted links. # Script Install Source: https://docs.hemsy.ai/embeds/script Install the Hemsy embed by adding one script tag to your theme code, or to any page where you own the markup. One script tag turns any element on your page into a Hemsy launcher. Add it to your Shopify theme code (for example `theme.liquid`) if you'd rather edit the theme yourself, or to any other page where you own the markup. > [!NOTE] > > Prefer not to touch code? The [theme app extension](/embeds/shopify) places > this same script for you from the theme editor. ## Install ```html theme={null} Design a look ``` Any element matching `data-hemsy-selector` becomes a launcher. With no extra attributes, clicking it opens **Sandbox mode**: the full interactive experience, starting blank. What each launcher opens, and what its final CTA does, is controlled by [launcher attributes](/embeds/launch-modes). Use a shared class selector like `.hemsy-launcher` when multiple elements should open Hemsy. Avoid reusing the same `id` on multiple elements. > [!NOTE] > > Launchers are bound when the script loads. Elements added to the page later > (for example by client-side rendering after load) will not automatically > become launchers. Use the [JavaScript API](/embeds/javascript-api) for > dynamic elements. One exception: the script re-scans for launchers on > Shopify's `shopify:section:load` event, so theme editor re-renders keep > working. ## Script attributes | Attribute | Required | Example | Description | | - | - | - | - | | `data-hemsy-subdomain` | Yes | `"mystore"` | Your Hemsy store subdomain. For `mystore.hemsy.ai`, use `"mystore"`. | | `data-hemsy-selector` | Yes | `".hemsy-launcher"` | CSS selector for elements that launch Hemsy. | | `data-hemsy-mode` | No | `"instant"` | Page-wide default for [Instant mode](/embeds/launch-modes#instant). Prefer setting `data-hemsy-mode="instant"` on individual launchers instead. | | `data-hemsy-action` | No | `"cart"` | Default final CTA behavior: `"checkout"` (default) opens Shopify checkout; `"cart"` hands items to your cart. Individual launchers can override it. See [Checkout vs Cart](/embeds/checkout-vs-cart). | | `data-hemsy-cart-strategy` | No | `"native"` | With the `cart` action, `"native"` makes Hemsy add returned items straight into the Shopify cart itself. Uses Shopify's Ajax cart API, which every Online Store theme has. See [Native cart strategy](/embeds/checkout-vs-cart#native-cart-strategy). | | `data-hemsy-anonymous-id` | No | `"visitor-42"` | Anonymous visitor ID passed through to Hemsy for analytics and order metadata. See [Segment](/segment). | | `data-hemsy-auto-close` | No | `"false"` | Keep the modal open after the cart handoff instead of closing it. | | `data-hemsy-incrementality` | No | `"true"` | Opt this page into incrementality init. Required for the storefront holdout. See [Incrementality](/embeds/incrementality). | Event callbacks (`onItemAdded`, `onItemRemoved`, `onProductVariantData`) are configured on `window.HemsyEmbedConfig`, not as data attributes. See [Checkout vs Cart](/embeds/checkout-vs-cart#event-callbacks). Without the native cart strategy, `onProductVariantData` is how returned items reach your cart. ## Rules worth knowing up front * Instant mode and the final action are **per launcher**: set `data-hemsy-mode="instant"` or `data-hemsy-action` on a launcher element to affect just that button. The same attributes on the script tag act as page-wide defaults. Instant and Share launchers coexist fine on the same page. * Prefer `data-hemsy-action` for checkout vs cart. The legacy script-level `data-hemsy-mode="cart"` still works for backward compatibility, but `data-hemsy-mode` should be reserved for `"instant"`. * `data-hemsy-trigger` has no launcher semantics of its own. It's the conventional selector hook (`data-hemsy-selector="[data-hemsy-trigger]"`), which is what the [Shopify theme extension](/embeds/shopify) uses by default. # Shopify Theme Extension Source: https://docs.hemsy.ai/embeds/shopify Install Hemsy on a Shopify storefront from the theme editor: an app embed for the script and a trigger block for launch buttons. No code. The Hemsy Shopify app includes a theme app extension, so the script tag, launcher attributes, and checkout vs cart are configured from the Shopify theme editor instead of your theme code. Page-wide options without a theme editor setting, such as [incrementality](/embeds/incrementality), take one line of theme code. Your theme files are never edited, and uninstalling the app removes everything. The extension has two parts: | Part | What it is | Where it lives | | - | - | - | | **Hemsy Embed** (app embed) | Loads the embed script with your store slug and the page-wide checkout/cart default | Theme editor › **App embeds**, once per theme | | **Hemsy Trigger** (app block) | A styleable button or link that opens Hemsy, one per placement | Any section, typically product pages | > [!NOTE] > > Your Hemsy dashboard's **Embed** page has one-click deep links that open the > theme editor with each part pre-selected, plus your store slug ready to copy. ## 1. Enable the app embed 1. In the Shopify admin, go to **Online Store › Themes › Customize**, then open **App embeds** (the puzzle-piece icon). 2. Toggle on **Hemsy Embed**. 3. Paste your **Hemsy store slug** (copy it from the dashboard's Embed page). 4. Choose what happens **when shoppers finish**: * **Open Hemsy checkout** (default): Hemsy opens Shopify checkout directly. * **Add items to the store cart**: Hemsy adds the shopper's items straight into your store's cart using the [native cart strategy](/embeds/checkout-vs-cart#native-cart-strategy). No callback code is involved. 5. Save. The embed alone doesn't render anything. It binds any element matching `[data-hemsy-trigger]` as a launcher, which is exactly what the trigger block emits. ## 2. Add trigger blocks Add the **Hemsy Trigger** block to any section from the theme editor (product templates are the usual spot). Each block is its own launcher with its own settings: | Setting | What it does | | - | - | | **Opens** | The [launch mode](/embeds/launch-modes) for this button: Designer (blank canvas), this product page's item, a bundle of products, a shared look, or a guided flow. | | **Bundle products** | For bundle triggers: pick products in the editor and Hemsy builds the payload for you. | | **Share ID / Flow ID** | For shared-look and guided-flow triggers. Copy the IDs from the Hemsy dashboard. | | **Instant mode + Model ID** | Skips model selection and generates immediately with the given model. See [Instant](/embeds/launch-modes#instant). | | **When shoppers finish** | Inherit the app embed's checkout/cart setting, or override it for this button. | | **Display style, label, colors, sizing** | Button or link, full width, background/text/border colors, radius, padding, font size. | Because instant mode and the finish action are per-launcher, you can freely mix triggers on one page: an instant "See it on a model" button next to a shared-look button next to a plain designer link. ## Custom placements If you want to launch Hemsy from an element the trigger block can't reach (a nav link, a custom section), give that element the `data-hemsy-trigger` attribute plus any [launcher attributes](/embeds/launch-modes#launcher-attributes): ```html theme={null} Build a bed ``` The app embed's script binds it automatically, including elements re-rendered by the theme editor, which the script rebinds on `shopify:section:load`. ## Prefer editing code? Everything the extension does can also be done in your theme code: add the [script install](/embeds/script) to `theme.liquid` and put launcher attributes on your own elements. Same script, same attributes. Everything else in these docs applies equally to both install paths. # Endear Source: https://docs.hemsy.ai/endear Let stylists turn a Hemsy visualization look into an Endear story without leaving the visualization experience. Hemsy can push a finished visualization look into [Endear](https://endearhq.com) as a **story**. The story uses the generated visualization as its cover photo and attaches every product in the look, so your team can send it to a client from Endear like any other story. This is a **stylist-facing** integration. Shoppers never see it, and it does not forward analytics events. For that, see [Segment](/segment). ## Where it appears The **Send to Endear** button appears on the visualization result screen in **stylist surfaces** only: | Surface | How it's opened | | - | - | | **Stylist tab** in the Hemsy dashboard | Available to owners, admins, and members with the stylist role. | | **Stylist embed** in another tool | Hemsy loaded with the `stylist=1` parameter, for example inside Endear or a support desk: `https://hemsy.ai/embed/{subdomain}?embed=1&stylist=1` | The button is hidden in the shopper-facing [embedded and hosted experiences](/embeds/overview), and it only renders once an Endear API key is saved for that store. ## Before you start * An Endear account with API access. * Your Shopify catalog **synced into Endear**. Hemsy attaches products by their Shopify variant ID, so a look can only be sent if those variants already exist in Endear. * A Hemsy plan that includes **Integrations**. ## Setup 1. In the Hemsy dashboard, open **Integrations**. 2. On the **Endear** card, paste your **Endear API Key**. You'll find it in your Endear dashboard under **Settings › API**. 3. Save. The card shows **Connected**, and **Send to Endear** appears for stylists on that store. Your key is stored encrypted and is never exposed to the browser. Use **Replace API key** to rotate it, or **Disconnect** to remove it. Disconnecting immediately hides the button for stylists. > [!NOTE] > > Endear only needs an API key. Unlike Segment, there is no endpoint URL to > configure. ## Creating a story 1. Build the look and run the visualization as usual. 2. On the result screen, click **Send to Endear**. 3. Enter a **Title** (required) and an optional **Description**. 4. Click **Create Story**. Hemsy confirms with **Story created in Endear!** and the story is ready in Endear. ## What Hemsy sends Each story is built from the look on screen: | Story item | Contents | | - | - | | **Cover photo** | The generated visualization, uploaded to Hemsy storage and passed to Endear as a public image URL. No product is attached to this item. | | **One item per product** | The Endear product variant for the selected Shopify variant, plus that variant's catalog image (falling back to the look image when the variant has none). | Hemsy resolves the Endear variant reference from your synced catalog, so Shopify variant `41931355815995` becomes `shop://{shop-integration-id}/ProductVariant/41931355815995`. ## Troubleshooting | Message | What to do | | - | - | | **One or more products were not found in Endear. Make sure your catalog is synced.** | The look contains variants Endear doesn't know about. Re-sync the Shopify catalog in Endear, then try again. | | **No synced products found in Endear. Sync your catalog before creating stories.** | Endear has no Shopify products at all, so Hemsy can't resolve variant references. Connect and sync the catalog in Endear first. | | **Endear created the story but no products were added.** | The story was created but every product failed to attach. Confirm the catalog is synced and that the variants in the look exist in Endear. | | **Not allowed to create stories with this API key.** | The key lacks story permissions or belongs to a different account. Generate a new key in Endear and replace it in **Integrations**. | | **Endear integration not configured** | No API key is saved for this store. Add one in **Integrations**. | If **Send to Endear** never appears, check that the card shows **Connected** and that you're in a stylist surface. The button is intentionally hidden in shopper-facing embeds. ## Related docs * [Segment](/segment): forward shopper visualization events to your analytics pipeline * [Hemsy Embeds](/embeds/overview): how the visualization experience is embedded # Roles & Permissions Source: https://docs.hemsy.ai/permissions Owner, admin, viewer, and stylist access in the Hemsy merchant dashboard. Hemsy organizations have **members**. Each member is assigned a **role** that controls what they can view and change. Roles can apply to **all stores** in the org or only **selected stores**. ## Roles ### Owner Owners have full control over the organization, including billing and destructive actions. * Manage billing * Create, configure, and delete stores * Invite and remove team members, including other owners * Change member roles and store access scopes * Full read/write access to every assigned store ### Admin Admins can run day-to-day operations but cannot manage billing or delete the organization or its stores. * View and edit store configuration, flows, integrations, and catalog settings * Invite and remove team members (except owners) * Cannot manage billing * Cannot delete stores or the organization * Cannot promote members to owner or demote owners ### Viewer Viewers have read-only access to assigned stores. * View dashboards, analytics, and store settings * Cannot change configuration, invite users, or manage billing * Cannot use the Stylist tab ### Stylist Stylists are store associates who create looks with customers. Their dashboard shows only the **Stylist** tab and read-only **Settings**. * Use the Stylist tab to visualize looks and send them to customers (for example via [Endear](/endear)) * Cannot change configuration, invite users, or manage billing ## Permission matrix Permissions apply within each member's **store access scope** (see below). | Capability | Owner | Admin | Viewer | Stylist | | - | - | - | - | - | | View dashboards and analytics | Yes | Yes | Yes | No² | | View store settings | Yes | Yes | Yes | Yes | | Use the Stylist tab | Yes | Yes | No | Yes | | Edit store configuration | Yes | Yes | No | No | | Manage flows | Yes | Yes | No | No | | Manage integrations | Yes | Yes | No | No | | Invite and remove members | Yes | Yes¹ | No | No | | Change member roles | Yes | No | No | No | | Manage billing | Yes | No | No | No | | Delete stores or organization | Yes | No | No | No | ¹ Admins can invite and remove non-owner members. Only owners can invite other owners or change owner roles. ² Hidden from the stylist's navigation. Stylists keep read access to the store, so treat them like viewers when deciding who gets the role. ## Store access scopes When you invite a member or edit their access, choose how broadly their role applies: * **All stores**: the role applies to every store in the organization. * **Selected stores**: the role applies only to the stores you assign. The member cannot see or access other stores. If a member has no access to a store, that store is hidden from their dashboard entirely. ## What happens when access is denied Hemsy does not show disabled actions as grayed-out controls in every case. When a member lacks permission: * **No store access**: the store does not appear in navigation. Direct links to that store return a **404 / page not found** response. * **View-only user attempts a change**: the action is blocked with: *"You have view-only access..."* * **Admin attempts billing or delete**: the action is blocked with: *"Only organization owners can..."* * **Viewer opens the Stylist tab**: the page returns **404 / page not found**. ## Team management Manage members from **Organization settings** in the Hemsy dashboard. * **Owners** can invite members, assign roles, set store access scopes, and remove any member (as long as at least one owner remains). * **Admins** can invite and remove admins, viewers, and stylists on stores they can access. They cannot manage owners or billing. * **Viewers** and **stylists** cannot invite or manage team members. > [!NOTE] > > Every organization must have at least one owner at all times. You cannot > remove the last owner from an organization. ## FAQ > **Can an organization have multiple owners?** > > Yes. You can assign the owner role to multiple members. At least one owner > must remain on the organization at all times. > **Can admins manage billing?** > > No. Only organization owners can manage billing. > **Can a viewer see analytics for stores they are assigned to?** > > Yes. Viewers can view dashboards and analytics for their assigned stores. They > cannot change settings or invite team members. > **Which role should store associates get?** > > **Stylist**, scoped to the stores they work in. They get the Stylist tab > without analytics in their navigation, and they can't change anything. > **What if I need someone to manage integrations but not billing?** > > Assign the **admin** role with access to the relevant stores. Admins can > manage integrations and store configuration without billing access. # Segment Source: https://docs.hemsy.ai/segment Forward Hemsy visualization events from the embedded or hosted experience to your Segment workspace. Hemsy can forward **browser-side visualization events** to [Segment](https://segment.com) as `track` calls. Use this when you want visualization behavior in the same pipelines as your storefront (GA4, Mixpanel, Klaviyo, Snowflake, and so on). This is separate from the **Analytics** page in the dashboard, which shows aggregated KPIs (sessions, conversion, revenue, and so on). Segment receives individual events with properties; Analytics computes rollups from Hemsy's internal event store. ## Where Segment forwarding applies Segment forwarding works in **both** ways shoppers use Hemsy: | Experience | URL pattern | How shoppers arrive | | - | - | - | | **Embedded experience** | `https://hemsy.ai/embed/{subdomain}?embed=1&…` | Your storefront loads `hemsy-embed.js` and opens Hemsy in a modal iframe. | | **Hosted experience** | `https://{subdomain}.hemsy.ai?…` | Shoppers open your store's Hemsy subdomain directly (link, QR code, email, and so on). | Both surfaces run the same visualization app and send events through the same browser API (`POST /api/events`). Segment is **not** limited to embeds. Segment forwarding does **not** apply to: * The **Hemsy dashboard** (merchant admin UI). The one exception is the **Stylist** tab, which runs the stylist embed; its events are forwarded with `source: stylist`. * **Server-only** events (for example attributed orders written by Shopify order webhooks). Those feed Analytics, not the Segment forwarder. ## Setup 1. In the Hemsy dashboard, open **Integrations**. 2. Under **Segment**, enter your **Segment Endpoint URL** (for most workspaces: `https://api.segment.io`). 3. Optionally enter your **Write Key** (required for standard Segment endpoints; leave blank only if your proxy authenticates requests another way). 4. Save. The card shows **Connected** when an endpoint is configured. Hemsy sends `POST` requests to `{endpoint}/v1/track` with JSON bodies in Segment's HTTP API shape. ## Identity stitching (`anonymousId`) To align Hemsy Segment events with your storefront identity graph, pass the same stable ID you use elsewhere (for example Segment's `anonymousId`). Hemsy sends this value as Segment's `anonymousId` on every forwarded `track`. If you do not pass one, Hemsy uses its own browser visitor ID (`hemsy_visitor_id` in `localStorage`), which will **not** match your site unless you bridge IDs yourself. There is no automatic cross-domain handoff from your storefront to `{subdomain}.hemsy.ai`. You must pass the ID explicitly using one of the methods below. ### Embedded experience Set `data-hemsy-anonymous-id` on the embed script. The embed loader appends it to the iframe URL as `anonymous_id`: ```html theme={null} ``` You can also set `anonymousId` on `window.HemsyEmbedConfig` (see the [Embeds JavaScript API](/embeds/javascript-api)). ### Hosted experience Add the **`anonymous_id`** query parameter to any link to your Hemsy subdomain: ``` https://mystore.hemsy.ai?anonymous_id=visitor-42 ``` Works alongside other parameters: ``` https://mystore.hemsy.ai?anonymous_id=visitor-42&flow= https://mystore.hemsy.ai?anonymous_id=visitor-42&closet= ``` Use the same ID you use on your storefront and in Segment. When a shopper lands without `anonymous_id`, only Hemsy's generated visitor ID is used. ### Checkout metadata The same `anonymous_id` is attached to the Shopify cart as a cart attribute (`anonymous_id`) when the shopper checks out from either experience, so it shows under the order's **Additional details**. ## How forwarding works 1. The shopper uses the **embedded** or **hosted** visualization experience. 2. The browser records the event in Hemsy and POSTs to `/api/events`. 3. If Segment is configured, Hemsy forwards a **`track`** call with a human-readable name prefixed with `Hemsy `. Forwarding runs only when: * The event has a Segment mapping (see [Forwarded events](#forwarded-events)). * Your store has a valid Segment endpoint saved in Integrations. * The request passes Hemsy's store context checks (host / origin / referer match your store slug or an allowed Hemsy host such as `hemsy.ai`, `{subdomain}.hemsy.ai`, staging, or local dev). ## Properties on every track call In addition to event-specific fields below, each forwarded `track` includes: | Property | Type | Description | | - | - | - | | `productIds` | `string[]` | Shopify product IDs for items in the shopper's look, when applicable. | | `variantIds` | `string[]` | Shopify variant IDs for items in the look, when applicable. | | `sessionId` | `string \| null` | Hemsy session ID for this tab visit (`sessionStorage`). | | `storeSlug` | `string` | Your Hemsy store subdomain slug. | | `source` | `string` | `browser` for shoppers, `stylist` for the in-store stylist embed. Filter on this to keep associate activity out of shopper metrics. | | `location_id` | `string` | Only on stylist events: the Shopify location the stylist selected. | Segment also receives `anonymousId` and an ISO `timestamp`. The same `sessionId` is attached to Shopify carts started from Hemsy as a hidden line-item property, `_hemsy_session_id`, so orders can be joined back to the session's events. ## Forwarded events ### Session and engagement | Segment event | When it fires | Event properties | | - | - | - | | **Hemsy Session Started** | Once per browser tab session when the visualization experience loads and analytics bootstraps. | - | | **Hemsy Session Engaged** | Once per session, 10 seconds after load (shopper remained in the experience). | - | ### Visualization funnel | Segment event | When it fires | Event properties | | - | - | - | | **Hemsy Try On Started** | Shopper starts visualization generation (photo + at least one item). | `selectedItemCount` | | **Hemsy Try On Completed** | Visualization succeeds and the result screen is shown. | `selectedItemCount` | | **Hemsy Try On Failed** | Visualization fails, returns without a generated image, or the store cannot generate (plan limit reached, model provider missing). | `reason`: e.g. `no_product_images`, `Generation failed`, `LIMIT_EXCEEDED`, `MERCHANT_MODEL_PROVIDER_REQUIRED`; `status`: HTTP status when a response was received; `code`: Hemsy error code when the response carried one | ### Look building | Segment event | When it fires | Event properties | | - | - | - | | **Hemsy Added Item to Look** | Shopper adds a product variant to their look. | `productTitle` | | **Hemsy User Photo Uploaded** | Shopper uploads a photo from their device. | - | | **Hemsy Model Photo Selected** | Shopper picks a photo from the model library. | `model_id` | ### Guided flows When a merchant **flow** is active (`data-hemsy-flow` on embed launchers, or `flow` query param on the hosted experience): | Segment event | When it fires | Event properties | | - | - | - | | **Hemsy Flow Step Completed** | Shopper completes a flow step by adding an item and advancing. | `flow_name`, `flow_id`, `flow_step_name` | | **Hemsy Flow Step Skipped** | Shopper skips a non-required step. | `flow_name`, `flow_id`, `flow_step_name` | | **Hemsy Flow Exited** | Shopper leaves the guided flow. | `flow_name`, `flow_id`, `flow_step_name` | ### Browse, filter, and search In free-browse mode (no active flow): | Segment event | When it fires | Event properties | | - | - | - | | **Hemsy Filter Selected** | Shopper selects a category in Filter & Sort. | `filter_name`, `filter_scope` | | **Hemsy Sort Selected** | Shopper changes sort (not "Featured"). | `sort_name`: `price-low`, `price-high`, etc. | | **Hemsy Search Submitted** | Shopper submits a catalog search (Enter). | `query`, `result_count` | ### Result screen | Segment event | When it fires | Event properties | | - | - | - | | **Hemsy Try On Edited** | Shopper edits the look from the result screen. | `action`: `edit`, `swap`, or `remove` | | **Hemsy Checkout Clicked** | Shopper taps checkout (or cart handoff in embed `cart` mode). | `selectedItemCount`, `hasStorefrontToken`, `fromSharedLook`, `sharedLookShortId` | | **Hemsy Look Shared** | Shopper shares the result. | See [Hemsy Look Shared](#hemsy-look-shared) below. | ### Hemsy Look Shared This event fires on two different paths depending on whether **share links** are enabled for your store (`sharing_enabled` in Hemsy, or always on staging/preview hosts). | `type` | When | Segment properties | | - | - | - | | `share_link` | Share links are enabled. Hemsy creates a persisted share URL, then surfaces it to the shopper. | `shortId`, `shareUrl`, `storeSlug`, `selectedItemCount`, `usedNativeShare` | | `share_image` | Share links are disabled. Hemsy shares or downloads the visualization only (no share URL). | `storeSlug`, `selectedItemCount` | #### `usedNativeShare` vs `shareUrl` (`type: share_link` only) These answer different questions: | Property | What it tells you | | - | - | | `usedNativeShare` | **How** the link was surfaced: `true` if the browser native share sheet was used (`navigator.share` with the URL, common on mobile), `false` if Hemsy fell back to copying the link to the clipboard (typical on desktop when Web Share API is unavailable or fails). | | `shareUrl` | **What** link was shared: the URL recipients can open (for example `https://yourstore.com/?share=FreyjHz4` when redirecting to the store embed, or your hosted `https://{subdomain}.hemsy.ai/?share=…` URL). | Hemsy **always tries** the native share sheet first when `navigator.share` is available and the share completes without cancellation. If that is not available or fails (other than the user dismissing the sheet), Hemsy copies `shareUrl` to the clipboard and sets `usedNativeShare` to `false`. Cancelling the native sheet does **not** fire **Hemsy Look Shared**. `share_image` does not include `usedNativeShare` or `shareUrl`. That path uses the native share sheet with an image file when supported, otherwise a download. It is separate from the share-link pipeline in `createShareHandler`. ### Sharing | Segment event | When it fires | Event properties | | - | - | - | | **Hemsy Shared Look Opened** | When this event is reported through the browser events API. | `shortId` (when present) | > [!NOTE] > > Shared look opens are always counted in Analytics (Top Shares). Confirm > **Hemsy Shared Look Opened** in your Segment debugger for your traffic; > contact Hemsy if you need guaranteed Segment delivery on every open. ## Example track payload ```json theme={null} { "anonymousId": "visitor-42", "event": "Hemsy Try On Completed", "properties": { "selectedItemCount": 3, "productIds": ["123", "456"], "variantIds": ["789", "101112"], "sessionId": "a1b2c3d4-...", "storeSlug": "mystore" }, "timestamp": "2026-05-20T15:04:05.123Z" } ``` ## Testing 1. Save your Segment endpoint (and write key) in **Integrations**. 2. **Embedded experience:** Open Hemsy from your storefront with `data-hemsy-anonymous-id` set to a test ID (for example `segment-test-001`). 3. **Hosted experience:** Open `https://{subdomain}.hemsy.ai?anonymous_id=segment-test-001` and run through upload › add items › visualization › checkout. 4. In Segment **Sources › Debugger**, confirm `Hemsy *` track events with `anonymousId: segment-test-001`. If events are missing: * Confirm the integration shows **Connected**. * Confirm you are on the correct subdomain or embed slug. * Confirm the event is listed under [Forwarded events](#forwarded-events), not [Not forwarded](#not-forwarded-to-segment). ## Related docs * [Hemsy Embeds](/embeds/overview): embedded launch modes, `data-hemsy-anonymous-id`, cart vs checkout * Hemsy dashboard **Analytics**: aggregated KPIs and funnels (no Segment required) # Staging Source: https://docs.hemsy.ai/staging Test Hemsy changes on the staging environment before they reach production. Staging runs the latest pre-release build of Hemsy. Use it to check new features against your store before they ship to production. | Surface | Production | Staging | | - | - | - | | Shopper experience | `https://{subdomain}.hemsy.ai` | `https://staging.hemsy.ai/?store={subdomain}` | | Dashboard | `https://dashboard.hemsy.ai` | `https://staging.dashboard.hemsy.ai` | | Embed script | `https://hemsy.ai/hemsy-embed.js` | `https://staging.hemsy.ai/hemsy-embed.js` | ## Shopper experience Staging serves every store from one host, so you pick the store with `?store=` instead of a subdomain. Without `?store=`, staging shows the Hemsy landing page. ``` https://staging.hemsy.ai/?store=mystore ``` [Deep link](/deep-links) parameters work the same way. Add them next to `store`: ``` https://staging.hemsy.ai/?store=mystore&product=organic-cotton-duvet ``` ## Embed script Load the script from staging. The embed opens Hemsy from the same host that served the script, so every launcher on the page opens staging. Every other attribute stays the same as the [production install](/embeds/script). ```html theme={null} ``` The staging embed can be loaded from any page, including `localhost` and your own staging storefront, so you can test without changing your store's allowed domains. ## Dashboard Sign in at [staging.dashboard.hemsy.ai](https://staging.dashboard.hemsy.ai) to try dashboard changes before release.