A product page's product, to try on
/v2/agent/looks/pieceWhich catalogue item the product on a store's page is, to try it on. It is the first call of the storefront's "Try it on" button on a product's photo: name the product the page shows, and the item's id comes back with the colour chosen on the page.
Render it on the shopper with POST /v2/agent/looks, passing the
itemId, piece: true, their photo as userPhotoUrl, the colour in
colours and the datasetIds returned here. A piece is never
rendered on a model.
The product is found by the SKU of the variant chosen on the page,
else by its title, in the store the page is on (store, as on the
chat) unless datasetIds are given. variant is that variant's own
title (Rust / XS): where part of it is exactly one of the product's
colours, that is the colour returned.
It is metered on the looks render resource
(api.v2.agent.looks.render) and its unit is always refunded: nothing
is drawn here.
The route answers OPTIONS preflight with 204 and allows any
origin, so it can be called directly from a storefront page, as the
looks and pose endpoints can.
Request body
application/jsonrequiredThe product on the page. A title or a sku is needed.
The product's title, as the store has it.
The SKU of the variant chosen on the page.
That variant's title, its options joined as Shopify writes them, e.g. Rust / XS.
Optional. The colour chosen on the page, as the store names it. Looked for first, so a colour written with a stroke of its own (Cobalt / Sky) is found; without it the colour is read from variant.
Optional. Limit the search to these datasets; they win over store.
Optional. The store the page is on, as on the chat.
The page's origin.
Shopify's permanent shop domain.
Optional. The shopper's two-letter country, for the price and what can be bought there.
Response
The catalogue item the page's product is.
Its name in the catalogue.
The colour chosen on the page, as the catalogue names it, or null. Send it to the looks endpoint in colours.
The datasets of the store the product was found in. Pass them to the looks endpoint with the render.
Errors
19Every error is JSON with a single error string unless noted. Match on the status code; the message is for humans.
This store does not offer seeing pieces on your own photo."See it on you" is switched off for the store, or for the organization.
This product is not in the catalogue yet, or cannot be bought where you are.No active item in scope is that product, or it is sold out or not sold in the shopper's country.
product needs a title or a sku.product is missing, or carries neither a title nor a sku.
curl -X POST "https://stylor.ai/api/v2/agent/looks/piece" \
-H "Authorization: Bearer $STYLOR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"product": {
"title": "Top - Cheyenne Western Shirt",
"sku": "23WS1801-HTB-1",
"variant": "Horse Trails Buckskin / XS"
},
"store": {
"origin": "https://lovleiranch.com"
},
"country": "US"
}'{
"piece": {
"itemId": "59989728-3920-4be9-9ae3-38031aa72d3f",
"name": "Top - Cheyenne Western Shirt",
"colour": "Horse Trails Buckskin"
},
"datasetIds": [
"eabedae0-47a5-4233-a7cc-3ddc01fa4254"
]
}