Skip to content

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.

StatusCauseWhat to do
200Success — but check data.messageBranch on message, then status[].
400Upload rejected, e.g. the image is not in the image field or more than one file was sentFix the call.
403Unauthorized / Invalid Partner ID: the Partner ID is unknownCheck the ID and the environment (test and production IDs differ).
403Unauthorized / Invalid license for module: the Partner ID is not licensed for Skin Analysis or for one of the requested componentsRemove the component or ask your Revieve contact.
404Partner ID required: no partner_id form fieldSend the Partner ID in the multipart body.
413Image larger than 30 MBResize client-side; aim for < 5 MB.
500Analysis failed (code: "1661"), or the request had no imageCheck that the image is a readable JPEG. Retry once at most.
502/503/504Transient infrastructure issueRetry 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.

A 200 OK HTTP response can still report problems via data.message and data.status[]. The handling matrix:

messageMeaningUX
OKNo global quality issuesRender results. Individual metrics can still fail: check each finding’s message.
WarningResults usable, quality issue notedRender results. Optionally surface advice from status[].
ErrorThe analysis could not run; results is nullHide 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.

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");
}

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.