Metron

One element for the widget. One endpoint for the API.

Most stores only need the drop-in widget. Call the REST API from your server if you're building your own try-on UI.

product page · htmlthe whole integration
<script src="https://cdn.vto.apeiro.clothing/widget/v1/apeiro-vto.js" async></script>

<apeiro-tryon
  data-key="pk_live_…"
  data-product-id="SKU-123"
  data-product-name="Linen overshirt"
  data-garment-image="https://images.brand.co.za/products/overshirt-front.jpg">
</apeiro-tryon>

Widget

Add the script once per page and one <apeiro-tryon> element where the button should appear. Until a shopper presses Try it on, the only request is one small anonymous "button seen" event for your dashboard's funnel. The script is about 13 KB compressed and loads async.

AttributeRequiredWhat it is
data-keyYesYour publishable key. A secret key is refused.
data-product-idYesYour product id or SKU. Used in reporting and events.
data-garment-imageYesThe https:// image to try on, from a host on your image allowlist.
data-product-nameNoUsed in the popup copy.
data-button-labelNoButton text. Default: Try it on.

Restyle it with --apeiro-accent, --apeiro-accent-text, --apeiro-radius and --apeiro-font, or the ::part(button) part. By default it inherits your page font.

Platform snippets, variants, CSP and troubleshooting are in the full integration guide.

Authentication

Every brand gets two keys. Both only accept garment images from your image hosts, and the publishable key only works on your allowed domains.

pk_live_…

Publishable key

Goes in your theme. It only works from your own domains, so it is safe in public HTML.

sk_live_…

Secret key

Server only. Any request that carries an Origin header is refused, so it cannot be used from a browser.

base url · header
https://api.vto.apeiro.clothing/v1
Authorization: Bearer sk_live_…

Try-on endpoint

Start a try-on with a multipart POST, then poll for the result. You collect the shopper's consent before sending their photo.

POST/v1/tryonsStarts a try-on.
GET/v1/tryons/:idGets a try-on's status and result.
GET/v1/usageThis month's quota, used, in-flight and remaining try-ons. Secret key only.
GET/v1/whoamiChecks your key. Returns your brand and key prefix.
GET/v1/healthService status. No auth.

Request fields

FieldRequiredNotes
photoYesFile. JPEG, PNG or WebP (checked from the file contents), up to 8 MB, short edge at least 256 px, at most 40 megapixels. HEIC isn't supported: convert to JPEG first.
garmentImageUrlYeshttps:// URL of the product image, up to 2048 characters, on your image allowlist.
productIdYesYour product id or SKU, 1 to 200 characters.
consentYesMust be the string true: the shopper agreed to their photo being processed.
sessionIdNoYour own opaque id for the shopper's session (up to 100 characters), for your reporting.
POST /v1/tryons · from your server
curl -X POST https://api.vto.apeiro.clothing/v1/tryons \
  -H "Authorization: Bearer $APEIRO_SK" \
  -F "photo=@shopper.jpg;type=image/jpeg" \
  -F "garmentImageUrl=https://images.brand.co.za/products/overshirt-front.jpg" \
  -F "productId=SKU-123" \
  -F "consent=true"

# 202  id + status "processing"  -> generation started
# 200  id + status "succeeded"   -> an identical recent try-on was reused (free)

Poll for the result

Poll right away, then every 1.5 seconds for 30 seconds, then every 3 seconds, giving up after 2 minutes. The result URL is a short-lived signed link to a WebP image.

GET /v1/tryons/:id · responses
{ "id": "…", "status": "processing" }

{ "id": "…", "status": "succeeded",
  "resultUrl": "https://…signed-link…",
  "expiresAt": "2026-11-11T14:30:00.000Z" }

{ "id": "…", "status": "failed",
  "error": { "code": "safety_blocked", "billable": false } }

Error codes

Every error has the same shape, and every response carries an x-request-id header. You are billed only for successful, newly generated try-ons.

{ "error": {
    "code": "quota_exhausted",
    "message": "This store's try-on allowance for the month is used up.",
    "requestId": "…"
} }
StatusCodeWhat to do
400validation_failedA field is missing or invalid, or the photo is too small or too large in pixels. Fix the request; do not retry as-is.
401missing_key, invalid_keyNo key, a wrong key or a revoked key. Check your secret key.
402quota_exhaustedMonthly allowance, plus any overage, is used up. Stop until next month or change plan.
403forbidden_key_typeA secret key was sent from a browser, or a publishable key was used on /v1/usage. Call from your server, with the secret key.
403brand_inactiveYour account is suspended. Contact us.
403garment_host_not_allowedThe garment URL (or a redirect) is not on your image allowlist. Ask us to add the host.
404not_foundUnknown try-on id.
410result_expiredThe result has been deleted. Start a new try-on.
413payload_too_largePhoto over 8 MB. Resize before sending.
415unsupported_media_typePhoto isn't JPEG, PNG or WebP. Convert to JPEG.
422garment_fetch_failedWe could not download the garment image. Check the URL is public, an image, and under 10 MB.
429rate_limitedToo many requests. Wait for the Retry-After seconds, then retry.
503service_unavailableTemporarily busy. Retry later; honour Retry-After if present.
500internal_errorUnexpected error. Retry later; send the requestId to support if it persists.

Failed generations (safety_blocked, generation_failed) come back in the GET response, not as HTTP errors, and are free. Only retry a POST on 429, 503 or a network error, and wait at least the Retry-After time. Never retry a 4xx unchanged.

Rate limits and usage

60try-on requests / minutePer key.
500try-ons / day, by defaultA per-brand safety cap.
Your plantry-ons / monthMonths run on South African time.
GET /v1/usage · response
{ "monthStart": "2026-10-31T22:00:00.000Z",
  "quota": 500, "used": 132, "inFlight": 1,
  "overageEnabled": false, "overageCap": null,
  "remaining": 367 }

These are current defaults. A 429 or 503 with Retry-After always tells you when to try again.

Widget events

The element dispatches DOM events that bubble to document. They never contain the shopper's photo, the result image or your key, so they are safe to forward to analytics. The widget never touches your cart: listen for add-to-cart and press your own button.

EventDetailWhen
apeiro:openproductIdThe shopper opened the popup.
apeiro:tryon-completeproductId, tryonId, fromCacheA result is showing.
apeiro:add-to-cartproductId, tryonIdThe shopper pressed Add to cart in the popup.
apeiro:errorproductId, codeSomething failed.
apeiro:closeproductId, stepThe popup closed.

Size recommendations Add-on · on request

Find my size is an add-on we switch on for your brand, after setting up your size charts with you. Until it's on, the attributes below do nothing and no button appears. It never uses a photo or try-on credits.

product pagethree new attributes
<apeiro-tryon
  data-key="pk_live_…"
  data-product-id="SKU-123"
  data-product-name="Linen overshirt"
  data-garment-image="https://images.brand.co.za/products/overshirt-front.jpg"
  data-size-recs="on"
  data-size-select="#product-size"
  data-privacy-url="https://yourbrand.co.za/pages/privacy">
</apeiro-tryon>
AttributeRequiredWhat it does
data-size-recsYes, onShows Find my size when the product has a published size chart. Leave it out, or set off, to turn it off per product.
data-size-selectNoA CSS selector for your own size picker. After a recommendation the widget selects that size there and fires input and change, so your theme switches the variant. It only selects an exact label match: "M" never selects "Medium".
data-privacy-urlNoYour privacy page, linked under the questionnaire. Default: APEIRO's.

Size-only products leave out data-garment-image: the element then shows only Find my size. Style the button with ::part(size-button), the same way as ::part(button).

Network

One small request on page load to check for a size chart, cached for 5 minutes. The questionnaire (about 10 KB) loads only when a shopper taps the button, from the same address as the widget. Your CSP needs nothing new.

The apeiro:size-recommended event

Fired on every result. Keep recommendationId and put it on the cart line, whatever size the shopper finally picks. That's how recommendations get better over time.

your theme
document.addEventListener("apeiro:size-recommended", (e) => {
  const { productId, recommendationId, recommendedSize, alternativeSize, confidence } = e.detail;
  // confidence: "high" | "medium" | "low"

  // Shopify: a hidden line item property in your product form,
  // <input type="hidden" name="properties[_apeiro_size_rec]" data-apeiro-size-rec>
  // so it reaches the order line as _apeiro_size_rec.
  const input = document.querySelector("[data-apeiro-size-rec]");
  if (input) input.value = recommendationId;
});

Tell us what happened to the order

Use one of these for an order, not both, or the same line is counted twice.

No code

Your store's order webhooks

Create order and refund webhooks in your Shopify or WooCommerce admin, or let our WooCommerce plugin set them up in one click. We work out per line which size was bought, whether it matched, and whether it was kept, refunded or exchanged.

Secret key

POST /v1/size-outcomes

From your server, once per order line, when you know the outcome.

  • kept
  • returned_too_small
  • returned_too_large
  • returned_other
  • exchanged

Full setup in the integration guide

Webhooks Planned

Not live yet. Two events are planned so your own systems can react to usage and billing changes.

usage.thresholdSent when a brand reaches 80% and 100% of its monthly allowance.
subscription.updatedSent when a plan is chosen, changed or cancelled.

Stuck on an install? Send us the error code.

Include the page URL, the time and the request id. Never send your secret key.