A product page's product, to try on

post/v2/agent/looks/piece

Which 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.

Public keyapi.v2.agent.looks.renderNo demo

Request body

application/jsonrequired
objectrequired

The product on the page. A title or a sku is needed.

titlestring

The product's title, as the store has it.

skustring

The SKU of the variant chosen on the page.

variantstring

That variant's title, its options joined as Shopify writes them, e.g. Rust / XS.

colourstring

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.

datasetIdsarray<string>

Optional. Limit the search to these datasets; they win over store.

object

Optional. The store the page is on, as on the chat.

originstring

The page's origin.

shopstring

Shopify's permanent shop domain.

countrystring

Optional. The shopper's two-letter country, for the price and what can be bought there.

Response

200The piece.
objectrequired
itemIdstringrequired

The catalogue item the page's product is.

namestringrequired

Its name in the catalogue.

colourstringnullablerequired

The colour chosen on the page, as the catalogue names it, or null. Send it to the looks endpoint in colours.

datasetIdsarray<string>required

The datasets of the store the product was found in. Pass them to the looks endpoint with the render.

Errors

19

Every error is JSON with a single error string unless noted. Match on the status code; the message is for humans.

403
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.

404
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.

422
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"
}'
Response · 200
{
  "piece": {
    "itemId": "59989728-3920-4be9-9ae3-38031aa72d3f",
    "name": "Top - Cheyenne Western Shirt",
    "colour": "Horse Trails Buckskin"
  },
  "datasetIds": [
    "eabedae0-47a5-4233-a7cc-3ddc01fa4254"
  ]
}