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.
<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.
| Attribute | Required | What it is |
|---|---|---|
| data-key | Yes | Your publishable key. A secret key is refused. |
| data-product-id | Yes | Your product id or SKU. Used in reporting and events. |
| data-garment-image | Yes | The https:// image to try on, from a host on your image allowlist. |
| data-product-name | No | Used in the popup copy. |
| data-button-label | No | Button 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.
Publishable key
Goes in your theme. It only works from your own domains, so it is safe in public HTML.
Secret key
Server only. Any request that carries an Origin header is refused, so it cannot be used from a browser.
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/tryons | Starts a try-on. |
|---|---|
| GET/v1/tryons/:id | Gets a try-on's status and result. |
| GET/v1/usage | This month's quota, used, in-flight and remaining try-ons. Secret key only. |
| GET/v1/whoami | Checks your key. Returns your brand and key prefix. |
| GET/v1/health | Service status. No auth. |
Request fields
| Field | Required | Notes |
|---|---|---|
| photo | Yes | File. 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. |
| garmentImageUrl | Yes | https:// URL of the product image, up to 2048 characters, on your image allowlist. |
| productId | Yes | Your product id or SKU, 1 to 200 characters. |
| consent | Yes | Must be the string true: the shopper agreed to their photo being processed. |
| sessionId | No | Your own opaque id for the shopper's session (up to 100 characters), for your reporting. |
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.
{ "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": "…"
} }| Status | Code | What to do |
|---|---|---|
| 400 | validation_failed | A field is missing or invalid, or the photo is too small or too large in pixels. Fix the request; do not retry as-is. |
| 401 | missing_key, invalid_key | No key, a wrong key or a revoked key. Check your secret key. |
| 402 | quota_exhausted | Monthly allowance, plus any overage, is used up. Stop until next month or change plan. |
| 403 | forbidden_key_type | A secret key was sent from a browser, or a publishable key was used on /v1/usage. Call from your server, with the secret key. |
| 403 | brand_inactive | Your account is suspended. Contact us. |
| 403 | garment_host_not_allowed | The garment URL (or a redirect) is not on your image allowlist. Ask us to add the host. |
| 404 | not_found | Unknown try-on id. |
| 410 | result_expired | The result has been deleted. Start a new try-on. |
| 413 | payload_too_large | Photo over 8 MB. Resize before sending. |
| 415 | unsupported_media_type | Photo isn't JPEG, PNG or WebP. Convert to JPEG. |
| 422 | garment_fetch_failed | We could not download the garment image. Check the URL is public, an image, and under 10 MB. |
| 429 | rate_limited | Too many requests. Wait for the Retry-After seconds, then retry. |
| 503 | service_unavailable | Temporarily busy. Retry later; honour Retry-After if present. |
| 500 | internal_error | Unexpected 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
{ "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.
| Event | Detail | When |
|---|---|---|
| apeiro:open | productId | The shopper opened the popup. |
| apeiro:tryon-complete | productId, tryonId, fromCache | A result is showing. |
| apeiro:add-to-cart | productId, tryonId | The shopper pressed Add to cart in the popup. |
| apeiro:error | productId, code | Something failed. |
| apeiro:close | productId, step | The 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.
<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>| Attribute | Required | What it does |
|---|---|---|
| data-size-recs | Yes, on | Shows 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-select | No | A 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-url | No | Your 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).
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.
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.
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.
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
Webhooks Planned
Not live yet. Two events are planned so your own systems can react to usage and billing changes.
Stuck on an install? Send us the error code.
Include the page URL, the time and the request id. Never send your secret key.