# Web SDK reference

> Every message between your page and the checkup, its options, and its errors.

Your page and the checkup talk with `postMessage`. Every message is an object with the version of
the messages, `v: 2`, a `type`, and for most types a `payload`. The checkup answers only the window
that embeds it, and after `init` only the origin that sent it.

## Messages

```typescript
/** From your page to the checkup. */
type ToCheckup =
  | { v: 2; type: "init"; payload: Settings }
  | { v: 2; type: "checkup"; payload: Checkup };

type Checkup = {
  user?: Person;
  model?: FaceVideoModel;
  checkupType?: "faceVideo" | "voice" | "faceSelfie" | "bodyComposition";
  voiceType?: VoiceType;
};
type FaceVideoModel = "faceVideo1" | "faceVideo2" | "auto";
type VoiceType = "respiratory" | "mental";

/** From the checkup to your page. */
type FromCheckup =
  | { v: 2; type: "ready"; version?: string }
  | { v: 2; type: "initialized" }
  | { v: 2; type: "progress"; payload: Progress }
  | { v: 2; type: "result"; payload: Result }
  | { v: 2; type: "error"; payload: { code: ErrorCode; reason?: string; message?: string } };

/** `step` of `steps`: which recording of a voice checkup. */
type Progress = { state: ProgressState; progress: number; step?: number; steps?: number };

type ProgressState = "initialization" | "ready" | "progress" | "extraTime" | "processing";

type Biomarker = {
  type: string;
  name: string;
  value: number | string | BloodPressure; // a number, a level such as "low", or blood_pressure's
  unit: string;
  model: string; // the model that measured it, such as face_video_1
  modelVersion: string; // that model's version, such as 2026.11
};

/** blood_pressure's value, in mmHg. */
type BloodPressure = { systolic: number; diastolic: number };

/** `scores` or `scoresError` only after an `init` with `scores: true`: see Scores. */
type Result = {
  biomarkers: Biomarker[];
  scores?: Scores;
  scoresError?: { code: "PROFILE_INCOMPLETE" | "SCORES_UNAVAILABLE" };
};
```

| Message       | Direction       | When                                                                                                                                                                  |
| ------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ready`       | Checkup to page | The checkup has loaded and waits for `init`. The only message sent to any origin; it carries only the checkup's `version`, such as `0.8.0`.                           |
| `init`        | Page to checkup | Once, after `ready`. The checkup takes the first one it can read and ignores the rest.                                                                                |
| `initialized` | Checkup to page | Your key was accepted. The measurement loads next.                                                                                                                    |
| `progress`    | Checkup to page | The measurement moved on: `state`, and `progress` from 0 to 100 while it measures.                                                                                    |
| `result`      | Checkup to page | The measurement ended: its biomarkers. See [Results](/docs/sdks/results).                                                                                             |
| `error`       | Checkup to page | Something stopped the checkup: see [Errors](#errors).                                                                                                                 |
| `checkup`     | Page to checkup | Any time after `init`: start again with these settings, which replace the last ones. A measurement under way is dropped, as is a result still waiting for its scores. |

`progress` goes through these states:

| `state`          | What the person sees                                  |
| ---------------- | ----------------------------------------------------- |
| `initialization` | The measurement is loading.                           |
| `ready`          | The checkup waits for the person to press its button. |
| `progress`       | It measures; `progress` counts to 100.                |
| `extraTime`      | The face video needs more time after its minute.      |
| `processing`     | It works out the results.                             |

Some face video measurements need longer than their minute: the checkup then says `extraTime` until
it works out the results, for up to two minutes more, and ends with `MEASUREMENT_TIMEOUT` if no
result comes by then. The minute starts once the face is in place: the checkup waits up to 90
seconds for that after the person presses the button, and ends with `MEASUREMENT_TIMEOUT` past it.
So a result can come up to four and a half minutes after the press. A later release can add a
state: one you do not know means the checkup is still running.

If `initialized` or an `error` does not arrive after `init`, the checkup could not read it: check it
against the settings below.

## The script

`YouthSDK`, which [YOU(th)'s script](/docs/sdks/web#start-a-checkup) defines, sends and reads these
messages for you:

```typescript
type YouthSDK = {
  /** Loads the checkup into the iframe and starts it. Returns a function that unloads it. */
  startCheckup(
    iframe: HTMLIFrameElement,
    address: string,
    settings: Settings,
    events: CheckupEvents,
  ): () => void;
  /** Sends `checkup`: the next measurement, without loading the iframe again. */
  nextCheckup(iframe: HTMLIFrameElement, address: string, payload: Checkup): void;
};

type CheckupEvents = {
  onResult: (biomarkers: Biomarker[]) => void;
  onError: (code: string, detail?: { reason?: string; message?: string }) => void;
  onProgress?: (
    state: string,
    progress: number,
    recording?: { step: number; steps: number },
  ) => void;
  onReady?: (version?: string) => void; // the checkup has loaded
  onInitialized?: () => void; // your key was accepted
  onScores?: (scores: Scores) => void; // passing it asks for YOU(th)'s scores
  onScoresError?: (code: string) => void; // why a result came without them
};
```

## Settings

The `init` payload:

| Field         | Value                                                                                                                                                                                                                                                                                                      |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`      | Required. Your [key](/docs/sdks#what-you-need).                                                                                                                                                                                                                                                            |
| `locale`      | `en` (the default), `de`, `it` or `es`. A region (`de-CH`) counts as its language; any other counts as left out.                                                                                                                                                                                           |
| `user`        | The person, below. Can change with each `checkup`.                                                                                                                                                                                                                                                         |
| `model`       | The [face video model](#the-face-video-model): `faceVideo1`, `faceVideo2` or `auto`. Can change with each `checkup`.                                                                                                                                                                                       |
| `theme`       | Colours and texts, below.                                                                                                                                                                                                                                                                                  |
| `messages`    | Texts to replace, by key, below.                                                                                                                                                                                                                                                                           |
| `orientation` | `portrait` (the default) or `landscape`. Set once per iframe.                                                                                                                                                                                                                                              |
| `mediaShare`  | The share of the iframe the picture takes, `0.2` to `0.9`: of the height in `portrait`, of the width in `landscape`. The panel gets the rest and its content is drawn larger to fill it. Left out, the panel is as large as its content. Set once per iframe. See [On a kiosk](/docs/sdks/web#on-a-kiosk). |
| `checkupType` | `faceVideo` (the default), `voice`, `faceSelfie` or `bodyComposition`. Can change with each `checkup`.                                                                                                                                                                                                     |
| `voiceType`   | For a voice checkup, `respiratory` (the default) or `mental`. Can change with each `checkup`.                                                                                                                                                                                                              |
| `diagnostics` | `true` turns the checkup's error reports on, and any other value off. Left out, they are on until your key is accepted, then follow your organization's saved setting: send `false` to keep them off from the start.                                                                                       |
| `scores`      | `true` asks for [YOU(th)'s scores](#scores) with each result, where your organization gets them; any other value asks for none. The script sends it for you when you pass `onScores`. Set once per iframe.                                                                                                 |

A field you leave out, or one the checkup cannot read, takes
[your organization's saved setting](/docs/sdks#your-organizations-settings), if any, or the
default; the rest still applies. Three fields are stricter: `apiKey` must be a string that is not
blank, `locale` a string and `messages` an object of strings, or the checkup cannot read `init` at
all. Besides the theme, the texts and the language, your organization can save the orientation,
the checkup to start with and the error reports. `diagnostics` is the exception: any value but
`true` turns the reports off.

### The face video model

`model` names the face video model to run. YOU(th) sets which models your key may run, separately
for your test and live keys.

| `model`      | Which model runs                                                  |
| ------------ | ----------------------------------------------------------------- |
| Left out     | Model 1 when your key offers it, otherwise model 2                |
| `faceVideo1` | Model 1                                                           |
| `faceVideo2` | Model 2                                                           |
| `auto`       | The model the person's profile suits, among those your key offers |

A value the checkup cannot read counts as left out. That includes the ids a result names its
model by, `face_video_1` and `face_video_2`: they are not values of `model`. A result's `model`
tells you which one ran. A model your key does not offer ends the checkup with
`NO_PROVIDER_AVAILABLE` before the camera starts.

With `auto`, and only then, the profile chooses the model, by these rules in order:

| Age                 | Height and weight  | `ethnicity`                                 | Model        |
| ------------------- | ------------------ | ------------------------------------------- | ------------ |
| Over 80             | Any                | Any                                         | `faceVideo2` |
| 80 or less, or none | Implausible        | Any                                         | `faceVideo1` |
| 80 or less, or none | Plausible, or none | `black`, `africanAmerican`                  | `faceVideo2` |
| 80 or less, or none | Plausible, or none | `unspecified`, or none                      | `faceVideo2` |
| 80 or less, or none | Plausible, or none | `white`, `hispanicLatino`, `nativeAmerican` | `faceVideo1` |
| 80 or less, or none | Plausible, or none | `asian`                                     | `faceVideo1` |

Implausible is a height outside 120 to 220 centimetres, a weight outside 30 to 200 kilograms, or a
BMI outside 15 to 45, checked only when both height and weight are given. `gender` is not used. When
your key offers only one of the two models, that one runs whatever the profile suits. These rules
may change in later releases, which can change the biomarkers a person receives: if your product
depends on a fixed set, name the model.

`selectedProvider`, with `provider1` and `provider2`, is the setting `model` replaces. It keeps
working when you send no `model`: `provider1` stands for `faceVideo1` and `provider2` for
`faceVideo2`.

### The person

```typescript
type Person = {
  age?: number; // years
  weight?: number; // kilograms
  height?: number; // centimetres
  gender?: "female" | "male" | "unspecified";
  smokingState?: "smoker" | "nonSmoker" | "unspecified";
  ethnicity?:
    | "asian"
    | "black"
    | "white"
    | "africanAmerican"
    | "hispanicLatino"
    | "nativeAmerican"
    | "unspecified";
};
```

The body composition checkup needs `age`, `height`, `weight` and a `gender` of `female` or `male`,
within its ranges: see [Body composition](/docs/sdks/web#body-composition).

Numbers must be above zero. Some biomarkers, such as heart age, need the whole profile, smoking
status included: see [Tell it about the person](/docs/sdks/web#tell-it-about-the-person). Some
measurements use the profile only when `age`, `weight` and `height` are all there and plausible;
otherwise they measure without any of it, `gender` and `smokingState` included.

### Theme

```typescript
type Theme = {
  fontFamily?: string; // every text, unless its style sets one
  footerBgColor?: string;
  recordBtnColor?: string;
  recordBtnBorderColor?: string;
  progressBarColor?: string;
  primaryBtnColor?: string; // the selfie's Submit
  secondaryBtnColor?: string; // the selfie's Retake, outlined
  headerTextStyle?: TextStyle;
  headerErrorTextStyle?: TextStyle;
  primaryTextStyle?: TextStyle;
  secondaryTextStyle?: TextStyle;
  warningTextStyle?: TextStyle;
  selfieWarningTextStyle?: TextStyle; // the selfie's hints and errors
  primaryBtnTextStyle?: TextStyle;
  secondaryBtnTextStyle?: TextStyle;
};

type TextStyle = {
  color?: string; // any CSS colour: "#1b1b1b", "rgb(0 0 0)", "navy"
  fontSize?: number; // pixels, 8 to 48
  fontWeight?: number; // 100 to 900
  fontFamily?: string; // installed on the person's device
};
```

### Texts

`messages` replaces texts by key, in every language. It cannot reword "Powered by YOU(th)". An unknown key, an empty text or one over 500
characters is ignored. Every text must be a string, or the checkup cannot read `init`.
`{duration}`, `{pulse}`, `{seconds}` and `{years}` are filled in by the checkup.

| Key                                  | English text                                                               |
| ------------------------------------ | -------------------------------------------------------------------------- |
| `basicVideoRecord`                   | Record a {duration}-second face video                                      |
| `basicVideoRecording`                | Recording in progress...                                                   |
| `basicVideoProcessing`               | Processing results...                                                      |
| `basicVideoExtraTime`                | The scan needs a little more time                                          |
| `basicVideoInstructions`             | Stay still, ensure even face lighting and no light sources behind you      |
| `basicPulseMask`                     | {pulse} bpm                                                                |
| `faceVideoInitialization`            | Initialization ...                                                         |
| `faceVideoUnknown`                   | Unknown error, try again later.                                            |
| `faceVideoWarningFacePosition`       | Position your face in the frame                                            |
| `faceVideoWarningFaceRecognize`      | Can't recognize your face                                                  |
| `faceVideoWarningFaceTooFar`         | Your face is too far                                                       |
| `faceVideoWarningForehead`           | Uncover your forehead                                                      |
| `faceVideoWarningGlasses`            | Please remove your glasses                                                 |
| `faceVideoWarningHeadLevel`          | Keep your head level                                                       |
| `faceVideoWarningHoldStill`          | Hold still                                                                 |
| `faceVideoWarningInvalidOrientation` | Invalid device orientation                                                 |
| `faceVideoWarningUnevenLight`        | Adjust the lighting                                                        |
| `voiceRespiratoryRecord`             | Say “Aahhh” for 6 seconds                                                  |
| `voiceRepeatRespiratoryRecord`       | One more time: Say “Aahh”                                                  |
| `voiceRespiratoryRecordGuide`        | Find a quiet place to record                                               |
| `voiceMentalRecord`                  | Describe your day for 30 sec                                               |
| `voiceUploadingRecordings`           | Uploading your recordings…                                                 |
| `voiceCheckRecordings`               | Checking recording quality…                                                |
| `voiceWaitingResults`                | Waiting for results…                                                       |
| `faceSelfieGuide`                    | Make sure the room is well lit and your face is in the center of the frame |
| `faceSelfieModelLoading`             | Loading the selfie model…                                                  |
| `faceSelfieWarningNoFace`            | Place your face inside the frame                                           |
| `faceSelfieWarningMultipleFaces`     | Make sure only one face is in the frame                                    |
| `faceSelfieWarningTooFar`            | Move closer to the camera                                                  |
| `faceSelfieWarningTooClose`          | Move a little further from the camera                                      |
| `faceSelfieWarningNotCentered`       | Center your face in the frame                                              |
| `faceSelfieWarningHeadTurned`        | Look straight at the camera                                                |
| `faceSelfieWarningTooDark`           | Find a brighter place                                                      |
| `faceSelfieWarningTooBright`         | Too bright. Avoid direct light on your face                                |
| `faceSelfieHintHoldStill`            | Great! Hold still                                                          |
| `faceSelfieHintHoldPosition`         | Hold your face position: {seconds}                                         |
| `faceSelfieHintReview`               | Check your photo                                                           |
| `faceSelfieHintAnalyzing`            | Analyzing your photo…                                                      |
| `faceSelfieSend`                     | Submit                                                                     |
| `faceSelfieRetake`                   | Retake                                                                     |
| `bodyCompositionTitle`               | Full-body scan                                                             |
| `bodyCompositionGuidePhone`          | A phone’s camera gives the most accurate results                           |
| `bodyCompositionGuideFrame`          | Stand back so that your whole body is in the frame                         |
| `bodyCompositionGuideTime`           | Your results take 1–2 minutes                                              |
| `bodyCompositionStart`               | Start the scan                                                             |
| `bodyCompositionPreparing`           | Preparing the scan…                                                        |
| `bodyCompositionUploading`           | Sending your scan…                                                         |
| `bodyCompositionMeasuring`           | Measuring your body composition…                                           |
| `bodyCompositionMeasuringHint`       | This takes 1–2 minutes. Keep this page open                                |
| `bodyCompositionResultsTitle`        | Your results                                                               |
| `bodyCompositionScanAgain`           | Scan again                                                                 |
| `bodyCompositionBodyFat`             | Body fat                                                                   |
| `bodyCompositionVisceralFat`         | Visceral fat                                                               |
| `bodyCompositionLeanMass`            | Lean mass of arms and legs                                                 |
| `bodyCompositionMuscleMass`          | Skeletal muscle mass                                                       |
| `bodyCompositionBodyMassIndex`       | Body mass index                                                            |
| `bodyCompositionMetabolicAge`        | Metabolic age                                                              |
| `bodyCompositionYears`               | {years} years                                                              |
| `bodyCompositionModelLabel`          | Your body in 3D                                                            |
| `bodyCompositionToday`               | Today                                                                      |
| `bodyCompositionFutureMeTitle`       | Future Me                                                                  |
| `bodyCompositionFutureMeHint`        | See your body at a lower weight                                            |
| `bodyCompositionFutureMeTarget`      | Target weight: {weight} kg                                                 |
| `bodyCompositionFutureMeShow`        | Show my Future Me                                                          |
| `bodyCompositionFutureMeMaking`      | Making your Future Me…                                                     |
| `bodyCompositionFutureMeFailed`      | We couldn’t make your Future Me. Please try again                          |
| `bodyCompositionFutureMeUsedUp`      | You can make three Future Mes per scan                                     |
| `bodyCompositionFutureMeAt`          | At {weight} kg                                                             |

The selfie's and the body composition checkup's error texts, `faceSelfieError…` and
`bodyCompositionError…`, are listed with [their errors](#errors). The texts of its camera's screens are not among the keys.

## Scores

After an `init` with `scores: true`, and where your organization gets
[YOU(th)'s scores](/docs/sdks/web#youths-scores), each `result` carries them for the person `user`
names, or says why there are none:

```typescript
type Scores = {
  version: string; // how they were made: it changes whenever a rule does
  biomarkers: (Scored & { code: string; ranges: ScoreRange[] })[];
  healthAreas: (Scored & { code: string })[]; // such as cardiovascular
  overall?: Scored; // absent when no health area that counts in it has a score
};

/** From 0 to 1, and its band: strong, moderate or weak. */
type Scored = { score: number; band: string };

/** A band of the biomarker's values for this person: from `lower`, below `upper`; null is open. */
type ScoreRange = {
  lower: number | null;
  upper: number | null;
  band: string;
  field?: string;
  category?: string;
};
```

| `scoresError.code`   | Why                                                                                                                                       |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `PROFILE_INCOMPLETE` | `user` gives no `age` from 18 to 120, or no `gender` of `female` or `male`. Nothing was asked: the checkup never assumes an age or a sex. |
| `SCORES_UNAVAILABLE` | They could not be made: no connection, no answer within 8 seconds, or a refusal of YOU(th)'s service.                                     |

The result waits for its scores, at most 8 seconds, and comes either way. Where your organization
gets no scores, the result carries neither field. With the script, `onResult` comes first, then
`onScores` or `onScoresError`; scores it cannot read are `SCORES_UNAVAILABLE`.

## Errors

`error` carries a `code` and, except before the measurement loads, a `message`: the text the checkup
would show for it, in the checkup's language, for your logs. The checkup does not show the person
what happened: before or while the measurement loads it stays on its loading text, and during the
measurement it goes back to `ready`. Your page tells the person, and decides what comes next.

**Before the measurement loads.** Load the iframe again to try again.

| Code                  | What happened                                                                                                                                                        |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `INVALID_API_KEY`     | The key is unknown or revoked.                                                                                                                                       |
| `ORIGIN_NOT_ALLOWED`  | Your organization lists the origins that may embed the checkup, and your page's is not one of them: see [What your page needs](/docs/sdks/web#what-your-page-needs). |
| `NETWORK`             | The checkup could not reach YOU(th) in time. Check the connection.                                                                                                   |
| `SERVICE_UNAVAILABLE` | YOU(th) could not answer just now. Try again later.                                                                                                                  |
| `UNKNOWN`             | Anything else.                                                                                                                                                       |

**While the measurement loads.** Send `checkup` to try again, with the same settings.

| Code                           | What happened                                                              |
| ------------------------------ | -------------------------------------------------------------------------- |
| `PROVIDER_INIT_FAILED`         | The measurement could not load.                                            |
| `SERVICE_UNAVAILABLE`          | YOU(th) could not answer.                                                  |
| `INVALID_API_KEY`              | The key no longer opens a measurement, for example because it was revoked. |
| `ORIGIN_NOT_ALLOWED`           | The session was renewed from an origin your organization no longer lists.  |
| `PROVIDER_CONNECTION_ERROR`    | The measurement could not connect. Check the connection.                   |
| `NO_PROVIDER_AVAILABLE`        | The measurement is not enabled for your key. Tell your YOU(th) contact.    |
| `INVALID_PROVIDER_CREDENTIALS` | The measurement is not enabled for this site. Tell your YOU(th) contact.   |
| `CAMERA_UNAVAILABLE`           | There is no camera, or the person did not allow it.                        |

**During the measurement.** The checkup goes back to `ready`, and the person can start again with
its button.

| Code                        | What happened                                                                                                                                                         |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FACE_NOT_DETECTED`         | Model 1 only. A warning lasted about seven seconds: the face out of the frame or too far, the head tilted, uneven light, or the phone not upright.                    |
| `MEASUREMENT_TIMEOUT`       | The measurement gave no result in time.                                                                                                                               |
| `MEASUREMENT_FAILED`        | The measurement could not start or could not finish.                                                                                                                  |
| `CAMERA_UNAVAILABLE`        | The camera stopped.                                                                                                                                                   |
| `SERVICE_UNAVAILABLE`       | When the person pressed the button: your organization has reached the [monthly limit](/docs/sdks#monthly-limits) of the model that runs, or YOU(th) could not answer. |
| `INVALID_API_KEY`           | When the person pressed the button: the key was refused, for example because it was revoked.                                                                          |
| `ORIGIN_NOT_ALLOWED`        | When the person pressed the button: the session was renewed from an origin your organization no longer lists.                                                         |
| `NO_PROVIDER_AVAILABLE`     | When the person pressed the button: the measurement is not enabled for your key. Tell your YOU(th) contact.                                                           |
| `PROVIDER_CONNECTION_ERROR` | When the person pressed the button: the checkup could not reach YOU(th). Check the connection.                                                                        |
| `PROVIDER_INIT_FAILED`      | When the person pressed the button: the measurement could not load.                                                                                                   |

**During a voice checkup.** The checkup goes back to its first recording, and the person can record
again. `reason` says more than `code`, as the Flutter SDK's `YouthVoiceErrorCode` does.

| Code                     | `reason`                                                                                                  | What happened                                                                                                                                                               |
| ------------------------ | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MICROPHONE_UNAVAILABLE` | `permissionDenied`                                                                                        | The person or the browser did not allow the microphone.                                                                                                                     |
| `VOICE_TOO_QUIET`        | `tooQuiet`                                                                                                | The voice was too quiet. Ask the person to speak louder.                                                                                                                    |
| `NETWORK`                | `checkupCreateFailed`, `uploadFailed`                                                                     | The checkup could not start the analysis or upload the recordings: the connection failed, the key was revoked, or no monthly limit is set for the voice checkups.           |
| `MEASUREMENT_TIMEOUT`    | `resultsUnavailable`                                                                                      | The results did not arrive in time. Try again later.                                                                                                                        |
| `MEASUREMENT_FAILED`     | `tooShort`, `validationFailed`, `interrupted`, `alreadyRecording`, `invalidFormat`, `cancelled`, `failed` | The recording ended early, was not clear enough, or failed. With `failed`, there may also be no microphone, or another app holds it.                                        |
| `SERVICE_UNAVAILABLE`    | any                                                                                                       | Your organization has reached the voice checkups' [monthly limit](/docs/sdks#monthly-limits), the voice checkups are switched off for it, or the analysis could not answer. |

**During a selfie checkup.** After the person submits a photo, the checkup goes back to the camera
for a new one without showing what happened: your page tells the person, with the text `message`
holds. Two errors stay on the checkup's screen with their text instead, because nothing there can
fix them: `CAMERA_UNAVAILABLE`, and `NO_PROVIDER_AVAILABLE` when your key has no selfie as the
checkup starts. `reason` says more than `code`:

| Code                    | `reason`                                   | What happened                                                                                                                                                                                                       | Text key                                                   |
| ----------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `NO_PROVIDER_AVAILABLE` | `checkupCreateFailed`, or the step's below | The selfie is not enabled for your key, which YOU(th) does by setting its [monthly limit](/docs/sdks#monthly-limits): asked before the camera opens, or refused when the person submits. Tell your YOU(th) contact. | `faceSelfieErrorCheckupCreate`                             |
| `CAMERA_UNAVAILABLE`    | `cameraUnavailable`                        | There is no camera, the person did not allow it, or the face detector could not load.                                                                                                                               | `faceSelfieErrorCamera`                                    |
| `NETWORK`               | `checkupCreateFailed`, `uploadFailed`      | The checkup could not be started, or the photo sent: check the connection.                                                                                                                                          | `faceSelfieErrorCheckupCreate`, `faceSelfieErrorUpload`    |
| `MEASUREMENT_FAILED`    | `analysisFailed`                           | The analysis could not read the photo. Take a new one in even light.                                                                                                                                                | `faceSelfieErrorAnalysis`                                  |
| `MEASUREMENT_FAILED`    | `uploadFailed`                             | YOU(th) would not take the photo.                                                                                                                                                                                   | `faceSelfieErrorUpload`                                    |
| `MEASUREMENT_FAILED`    | `cancelled`, `failed`                      | Anything else.                                                                                                                                                                                                      | `faceSelfieErrorCanceled`, `faceSelfieErrorSomethingWrong` |
| `MEASUREMENT_TIMEOUT`   | `resultsUnavailable`                       | The results did not arrive in time. Try again later.                                                                                                                                                                | `faceSelfieErrorResultsUnavailable`                        |
| `SERVICE_UNAVAILABLE`   | the step's below                           | Your organization has reached the selfie's [monthly limit](/docs/sdks#monthly-limits).                                                                                                                              | the step's below                                           |
| `INVALID_API_KEY`       | the step's below                           | The key was refused, for example because it was revoked.                                                                                                                                                            | the step's below                                           |
| `ORIGIN_NOT_ALLOWED`    | the step's below                           | The session was renewed from an origin your organization no longer lists.                                                                                                                                           | the step's below                                           |

The step's reason is the call that was refused: `checkupCreateFailed` when the checkup starts,
`uploadFailed` when the photo is sent, `resultsUnavailable` while the checkup waits for the results;
its text key is that reason's. A selfie is counted once the person submits the photo, whatever
happens next.

**During a body composition checkup.** Unlike the other checkups, this one shows the person what
happened, with the text `message` holds, and offers to try again, except for `INVALID_USER_DATA`,
`NO_PROVIDER_AVAILABLE`, `INVALID_API_KEY` and `ORIGIN_NOT_ALLOWED`, which nothing on the screen
can fix. `reason` says more than `code`:

| Code                    | `reason`                              | What happened                                                                                                                                                                                       | Text key                                                          |
| ----------------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `INVALID_USER_DATA`     | `userDataRequired`                    | `user` lacks `age`, `height`, `weight` or a `gender` of `female` or `male`, or a value is outside what the checkup takes: see [Body composition](/docs/sdks/web#body-composition). Nothing is sent. | `bodyCompositionErrorUserData`                                    |
| `NO_PROVIDER_AVAILABLE` | `checkupCreateFailed`                 | Body composition is not enabled for your key. Tell your YOU(th) contact. Nothing is sent.                                                                                                           | `bodyCompositionErrorNotOffered`                                  |
| `CAMERA_UNAVAILABLE`    | `cameraUnavailable`                   | There is no camera, or the person did not allow it.                                                                                                                                                 | `bodyCompositionErrorCamera`                                      |
| `NETWORK`               | `checkupCreateFailed`, `uploadFailed` | The checkup could not be started, or its video sent: check the connection.                                                                                                                          | `bodyCompositionErrorCheckupCreate`, `bodyCompositionErrorUpload` |
| `MEASUREMENT_FAILED`    | `captureFailed`, `uploadFailed`       | The camera could not record, or the video could not be taken.                                                                                                                                       | `bodyCompositionErrorCapture`, `bodyCompositionErrorUpload`       |
| `MEASUREMENT_FAILED`    | `analysisFailed`                      | The analysis could not measure the video, usually because the whole body was not in the frame. A new checkup is needed.                                                                             | `bodyCompositionErrorAnalysis`                                    |
| `MEASUREMENT_FAILED`    | `failed`                              | Anything else.                                                                                                                                                                                      | `bodyCompositionErrorSomethingWrong`                              |
| `MEASUREMENT_TIMEOUT`   | `resultsUnavailable`                  | The results did not arrive within four minutes of the video. Try again later.                                                                                                                       | `bodyCompositionErrorResultsUnavailable`                          |
| `SERVICE_UNAVAILABLE`   | any                                   | Your organization has reached the body composition [monthly limit](/docs/sdks#monthly-limits), when the checkup starts or its video is sent, or the analysis or YOU(th) could not answer.           | `bodyCompositionErrorUnavailable`                                 |
| `INVALID_API_KEY`       | any                                   | The key was refused, for example because it was revoked.                                                                                                                                            | `bodyCompositionErrorNotOffered`                                  |
| `ORIGIN_NOT_ALLOWED`    | any                                   | The session was renewed from an origin your organization no longer lists.                                                                                                                           | `bodyCompositionErrorNotOffered`                                  |

A body composition checkup is counted once its video is sent: one the person starts and never
records is not.

**At a monthly limit.** Each face video model has a limit of its own: past it, that model's
measurement does not start. Past the voice limit, the checkup ends once the person has recorded,
before any recording is sent. A face video model with no limit set for your key does not run, so a
checkup that needs it ends with `NO_PROVIDER_AVAILABLE`, and with no voice limit a voice checkup
ends with `NETWORK`, and with no selfie limit a selfie checkup with `NO_PROVIDER_AVAILABLE`: ask your YOU(th) contact to set them.

**In the face video checkup, `UNSUPPORTED_ENVIRONMENT`.** The page or the browser lacks what the checkup needs:
HTTPS, cross-origin isolation, or a [current browser](/docs/sdks/web#what-your-page-needs). Trying again in the same page does not help;
fix the page, or ask the person to open it in another browser. It also comes when the phone is in
Low Power Mode: ask the person to turn it off.

**From the script.** `YouthSDK.startCheckup` adds two codes of its own, and stops the checkup with
either:

| Code                  | What happened                                                                                                  |
| --------------------- | -------------------------------------------------------------------------------------------------------------- |
| `LOAD_TIMEOUT`        | The checkup did not say `ready` within 30 seconds: it could not load, or its address is wrong. Start it again. |
| `UNSUPPORTED_VERSION` | The checkup speaks another version of the messages than the script. Load the script's current version.         |

**In a web view or a Custom Tab.** A native app that shows the checkup as the [iOS](/docs/sdks/ios)
and [Android](/docs/sdks/android) pages describe can also receive these. They may change while
those setups are previews:

| Code                        | What happened                                                                                                                           |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `DELIVERY_NOT_ALLOWED`      | Showing the checkup in a web view, or returning from a Custom Tab, is not switched on for your organization. Tell your YOU(th) contact. |
| `RETURN_TARGET_NOT_ALLOWED` | Custom Tab: the return address is not one your organization has listed. The checkup shows an error, and your app receives nothing.      |
| `INVALID_CONFIG`            | Custom Tab: the checkup could not read the `init` in the address.                                                                       |
| `CANCELED`                  | Custom Tab: the page was reloaded, so the checkup and its settings are gone. Open a new tab.                                            |
