Error handling
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
Section titled “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.
Document-level
Section titled “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
Section titled “A defensive client”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
Section titled “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.