# WEARFITS Virtual Try-On API

Base URL: https://api.wearfits.com

Last updated: 2026-11-06.

Use `POST /api/v1/virtual-fitting` for twin-backed try-on: it creates or reuses a digital twin. For raw-photo try-on without generating a twin, use `POST /api/v1/tryon/clothing` with `personImages` and `productImage`; an existing `digitalTwinId` can substitute its cached image for the person input.

## Minimal Request

```json
{
  "faceImage": "https://example.com/customer-face.jpg",
  "silhouetteImage": "https://example.com/customer-silhouette.png",
  "topGarment": "https://example.com/products/shirt.jpg",
  "bottomGarment": "https://example.com/products/pants.jpg",
  "gender": "female"
}
```

## Reuse A Digital Twin

```json
{
  "digitalTwinId": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "topGarment": "https://example.com/products/new-shirt.jpg",
  "options": { "preserveBackground": true }
}
```

`options.preserveBackground` keeps the avatar's background for outfit try-on when
true. It defaults to false, retaining the existing white-studio outfit behavior.
For new twins, `options.background` accepts `white` (default) or `dark`,
independently of gender. It cannot change a saved `digitalTwinId`; generate a
new twin for another background. White and dark requests create separate twins.

Create a dark-background twin inline and retain its background in the outfit:

```json
{
  "faceImage": "https://example.com/face.jpg",
  "bodyMeasurements": { "height": 180, "weight": 80 },
  "gender": "male",
  "poseId": "men_relaxed",
  "topGarment": "https://example.com/shirt.jpg",
  "options": { "background": "dark", "preserveBackground": true }
}
```

`men_relaxed` is relaxed front standing with weight on one leg and arms naturally
at the sides. `walking_pose` remains a walking alternative; the default male pose
remains `man_pose`.
`POST /api/v1/tryon/clothing` also supports `options.preserveBackground`,
but only uses person photos or a saved twin image and never creates a twin.

## Garment Fields

- `topGarment`
- `bottomGarment`
- `fullBodyGarment`
- `shoes`
- `productImage`

Slot fields accept a URL string or an array of one or two URLs. The first URL is the product packshot. The second URL is an optional on-model reference image. At least one of topGarment, bottomGarment, fullBodyGarment, or productImage is required; `shoes` can only be added on top of an outfit.

For single-product try-on, send `productImage` with optional `productCategory` (`auto`, `top`, `bottom`, `full-body`, `shoe`). This explicitly opts into the single-product path. A standalone shoe image is supported by this productImage path. For a 3D model with optional WEARFITS AR upload, use the separate shoe-3d endpoint.

Do not combine productImage with any garment slot, including shoes. Replace the
example digitalTwinId above with a saved 64-character lowercase hex twin ID.

## Raw-photo requests (no new twin)

POST /api/v1/tryon/clothing:

```json
{"personImages":["https://example.com/person.jpg"],"productImage":"https://example.com/shirt.jpg","productCategory":"top"}
```

POST /api/v1/tryon/shoes uses a different product field:

```json
{"personImages":["https://example.com/feet.jpg"],"shoeImages":[{"url":"https://example.com/shoe.jpg","angle":"side"}]}
```

Clothing accepts 1–3 personImages and shoes accepts 1–2. Each endpoint accepts
digitalTwinId instead of personImages, never both.
shoeImages accepts 1–4 objects; optional angle is front, side, or back.

## Status

The endpoint returns a job. Poll `GET /api/v1/jobs/{jobId}` with the same
authentication ownership until completed or failed. Read results[].url and
expiresAt; completed twin-backed jobs also expose digitalTwinId. Result-cache
hits can already be completed on submission. Poll with backoff and handle error
on failure. Store results before their URLs expire; do not treat them as permanent.

Keep merchant and service keys on your backend. Send protected requests with X-API-Key; consult each operation's security overrides in /doc.

For a merchant key or a bare service key, jobs and batches belong to that exact key. Another key gets 404 for jobs, but existing batches return 403 ACCESS_DENIED on ownership mismatch; keep the submitting key available while work is in flight. Service requests with X-Wearfits-Account instead use account ownership, so renewed account tokens retain access for the same account. Storefront tokens (wfs1.) have separate account-scoped ownership: they permit only POST /api/v1/virtual-fitting and GET /api/v1/jobs/{jobId}. They cannot create twins separately, call size-fitting, generate 3D assets, or cancel jobs. Renew an expired token server-side for the same account; do not switch authentication modes while polling.

For server-to-server callbacks submitted with a private merchant/bare service key, verify X-Webhook-Signature (sha256= followed by lowercase hex) with HMAC-SHA256. The HMAC key is the UTF-8 lowercase SHA-256 hex digest of that private key. Account-attributed service requests instead use SHA-256 of "account:" + the account ID; storefront requests use SHA-256 of "storefront:" + that ID. Those identifier-derived values are not private webhook secrets: prefer authenticated polling for those modes, rather than treating their signatures as proof of origin. Job callbacks sign compact JSON with object keys sorted recursively (array order retained); batch callbacks sign the exact request body bytes. Compare signatures in constant time, validate X-Webhook-Timestamp against the payload timestamp and your replay window, and deduplicate callbacks. Job delivery makes up to 3 attempts; batch delivery has no retry recovery. Retain polling as a fallback and fetch the final job for full 3D result details.

## OpenAPI

Machine-readable OpenAPI is available at https://api.wearfits.com/doc.
