Job outputs
Submit typed JSON under an Idempotency-Key, poll a job, decode a typed output.
Submitting
A submit names its input assets and its product parameters, and carries an
Idempotency-Key.
A makeup try-on has the same inputs and an ordered products list instead. The order
is the layer order, and each category appears at most once:
The answer is 202 with the job, Location: /v1/jobs/{job_id} and Retry-After.
The key
- A missing key is
400 IDEMPOTENCY_KEY_REQUIRED; a malformed one is400 INVALID_IDEMPOTENCY_KEY. - The same key with the same body answers the same job, so a retry after a timeout is safe.
- The same key with a different body is
409 IDEMPOTENCY_KEY_REUSED. A retry that arrives while the first use is still being admitted is409 IDEMPOTENCY_IN_PROGRESSwith a shortRetry-After: send the same request again after it.
Generate one key per logical request and keep it with the request until you have a job id. Idempotency explains why, and applies unchanged.
Polling
GET /v1/jobs/{job_id} until status is succeeded or failed. Wait the
Retry-After the previous answer gave you between reads. Send the previous ETag in
If-None-Match and an unchanged job answers 304 with no body.
The job’s fields obey fixed invariants, and a client can rely on them:
A failed job still answers HTTP 200. Read status before output. error.code on a failed job is one of INPUT_UNPROCESSABLE,
INPUT_EXPIRED or PROCESSING_FAILED. The first needs a different image, the second
a fresh upload, and the third may succeed on a retry under a new Idempotency-Key.
Decoding the output
output.type names the schema. Three types exist today:
makeup.try_oncarriesrevisionand oneimage, a result asset reference.skin.analysiscarriesanalysis_version, one entry per requested concern, and the requestedvisualizationsas result asset references.hair.try_oncarries one resultimageAsset plusapplied.color_gradientwith normalizeddarkandlightcolors and opacities. See the Hair color try-on guide for its inputs and supported options.
A concern score runs from 0 to 10 and higher means less visible: 8.7 for acne is a
good reading, not a bad one. A concern the service could not measure says so with
status: unavailable and a reason, and never with a score of 0.
Only what you asked for comes back. A skin analysis returns exactly the concerns and visualizations the request named.
The union is open
output is an open union. A later product adds a new type, and your code must keep
working when one arrives: branch on the types you know and keep the rest whole rather
than failing. inputs[].role is an open string for the same reason, and any response
object may gain fields.
Result images
Each result reference’s href is /v1/assets/{id}/content for its own id, relative
to the API’s base URL. Download it with your X-API-Key, as described in
Assets. It expires with the job.
Usage
GET /v1/usage?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD reports distinct accepted jobs
per UTC day and operation over [start_date, end_date). A submission that never
reached acceptance is not counted. These are operational counts, not an invoice.