# Revieve Developer Docs — full text
This file is the entire site, concatenated. It is generated; do not edit.
---
## Revieve Developer Docs
Source: src/content/docs/index.mdx
> Computer-vision API for beauty brands and retailers: skin analysis, makeup and hair from one selfie.
import { CardGrid, LinkCard } from "@astrojs/starlight/components";
import BuildGrid from "../../components/BuildGrid.astro";
## Use cases
Every picture is real API output, unless it is marked as an illustration.
## Start here
## Looking for virtual try-on?
For real-time, webcam-based makeup, hair-colour, or full-look try-on in the browser, use **Revieve Virtual Try-On** — a separate product with its own multi-hundred-point face tracking, optimised for live video on mobile and desktop, with on-device frame processing.
---
## Introduction
Source: src/content/docs/introduction.mdx
> What Revieve provides, how the two APIs fit together, and who they are intended for. Includes when to use the Virtual Try-On product instead.
import { Aside } from "@astrojs/starlight/components";
Revieve is a beauty-tech platform whose core capability is turning user images into structured, actionable data about skin, hair, and makeup — and then mapping that data onto your product catalog.
This site documents the two APIs that surface that capability:
- **Skin Analysis API** — a server-side computer-vision endpoint that accepts a JPEG and returns per-metric scores, regional measurements, masks, categorical findings, and image-quality warning/error codes.
- **Product Recommendations API** — a catalog-aware service that consumes analysis output (and optionally explicit user preferences) and returns ranked product picks for your catalog taxonomy.
## Who this is for
The docs assume you are one of:
- An **engineer** integrating Revieve into a brand or retailer's web or mobile app.
- An **internal team** building Revieve-powered consumer experiences (concierge, regimen builders, in-store kiosks).
- An **AI coding agent** acting on behalf of one of the above. (See the [AI agents page](/ai-agents/) for a structured ingestion route.)
## What good looks like
A clean integration usually has three layers:
1. **Capture** — a camera/upload UI that produces a face-forward JPEG of at least 600×600 pixels.
2. **Analyze** — a single `POST` to the Skin Analysis API with the components your experience needs.
3. **Apply** — render results back to the user (visualization overlays, shade picks, product cards), optionally piped into Product Recommendations.
The [Your first skin analysis](/guides/your-first-skin-analysis/) walk-through covers this end-to-end in about ten minutes.
## What's *not* documented here
- **Onboarding and Partner ID provisioning.** Reach out to your Revieve account contact. The test ID `jmlv6b2qtS` works against `partner-test.revieve.com` for evaluation.
- **Revieve Virtual Try-On** — the real-time webcam-based try-on product. See the [VTO overview](/products/virtual-try-on/) and the [product page on revieve.com](https://www.revieve.com/platform/makeup/makeup-virtual-try-on); integration is sales-led.
- **The hosted concierge front-ends** (AI Skincare, Makeup, Haircare Advisors; AI Hair Color Artist) — products built *on top of* the APIs and the VTO engine.
## Where images are processed
The Skin Analysis API is **server-side**: images sent to it are uploaded to Revieve for analysis, and the results are returned in the response.
For real-time experiences (lipstick, eyeshadow, hair-colour try-on), use **Revieve VTO**. It runs in the browser on the user's own device, because face tracking at video frame rate isn't feasible over a network hop. The webcam video is not sent to Revieve during try-on.
Compliance and data-handling specifics for your deployment are governed by your Revieve agreement.
## Versioning posture
The Skin Analysis API uses a single base path and identifies itself by spec version (currently `3.x`). Changes are additive: new components, fields and status codes are added, and existing fields keep their shape and meaning. Each release is listed in the [Changelog](/changelog/).
---
## APIs at a glance
Source: src/content/docs/apis-overview.mdx
> Side-by-side summary of the Skin Analysis and Product Recommendations APIs — what each accepts, what each returns, and when to call which.
import { Tabs, TabItem } from "@astrojs/starlight/components";
import { Aside } from "@astrojs/starlight/components";
## Two products, briefly
This site documents the **Skin Analysis** and **Product Recommendations** APIs — both server-side, image- or data-in / JSON-out. For real-time webcam-based virtual try-on, use **[Revieve VTO](/products/virtual-try-on/)** — a separate browser-side product with its own face tracking. The split:
| You want… | Use |
| ---------------------------------------------------------- | -------------------------------- |
| Per-metric skin analysis (wrinkles, redness, age, …) | Skin Analysis API (this site) |
| Catalog-aware product recommendations | Product Recommendations API |
| Real-time makeup try-on (lipstick, eyeshadow, full looks) | **Revieve VTO** |
| Hair-colour try-on | **Revieve VTO** / AI Hair Color Artist |
## Skin Analysis API
A single `POST /analyzeImage/` endpoint that accepts a multipart-encoded JPEG and a small set of query parameters. Returns a JSON document containing:
- **`results`** — per-component findings (score, regional measurements, masks). Each finding also has its own `message` and `local_warnings` for problems that affect only that metric.
- **`face_area`** — bounding box and face rotation.
- **`status`** — global warning and error codes, expected to affect all or most metrics (see [Status codes](/concepts/status-codes/)).
- **`message`** — a one-word summary of `status`: `OK` (no codes), `Warning` (only warnings; the analysis ran) or `Error` (at least one error; the analysis could not run).
- **`inverse_color_balance_rb`** — inverse white-balance factors `[invR, invB, luminance]` for re-applying the image's colour cast to measured colours (see [Interpreting results](/guides/interpreting-results/#inverse_color_balance_rb)).
You ask for what you need via the `components` query parameter. Common picks:
| Use case | Components |
| ----------------------- | -------------------------------------------------------------------------- |
| Skin assessment | `wrinkles, redness, hyperpigmentation, acne, pore_dilation, skin_age` |
| Foundation shade match | `makeup` |
| Hair attribute readout | `hair` |
See the full reference at [`POST /analyzeImage/`](/api/skin-analysis/operations/analyzeimage/).
## Product Recommendations API
Catalog-aware ranked recommendations. You provide your catalog taxonomy and optionally pass through analysis output and user preferences.
See the reference at [/api/product-recommendations/](/api/product-recommendations/).
## When to call which
Capture image → Skin Analysis → render results → Product Recommendations using analysis output as input. This is the "expert consultation" pattern.
Use **[Revieve VTO](/products/virtual-try-on/)**. Real-time try-on is not built on the Skin Analysis API.
Capture image → Skin Analysis with `makeup` → read `Skin foundation RGB`, `Skin undertone`, `Skin Fitzpatrick type` from `sum_measures[]` → query Product Recommendations filtered by foundation taxonomy.
No image. Send only user preferences and inventory filters to Product Recommendations. Lighter integration, lower personalisation ceiling.
## Hosting and environments
| Environment | Base URL | When to use |
| ------------- | ----------------------------------------------------- | --------------------------------------------- |
| Test | `https://partner-test.revieve.com/api/3/` | Evaluation, integration, QA. |
| Production | `https://partner.revieve.com/api/3/` | Your live traffic. |
When your contract specifies a region, Revieve gives you a regional production host instead, with the same `/api/3/` path.
The test environment receives new CV versions before production, so a component documented here can reach test first; the [changelog](/changelog/) says which version each environment runs.
The Partner ID `jmlv6b2qtS` is a shared demo ID for use with the test environment. It is for evaluation and testing only, and Revieve may replace it at any time; if it stops working, find the current one here in the docs or ask the Revieve team. Revieve tells you which Partner ID to use in each environment.
---
## AI assistant integration
Source: src/content/docs/ai-agents.mdx
> Surfaces and reference material for grounding AI coding assistants in current Revieve API behavior — OpenAPI specs, llms.txt, common mistakes to verify against.
import { Aside, Card, CardGrid, LinkCard, Tabs, TabItem } from "@astrojs/starlight/components";
## Overview
If you're building a Revieve integration with help from an AI coding assistant (Claude, ChatGPT, Cursor, Copilot, an MCP-connected client), this page collects the surfaces that keep the assistant grounded in current API behavior — and the common mistakes worth verifying in any AI-generated code.
## Canonical references
## Ingestion surfaces
Three ways to feed these docs into an AI assistant:
[`/llms-full.txt`](/llms-full.txt) — every page concatenated, front-matter preserved. Best for one-shot context windows.
Every doc page has a markdown sidecar at `.md`:
- [`/guides/getting-started.md`](/guides/getting-started.md)
- [`/concepts/redness.md`](/concepts/redness.md)
Use these instead of scraping rendered HTML — they preserve front-matter, code blocks, and structure cleanly.
## Endpoint summary
```http
POST https://partner-test.revieve.com/api/3/analyzeImage/
Content-Type: multipart/form-data
# Required query params
?skintone=<0-6>
&gender=
# Optional but useful
&components=
&hairtype=<-1..4>
&skintone_rgb=
# Form fields
image=
partner_id=
```
Response is JSON. Branch on `data.message` (`"OK"` / `"Warning"` / `"Error"`) before reading `data.results[]`. The `data.status[]` array is the first thing to check on any non-OK message.
## Common mistakes in AI-generated code
When training data lags the current spec, AI assistants tend to make a recurring set of mistakes. Worth scanning generated code for these:
| Wrong | Right |
| --- | --- |
| Recommending the CV API for real-time virtual try-on | Use **[Revieve VTO](/products/virtual-try-on/)** — a separate browser-side product with its own multi-hundred-point face tracker |
| `Authorization: Bearer …` | `partner_id` form field on the multipart body |
| `?components=` empty / unset to mean "no metrics" | Omitting means *all defaults*; pass an explicit list to slim |
| Reading `value_raw` | Use `value` (normalized 0..1) |
| Sending PNG / HEIC | JPEG only; ≥ 600×600 px |
| `gender=other` / `gender=nonbinary` | Use `gender=unknown` |
| Branching on HTTP 200 alone | Branch on `data.message` *and* `data.status[]` |
| Treating `local_warnings[]` as a stable enum | Treat as advisory; code defensively per finding |
| Assuming one intensity scale for all visualization channels | Ranges differ per metric; see [Intensity ranges](/concepts/visualization/#intensity-ranges) |
| Confusing the `makeup` component with virtual makeup try-on | `makeup` *detects* shades for matching; *applying* virtual makeup is VTO |
| Calling features in `visualization_data` "heatmap points" | They're spots, polylines, or polygon-area features — see [Visualization data](/concepts/visualization/) |
## Suggested implementation order
1. [Getting started](/guides/getting-started/) and [Authentication](/guides/authentication/).
2. Generate a thin client from the OpenAPI spec.
3. Use the call from [Your first skin analysis](/guides/your-first-skin-analysis/) as a fixture in integration tests.
4. Map status codes to user-facing copy per [Error handling](/guides/error-handling/).
5. For each metric your UI surfaces, read the corresponding [concept page](/concepts/) for value semantics and rendering notes.
## When the assistant goes off-spec
If generated code references a component, status code, or response field that doesn't appear in the OpenAPI document at this site, it doesn't exist in the API — re-prompt with `/llms-full.txt` or the relevant page sidecar in context, or paste the OpenAPI spec back in.
---
## Playground
Source: src/content/docs/playground.mdx
> Try the Skin Analysis API directly from the browser. Upload a JPEG, pick components, see the live response, copy the equivalent code.
import { Aside } from "@astrojs/starlight/components";
import PlaygroundClient from "../../components/PlaygroundClient.astro";
Run a real call against `partner-test.revieve.com/api/3/analyzeImage/` from the browser. The playground talks directly to the test environment — no proxy, no backend.
The shared demo Partner ID `jmlv6b2qtS` is prefilled. It is for evaluation only and may be replaced at any time; use your own Partner ID for sustained testing.
## What this is for
- **Trying components without writing code.** Tick the boxes, upload a selfie, see what comes back.
- **Generating reproducible calls.** "Show as code" panel emits the equivalent `curl`, JavaScript, or Python — paste into your client.
- **Grounding AI integrators.** "Copy prompt" emits a self-contained prompt the user can hand to an LLM (Claude, ChatGPT, Cursor) along with the actual response.
- **Spot-checking spec changes.** When a new component lands, this is the fastest way to see its real shape.
## Privacy
Images are sent directly to `partner-test.revieve.com` for analysis and are not stored. Use the shared test ID for evaluation only, and your own Partner ID for anything else.
---
## Virtual Try-On
Source: src/content/docs/products/virtual-try-on.mdx
> Real-time, webcam-based try-on of makeup, hair colour and full looks in the browser. A Revieve product with its own integration, and how it fits with the Skin Analysis API.
import { Aside, LinkCard, CardGrid } from "@astrojs/starlight/components";
## Overview
Revieve's **Virtual Try-On (VTO)** lets shoppers try makeup, hair colour, and full looks in real time using their webcam, directly in the browser, on mobile and desktop. Multi-hundred-point face tracking, true-to-product colour and finish, and skin-tone and lighting adjustment, with no images posted to a server.
VTO is its own Revieve product with its own integration and developer documentation, provided during onboarding. This site documents the still-image APIs (Skin Analysis and Product Recommendations), which VTO complements rather than overlaps: if you are building real-time try-on, start with VTO; if you are scoring skin from a photo, you are in the right place.
## What VTO does, briefly
- **Real-time, in-browser.** Webcam frames are processed by the VTO product directly in the browser; you don't post images to the CV API for try-on use cases.
- **Multi-hundred-point face tracking.** Denser and finer-grained than what's needed for still-image analysis, optimised for live video.
- **All makeup categories.** Face, lips, eyes, eyebrows. Single products, bundles, full-face looks.
- **Inclusive by design.** Tracking optimised across ethnicities, demographics, ages, and genders.
- **AR rendering with skin-tone and lighting adjustment.** True-to-product colour, intensity, and finish.
- **Mobile and desktop.** Same product, different form factors.
## Why this matters for the CV API
VTO and the CV API are complementary, not overlapping:
| Use case | Use |
| ------------------------------------------------------- | -------------- |
| Real-time virtual try-on (lipstick, eyeshadow, looks) | **VTO** |
| Hair-colour try-on | **VTO** / AI Hair Color Artist |
| Diagnostic skin scoring (wrinkles, redness, age, …) | **Skin Analysis API** |
| Personalised product recommendations | **Product Recommendations API** |
| Foundation shade matching from a single still | Skin Analysis API (`makeup` component) |
## Why VTO runs on-device
VTO processes tens of webcam frames per second to keep the AR overlay smooth. Round-tripping each frame to a server is impractical at that rate — the latency budget for a perceived-instant try-on is well under what a network hop allows, and bandwidth would balloon. So VTO does its face tracking and rendering locally in the browser.
A side effect: the webcam video is processed in the browser and is not sent to Revieve during try-on.
Compliance and data-handling specifics for your deployment are governed by your Revieve agreement.
## Other Revieve consumer products
VTO is one of several consumer-facing products built on the Revieve platform. Each has its own page on revieve.com; integration is sales-led:
- **AI Skincare Advisor** — diagnostic skincare consultation built on the Skin Analysis API.
- **AI Makeup Advisor** — makeup recommendations + try-on.
- **AI Haircare Advisor** — diagnostic haircare consultation.
- **AI Hair Color Artist** — virtual hair-colour try-on.
These are turnkey solutions, ready to add to your site. The APIs documented here are the building blocks underneath them.
---
## Getting started
Source: src/content/docs/guides/getting-started.mdx
> Make your first authenticated call to the Skin Analysis API in under five minutes using a JPEG and a Partner ID.
import { Steps, Tabs, TabItem, Aside } from "@astrojs/starlight/components";
This guide gets you from zero to a successful round-trip against the test environment. It assumes nothing besides `curl` (or `fetch` / `requests`) and a frontal-face JPEG of at least 600×600 pixels.
1. **Pick or grab a test image.**
Any frontal-face JPEG of at least 600×600 pixels works. Strong even lighting and a neutral background give the cleanest results.
2. **Send the image.**
```bash
curl -X POST \
"https://partner-test.revieve.com/api/3/analyzeImage/?skintone=0&gender=unknown&components=wrinkles,redness,acne,skin_age" \
-F "partner_id=jmlv6b2qtS" \
-F "image=@./selfie.jpg"
```
```js
const form = new FormData();
form.append("partner_id", "jmlv6b2qtS");
form.append("image", fileInput.files[0]);
const url = new URL("https://partner-test.revieve.com/api/3/analyzeImage/");
url.searchParams.set("skintone", "0");
url.searchParams.set("gender", "unknown");
url.searchParams.set("components", "wrinkles,redness,acne,skin_age");
const res = await fetch(url, { method: "POST", body: form });
const data = await res.json();
```
```python
import requests
with open("selfie.jpg", "rb") as f:
res = requests.post(
"https://partner-test.revieve.com/api/3/analyzeImage/",
params={
"skintone": 0,
"gender": "unknown",
"components": "wrinkles,redness,acne,skin_age",
},
data={"partner_id": "jmlv6b2qtS"},
files={"image": f},
)
data = res.json()
```
3. **Read the top-level response.**
```json
{
"message": "OK",
"face_area": { "bounding_box": [...], "rotation": -2.1 },
"status": [],
"results": [
{ "description": "wrinkles", "value": 0.34, "message": "Ok", "..." },
{ "description": "redness", "value": 0.18, "message": "Ok", "..." }
]
}
```
- `message: "OK"` confirms the call succeeded with no quality issues.
- Each entry in `results[]` is one metric you asked for.
- `status[]` is empty here; if a code shows up, see [Interpreting results](/guides/interpreting-results/).
4. **Iterate on the `components` list.**
Trim it to exactly what your UI uses. Fewer components → faster response, smaller payload.
## What's next
- [Authentication](/guides/authentication/) — the Partner-ID model in detail.
- [Your first skin analysis](/guides/your-first-skin-analysis/) — a longer walk-through that wires the response into a UI.
- [Interpreting results](/guides/interpreting-results/) — how to render scores, masks, and overlays.
- [API reference](/api/skin-analysis/operations/analyzeimage/) — every parameter, every response field.
---
## Authentication
Source: src/content/docs/guides/authentication.mdx
> Partner ID model, test vs production credentials, allowed origins, and where the credential rides on each request.
import { Aside } from "@astrojs/starlight/components";
Revieve identifies callers by **Partner ID** — a short string issued to your account. There is no OAuth flow, no JWT, no session cookie, and no `Authorization` header. Authentication is a single multipart form field on every request.
## Where to put it
The Partner ID rides as a form field in the multipart body of `POST /analyzeImage/`:
```http
POST /api/3/analyzeImage/?skintone=0&gender=unknown HTTP/1.1
Content-Type: multipart/form-data; boundary=----X
----X
Content-Disposition: form-data; name="partner_id"
jmlv6b2qtS
----X
Content-Disposition: form-data; name="image"; filename="selfie.jpg"
Content-Type: image/jpeg
----X--
```
That's it. Don't add `Authorization` headers; they aren't read.
## Test vs production
| Environment | Partner ID | Base URL |
| ----------- | -------------------------- | ----------------------------------------- |
| Test | `jmlv6b2qtS` (shared demo), or your own | `https://partner-test.revieve.com/api/3/` |
| Production | Issued to your account | `https://partner.revieve.com/api/3/`, or the regional host in your contract |
The test ID is shared. Treat it like any public demo key: fine for evaluation, never for real users. Revieve may replace it at any time; if it stops working, find the current one here in the docs or ask the Revieve team. Revieve tells you which Partner ID to use in test and in production.
## Calling from the browser
The Partner ID is designed to be used in the browser, and Revieve's own front-end plugin does exactly that. What limits its use is the list of allowed origins that Revieve configures for your account: ask your Revieve contact to add the domains your production site runs on. A browser call from any other origin fails with a CORS error. Calling the API from your own backend works too, but is not required.
If you need a new Partner ID, ask your Revieve contact.
## What the server checks
- **Partner ID**: missing returns `404`, unknown returns `403`. See [Error handling](/guides/error-handling/).
- **Licence**: the Partner ID must be licensed for Skin Analysis and for the components you request; otherwise `403`.
- **Region routing** is determined by the production base URL you receive, not by anything in the request.
---
## Your first skin analysis
Source: src/content/docs/guides/your-first-skin-analysis.mdx
> Ten-minute walk-through wiring a captured JPEG into the Skin Analysis API and rendering the response into a UI.
import { Steps, Code, Aside, Tabs, TabItem } from "@astrojs/starlight/components";
import DemoPreview from "../../../components/DemoPreview.astro";
This goes one step beyond [Getting started](/guides/getting-started/): capture an image in a browser, send it to the Skin Analysis API, and render the response into a small UI.
The example uses plain HTML and `fetch` so it ports trivially into React, Vue, or any framework. About 60 lines of code, no build step.
## The full example
```html title="index.html"
Revieve demo
…or try a sample photo:
```
## What it does, step by step
1. **The user picks a JPEG.** Anything ≥ 600×600 px works. The sample strip loads one of the docs' model photos into the same file input, so the rest of the code does not care where the image came from.
2. **We build the URL.** Always send `skintone` and `gender`; without them the server falls back to fixed defaults that may not match your user. If you don't know them, send `skintone=0` and `gender=unknown` to let the analysis estimate them. Optional: `components` (we ask for four). The full list is in the [API reference](/api/skin-analysis/operations/analyzeimage/).
3. **We POST a multipart form.** The body has `partner_id` and `image`. Browsers set the `Content-Type` boundary automatically.
4. **We branch on the response shape.**
- `data.message === "OK"` — no global quality issues. Individual metrics can still fail: check each result's `message` and `local_warnings`.
- `data.message === "Warning"` — results are usable, but image quality is reduced; consider a UX nudge ("try better lighting").
- `data.message === "Error"` — the analysis could not run and `results` is `null`; show the `description` of the first `status[]` entry with `isError: 1` (earlier entries can be warnings).
5. **We render `results`.** Each entry we asked for here has a `value` between 0 and 1 — multiply by 100 for percentage UI. Not every metric works this way: integer/categorical findings (e.g. `skin_age`, `skin_type`) leave `value` null and carry their result in `sum_measures[]` instead — see below.
## Where to go from here
- For richer rendering, the `measurement_locations[]` and `mask_shapes` fields drive overlay visualizations. See [Interpreting results](/guides/interpreting-results/).
- For integer and categorical findings (skin age, skin type, undertone, hair type, eye color), look at `sum_measures[]` rather than the top-level `value` — for these, `value` is null.
- For real-time AR try-on, use [Revieve VTO](/products/virtual-try-on/) — the Skin Analysis API is for still-image scoring only.
## Common quality issues
| Symptom | Likely cause | Fix |
| --------------------------- | --------------------------------------------- | ----------------------------------------- |
| `idx: 100` (input format) | Image is not a colour (RGB) image, e.g. grayscale. | Send a colour image. |
| `idx: 101` (resolution) | Image smaller than 600×600. | Recapture at higher resolution — don't upscale. |
| `idx: 301` (face too small) | Face too small in the frame. | Prompt the user to move closer. |
| `idx: 103/104` (lighting) | Over- or under-exposed. | Reshoot in even lighting; warn the user. |
| `idx: 201` (no face) | Face is occluded or out of frame. | Prompt the user to recentre. |
| `idx: 308` (overexposure) | Hot spot from direct flash. | Use more diffuse light. |
---
## Interpreting results
Source: src/content/docs/guides/interpreting-results.mdx
> How to read the Skin Analysis response — top-level fields, per-finding shape, masks, visualizations, and what to render.
import { Aside } from "@astrojs/starlight/components";
The Skin Analysis response is one JSON document with five top-level fields: `message`, `face_area`, `inverse_color_balance_rb`, `status[]`, and `results[]`. This page explains each and how to render it. A sixth, `composites`, appears only when you request [composite metrics](/concepts/composites/) and Revieve has configured them for your partner ID.
## The shape
```jsonc
{
"message": "OK" | "Warning" | "Error",
"face_area": {
"bounding_box": [x_min, y_min, x_max, y_max],
"rotation": -2.4
},
"inverse_color_balance_rb": [1.05, 0.98, 1.02],
"status": [
{ "idx": 308, "description": "Image is overexposed at the face area. Find more diffuse lighting or reduce exposure.", "isError": 0 }
],
"results": [
{
"description": "redness",
"value": 0.23,
"value_raw": 3.21, // deprecated
"message": "Ok",
"local_warnings": [],
"measurement_locations": [
/* per-region scores; advanced visualization features live here,
on each location's own visualization_data[] */
],
"sum_measures": [/* derived/aggregate */],
"visualization_data": null // currently null at finding level — see below
}
]
}
```
## `message` — the global verdict
The first thing your UI should branch on:
- **`OK`** — no global quality issues. Individual metrics can still fail: check each finding's `message` and `local_warnings`.
- **`Warning`** — results returned, but `status[]` flags one or more quality issues. Show the score, optionally nudge the user to retry for better fidelity.
- **`Error`** — the analysis could not run and `results` is `null`. `status[]` explains why; show that and ask for a new image.
## `face_area` — geometry
`bounding_box` is `[x_min, y_min, x_max, y_max]` in pixels of the original image. `rotation` is degrees clockwise from vertical. Use them when overlaying masks or visualizations back onto the source frame.
## `status` — quality codes
Each entry has:
- **`idx`** — a numeric code (see [Status codes](/concepts/status-codes/) for the full reference).
- **`description`** — human-readable.
- **`isError`** — `1` is an error (no results), `0` is a warning (results are still returned).
Entries are listed in the order they were found. When `message` is `Error`, warnings found earlier come first, so use the first entry with `isError: 1`. When every requested metric failed, `status[]` also contains those metrics' errors, followed by `500`.
Common codes:
| `idx` | Meaning | Treatment |
| ----- | ------------------------------------------- | ---------------------------------- |
| 100 | Image not in RGB color format | Surface, ask for retry |
| 101 | Image resolution too small | Surface, ask for retry |
| 102 | Image aspect ratio too extreme | Surface, ask for retry |
| 103/104 | Image too dark / overexposed globally | Optional nudge |
| 201 | No face detected | Surface, ask for retry |
| 308 | Face area overexposed | Optional nudge |
Metric-level codes such as `401` appear in that finding's `local_warnings`, not in `status`. The full list is on [Status codes](/concepts/status-codes/).
## `results[]` — per-component findings
Each entry corresponds to one metric you requested.
### `value` vs `value_raw`
`value` is normalized to `0..1` for nearly every metric — what you should display. `value_raw` is the pre-normalization value and is **deprecated**: ignore it for new integrations.
`skin_age`, `skin_type`, `makeup` and `hair` are exceptions: they leave the top-level `value` null; their results are in `sum_measures` (see below).
### `measurement_locations[]`
Where on the face the score was computed. Each entry includes:
- A `description` (`"left cheek"`, `"forehead"`, …). `shine`, `glow` and `skin_sagging` also add a `Global` location that covers the whole face.
- A `value` for that region.
- AOI (area of interest) coordinates: `AOI_x_o`, `AOI_y_o`, `AOI_radius_o` (in original image pixels).
- `ut_zone` — `"u-zone"` | `"t-zone"` | `"none"` | `"mixed"`. `mixed` is part of either zone depending on the definition (e.g. `chin`).
- Optional `mask_shapes` (with the `masks` component) — the exact area that was analyzed. What was found there is in `visualization_data`.
### `sum_measures[]`
Aggregated or categorical sub-findings. Shape varies by metric:
- **Makeup** → face shape (1–6), eye color (1–3), skin undertone (−1 / 0 / +1), foundation RGB, Fitzpatrick type.
- **Hair** → color array, volume (0–1), type (0–4), frizziness (0 or 1).
- **Skin Age** → integer 0–100.
- **Skin Type** → integer 1–8 (normal, dry, oily, combination, sensitive variants).
### `visualization_data[]`
Optional per-metric advanced visualization — the third tier of [visualization data](/concepts/visualization/) (the first two being AOI circles and mask shapes). Returned only when the corresponding `_visualization` opt-in is in your `?components=...` query (e.g. `acne_visualization`, `wrinkles_visualization`, `redness_visualization`).
The field appears at two levels: **read it from each `measurement_locations[]` entry.** Features are currently returned only there; the finding-level `visualization_data` is `null`.
```js
const finding = response.results.find((r) => r.description === "redness");
const features = (finding.measurement_locations ?? []).flatMap(
(loc) => loc.visualization_data ?? []
);
```
Each feature is one of three implicit types — determined by the metric, not by a `kind` field:
- **Spot** — single point with intensity. Used by acne, freckles, dark spots, hyperpigmentation. `length: 1`, `x[0]` / `y[0]` is the centroid.
- **Polyline** — connected line of N points (one wrinkle, one fold). Used by wrinkles. `length: N`, `intensity` is an array of per-point intensities; `length_weighted_intensity` is the canonical "how bad is this wrinkle" composite.
- **Polygon area** — enclosed region whose `intensity` is a level index (`1`, `2`, `3`, …), not a normalized score. Used by redness, melasma, shine, glow, skin type, texture, uneven skin tone, pore dilation. For the threshold-based metrics higher levels nest inside lower ones; `shine` and `skin_type` draw their levels from separate source fields and don't nest. `skin_sagging` also uses polygons but carries a continuous intensity instead of levels. See [Visualization data](/concepts/visualization/#intensity-ranges) for per-metric ranges.
All coordinates are in original-image pixel space. For paste-ready render code, see [Rendering recipes](/guides/rendering-recipes/).
## `inverse_color_balance_rb`
A 3-element array — **not** `[r, g, b]`. The elements are:
| Index | Meaning |
| ----- | ------- |
| `[0]` | inverse **red** white-balance multiplier (`1 / red_correction`) |
| `[1]` | inverse **blue** white-balance multiplier (`1 / blue_correction`) |
| `[2]` | inverse **luminance** factor (`1 / luminance_correction`) |
Green is the reference channel (multiplier `1`), so it has no entry — hence the `rb` ("red/blue") in the name, plus the luminance term. When white balance can't be estimated the array is `[1, 1, 1]` (a no-op).
### What it's for
The analysis runs in a **white-balanced ("true colour") space** — the engine internally removes the image's colour cast before measuring. These factors are the **inverse** of that correction, so they let you take a true-colour RGB value and **re-apply the original image's colour cast**. The point is efficiency: instead of colour-correcting the whole user photo (expensive, and a global approximation can make the photo itself look off), you leave the photo untouched and only re-bias the handful of colours you draw on top of it, so they sit naturally on the original image.
So use it when you composite a **CV-measured colour** (e.g. a foundation/skin-tone swatch the API returned in true-colour space) onto the **original, uncorrected photo**. Apply per channel:
```js
const [iR, iB, iL] = response.inverse_color_balance_rb;
// trueColor = [R, G, B] in 0..255 (a colour the API measured in true-colour space)
function toImageCast([R, G, B]) {
return [
R * iR * iL, // red channel: inverse red WB × luminance
G * iL, // green channel: luminance only (green is the reference)
B * iB * iL, // blue channel: inverse blue WB × luminance
];
}
```
The result is how that colour appears under the photo's own lighting/cast, so it blends with the un-corrected image.
## A minimal renderer
```js
function summarize(response) {
if (response.message === "Error") {
return { ok: false, reason: response.status?.find((s) => s.isError === 1)?.description };
}
const scores = Object.fromEntries(
response.results
.filter((r) => typeof r.value === "number")
.map((r) => [r.description, Math.round(r.value * 100)])
);
return { ok: true, scores, warnings: response.status ?? [] };
}
```
That's enough for a percentage-bar dashboard. Mask overlays are documented in their respective concept pages.
---
## Error handling
Source: src/content/docs/guides/error-handling.mdx
> HTTP- and document-level error semantics, retry strategy, and a defensive client implementation for the Skin Analysis API.
import { Aside } from "@astrojs/starlight/components";
The Skin Analysis API has two layers of failure: HTTP-level (transport, Partner ID and licence) and document-level (image quality, per-metric model confidence). Each calls for different handling.
## HTTP-level
| Status | Cause | What to do |
| ------ | ---------------------------------------- | ------------------------------------------------------- |
| 200 | Success — but check `data.message` | Branch on `message`, then `status[]`. |
| 400 | Upload rejected, e.g. the image is not in the `image` field or more than one file was sent | Fix the call. |
| 403 | `Unauthorized / Invalid Partner ID`: the Partner ID is unknown | Check the ID and the environment (test and production IDs differ). |
| 403 | `Unauthorized / Invalid license for module`: the Partner ID is not licensed for Skin Analysis or for one of the requested components | Remove the component or ask your Revieve contact. |
| 404 | `Partner ID required`: no `partner_id` form field | Send the Partner ID in the multipart body. |
| 413 | Image larger than 30 MB | Resize client-side; aim for < 5 MB. |
| 500 | Analysis failed (`code: "1661"`), or the request had no image | Check that the image is a readable JPEG. Retry once at most. |
| 502/503/504 | Transient infrastructure issue | Retry with back-off. |
A browser request from an origin that is not on your account's allowed list does not get an HTTP error you can read: the browser blocks the response and reports a CORS or network error. See [Calling from the browser](/guides/authentication/#calling-from-the-browser).
## Document-level
A `200 OK` HTTP response can still report problems via `data.message` and `data.status[]`. The handling matrix:
| `message` | Meaning | UX |
| --------- | -------------------------------------------- | --------------------------------------------------------- |
| `OK` | No global quality issues | Render results. Individual metrics can still fail: check each finding's `message`. |
| `Warning` | Results usable, quality issue noted | Render results. Optionally surface advice from `status[]`. |
| `Error` | The analysis could not run; `results` is `null` | Hide result UI. Surface the `description` of the first `status[]` entry with `isError: 1`. |
Per-finding `local_warnings[]` arrays apply at the metric level — e.g. pore dilation may fail because face resolution wasn't sufficient even when the overall call succeeded. Hide that one card, keep the rest.
## A defensive client
```ts
async function analyze(file: File | undefined) {
// A request without an image returns HTTP 500. Do not send it, and do not retry it.
if (!file) {
throw new Error("No image to analyze");
}
const url = new URL("https://partner-test.revieve.com/api/3/analyzeImage/");
url.searchParams.set("skintone", "0");
url.searchParams.set("gender", "unknown");
const form = new FormData();
form.append("partner_id", PARTNER_ID);
form.append("image", file);
for (let attempt = 0; attempt < 3; attempt++) {
const res = await fetch(url, { method: "POST", body: form });
// 502/503/504 are transient infrastructure errors. Retry with back-off.
if ([502, 503, 504].includes(res.status)) {
await new Promise((r) => setTimeout(r, 250 * 2 ** attempt));
continue;
}
// 500 means the analysis failed (code 1661), often because of the image itself. Retry once at most.
if (res.status === 500 && attempt === 0) {
await new Promise((r) => setTimeout(r, 250));
continue;
}
if (!res.ok) {
throw new ApiError(`HTTP ${res.status}`, res.status);
}
const data = await res.json();
if (data.message === "Error") {
// Warnings can come before the error in status[]
const error = data.status?.find((s) => s.isError === 1);
throw new AnalysisError(
error?.description ?? "Analysis failed",
error?.idx,
);
}
return data;
}
throw new Error("Exhausted retries");
}
```
## Surface to users, log to ops
The `description` texts in `status[]` and `local_warnings[]` are English developer strings. Map `idx` to your own user-facing, translatable copy, and log the raw codes for debugging.
---
## Rendering recipes
Source: src/content/docs/guides/rendering-recipes.mdx
> Paste-ready Canvas / SVG renderers for the three advanced-visualization feature types — spots, polylines, polygon-areas.
import { Aside, Code, Tabs, TabItem } from "@astrojs/starlight/components";
import DemoPreview from "../../../components/DemoPreview.astro";
## Overview
This guide is paste-and-tune code for drawing the three feature types in [advanced visualization data](/concepts/visualization/#tier-3--advanced-concern-visualization):
| Feature type | Metrics | Recipe |
|---|---|---|
| **Spots** | acne, freckles, dark spots, hyperpigmentation | [→ Spots](#recipe-1--spots) |
| **Polylines** | wrinkles + sub-region variants | [→ Polylines](#recipe-2--polylines) |
| **Polygon areas** | redness, melasma, shine, glow, texture, uneven skin tone, skin sagging, pore dilation | [→ Polygon areas](#recipe-3--polygon-areas) |
The renderers below are vanilla Canvas 2D, no dependencies. Same iteration shape, same render rules, simplified to the essentials of what works for these data types.
## The shared loop
Every advanced-visualization render starts with the same nested iteration:
```js
// 1. Find the metric in results[].
const finding = response.results.find((r) => r.description === "redness");
if (!finding) return;
// 2. Each measurement_locations[] entry can carry visualization_data[].
// Shine also has a "Global" entry covering the zone entries: draw Global only.
const locations = finding.measurement_locations ?? [];
const global = locations.filter((loc) => loc.description === "Global");
for (const loc of global.length ? global : locations) {
// 3. Sort features ascending by intensity before drawing.
// Higher-intensity polygons sit INSIDE lower-intensity ones —
// drawing low → high gives correct overpainting. Polylines carry an
// array of per-point intensities, so sort those by mean_intensity.
const level = (f) => (typeof f.intensity === "number" ? f.intensity : f.mean_intensity ?? 0);
const features = (loc.visualization_data ?? [])
.slice()
.sort((a, b) => level(a) - level(b));
for (const f of features) {
// mean_intensity is the canonical color-decision input;
// fall back to intensity if absent.
const colorIntensity = f.mean_intensity ?? f.intensity;
drawFeature(ctx, f, colorIntensity);
}
}
```
Four rules from this loop:
1. **Sort features ascending by intensity** before drawing. Required for area metrics, harmless for spot/line. Keeps render order deterministic.
2. **Prefer `mean_intensity ?? intensity`** for color decisions — `mean_intensity` is more stable than the raw per-coordinate `intensity` on multi-point features.
3. **Stay in original-image pixel space.** All `x` / `y` arrays are in input-image coordinates. Render onto a canvas of the same dimensions as the source image, no transform required.
4. **Draw `Global` only when a metric also has zone entries.** Shine's `Global` entry carries the whole-face areas and its `t-zone` / `u-zone` entries the same areas cut to each zone, so drawing every entry draws most areas twice. Draw `Global`, or the zones, not both.
## Recipe 1 — spots
A spot feature is a single point (`length: 1`, `x`, `y` and `intensity` are length-1 arrays; `mean_intensity` holds the same value as a number).
```js
// Recipe 1 — spots. Requires nothing. Used via renderMetric (render.js) or directly.
/**
* Draw a single spot — used for acne, freckles, dark spots,
* hyperpigmentation.
*
* `style` controls the marker shape:
* "dot" — two concentric circles (recommended for acne, freckles)
* "box" — square outline (dark spots / hyperpigmentation)
*/
function drawSpot(ctx, feature, intensity, { style, color, scale = 1 }) {
const x = feature.x[0];
const y = feature.y[0];
ctx.save();
ctx.strokeStyle = color;
ctx.fillStyle = color;
ctx.lineWidth = 2 * scale;
if (style === "dot") {
// Inner solid disc + outer stroke ring.
ctx.beginPath();
ctx.arc(x, y, 6 * scale, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(x, y, 12 * scale, 0, Math.PI * 2);
ctx.lineWidth = 2 * scale;
ctx.stroke();
} else if (style === "box") {
const size = 18 * scale;
ctx.lineWidth = 4 * scale;
ctx.strokeRect(x - size / 2, y - size / 2, size, size);
} else if (style === "cross") {
const size = 14 * scale;
ctx.lineWidth = 4 * scale;
ctx.beginPath();
ctx.moveTo(x - size / 2, y - size / 2);
ctx.lineTo(x + size / 2, y + size / 2);
ctx.moveTo(x + size / 2, y - size / 2);
ctx.lineTo(x - size / 2, y + size / 2);
ctx.stroke();
}
ctx.restore();
}
```
Used on: [acne](/concepts/acne/), [freckles](/concepts/freckles/), [dark spots](/concepts/dark-spots/), [hyperpigmentation](/concepts/hyperpigmentation/).
Marker size is fixed in viewBox-pixel terms (6/12 px for dots, 18 px for boxes, 14 px for crosses are workable defaults); pass a `scale` if you're rendering on a downsized canvas.
## Recipe 2 — polylines
A polyline feature is a connected line — one wrinkle, one fold. `x` and `y` are length-N arrays of points along the line. `intensity` is an array of length N (per-point intensity), and `length_weighted_intensity` is the canonical "how bad is this wrinkle" composite.
```js
// Recipe 2 — polylines. Requires nothing. Used via renderMetric (render.js) or directly.
const FILTER_STEP = 3;
const FILTER_THRESHOLD = 20;
/**
* Decimate dense point arrays for performance — wrinkles can carry
* hundreds of points along a single line. Filtering every Nth point
* above a threshold gives a visually identical render at a fraction
* of the cost.
*/
function decimate(arr, step = FILTER_STEP, threshold = FILTER_THRESHOLD) {
if (arr.length <= threshold) return arr;
return arr.filter((_, i) => i % step === 0 || i === arr.length - 1);
}
/**
* Draw a polyline — used for wrinkles and its sub-region variants
* (nasolabial folds, marionette lines, etc.).
*/
function drawPolyline(ctx, feature, intensity, { color, strokeWidth = 4, scale = 1 }) {
const xs = decimate(feature.x);
const ys = decimate(feature.y);
if (xs.length < 2) return;
ctx.save();
ctx.strokeStyle = color;
ctx.lineWidth = strokeWidth * scale;
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.beginPath();
ctx.moveTo(xs[0], ys[0]);
for (let i = 1; i < xs.length; i++) ctx.lineTo(xs[i], ys[i]);
ctx.stroke();
ctx.restore();
}
```
Used on: [wrinkles](/concepts/wrinkles/).
For ranking wrinkles (e.g., "show me the worst 5"), sort the features by `length_weighted_intensity` descending — that composite is built specifically for this use.
## Recipe 3 — polygon areas
A polygon-area feature is an enclosed region whose `intensity` is a *categorical integer* indexing levels, counting up from `1`. The top of the range varies by metric — `1..2` up to `1..9` — see the [level table](/concepts/visualization/#intensity-ranges). Each level can come back as several features, one per separate region at that level.
For most of these metrics the levels are increasing thresholds on one field, so higher levels sit inside lower ones and layered fills read as a gradient. `skin_sagging` also draws polygons but its `intensity` is a continuous score, not a level. `shine` (`1..4`) and `skin_type` (`1..9`) are different again: their levels come from separate source fields, so treat the integer as a label and give each level its own colour rather than a position on one ramp.
```js
// Recipe 3 — polygon areas. Requires nothing. Used via renderMetric (render.js) or directly.
/**
* Draw a polygon-area feature — used for redness, melasma, shine, skin type,
* texture, uneven skin tone, skin sagging, pore dilation.
*
* Colour: pick one outside the skin-tone gamut (blue, magenta, teal, green), so it reads
* as an annotation on every skin tone instead of fusing into it or looking like a skin
* condition. For the threshold-based metrics keep ONE colour and carry the level in
* opacityForLevel(intensity) — translucent fills of any colour pull towards skin, so keep
* them light and let the outline do the work. For shine and skin type (categories, not
* levels) map each level to its own colour with colorForLevel(intensity) instead.
*/
function drawPolygonArea(ctx, feature, intensity, { colorForLevel, opacity = 0.2, opacityForLevel, outline = 2, scale = 1 }) {
const xs = feature.x;
const ys = feature.y;
if (xs.length < 3) return;
const color = colorForLevel(intensity);
ctx.save();
ctx.beginPath();
ctx.moveTo(xs[0], ys[0]);
for (let i = 1; i < xs.length; i++) ctx.lineTo(xs[i], ys[i]);
ctx.closePath(); // polygon types are closed shapes — connect last to first
ctx.fillStyle = color;
ctx.globalAlpha = opacityForLevel ? opacityForLevel(intensity) : opacity;
ctx.fill();
if (outline > 0) {
ctx.globalAlpha = 0.9;
ctx.strokeStyle = color;
ctx.lineWidth = outline * scale;
ctx.stroke();
}
ctx.restore();
}
```
Used on: [redness](/concepts/redness/), [melasma](/concepts/melasma/), [texture](/concepts/texture/), [uneven skin tone](/concepts/uneven-skin-tone/), [skin sagging](/concepts/skin-sagging/), [shine](/concepts/shine/), [glow](/concepts/glow/).
Because the shared loop sorts features ascending by intensity, the highest level naturally lands on top. With one colour and `opacityForLevel` rising with the level (the recipes use 0.12, 0.22, 0.32), the layered fill reads as a density map — outer (low) areas stay faint, inner (high) areas dominate — while the outline keeps every region visible on every skin tone. Use a colour outside the skin-tone gamut (blue, magenta, teal, green): warm colours fuse into light skin and look like the condition itself. For `shine` and `skin_type`, keep the sort for deterministic draw order but pick `colorForLevel` per level rather than as a ramp, since their levels aren't a severity sequence.
## Putting it together
One function selects the finding and walks its features in the right order; each metric is then a single call that names the recipe and the colours:
```js title="render.js"
// renderMetric: the shared loop. Requires one of the draw recipes to pass as options.draw.
function renderMetric(ctx, response, metric, options) {
const finding = response.results.find((r) => r.description === metric);
if (!finding) return;
// Shine has a "Global" entry with the whole-face areas plus "t-zone" / "u-zone" entries
// with the same areas cut to each zone. Draw Global only, or most areas draw twice.
const locations = finding.measurement_locations ?? [];
const global = locations.filter((loc) => loc.description === "Global");
for (const loc of global.length ? global : locations) {
// Polylines carry an array of per-point intensities; sort those by mean_intensity.
const level = (f) => (typeof f.intensity === "number" ? f.intensity : f.mean_intensity ?? 0);
const features = (loc.visualization_data ?? [])
.slice()
.sort((a, b) => level(a) - level(b));
for (const f of features) {
const intensity = f.mean_intensity ?? f.intensity;
options.draw(ctx, f, intensity, options);
}
}
}
```
Every concept page shows its own call like this one, in the Code tab beside its reference image. The preview below draws three of them at once: freckles, wrinkles and redness.
The preview runs on recorded partner-test responses for a set of licensed model photos, drawn on the analysed photo in source-image coordinates. Toggle the layers, switch model with the thumbnails, and hold the photo to see it without overlays. Note how freckle markers and wrinkle lines differ between faces, and how the redness levels nest.
## Complete example
Everything above in one file: upload a photo, request a metric with its visualization channel, draw the photo on a canvas of the same size, make one metric call.
```html title="index.html"
Revieve — draw an overlay
```
## Get the helpers
The recipes are plain scripts with no dependencies, served from this site at stable URLs:
- One file, classic script: `https://api.revieve.com/demos/recipes/revieve-render.js` (defines `renderMetric`, `drawSpot`, `drawPolyline`, `drawPolygonArea`, `decimate` as globals)
- One file, ES module: `https://api.revieve.com/demos/recipes/revieve-render.mjs` (same functions as named exports)
- Per recipe: `https://api.revieve.com/demos/recipes/spots.js`, `polylines.js`, `polygon-areas.js`, `render.js`
- Per metric call, as shown on each concept page: `https://api.revieve.com/demos/recipes/metrics/.js`, for example `metrics/redness.js`
Each file starts with a comment saying what it requires. The functions expect a 2D context `ctx` on a canvas sized to the analysed image and the parsed `analyzeImage` JSON as `response`; nothing else is assumed. The current version is in the header of the bundle. Copy the files into your project and pin them; they are small enough to read in full.
## Other rendering targets
- **Server-side / Python.** Use OpenCV (`cv2.fillPoly`, `cv2.polylines`, `cv2.circle`) or `matplotlib.pyplot` — both are workable for batch rendering and report generation.
- **SVG.** Build a ``, ``, or `` element per feature inside an `