Docs
Contact

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

/** 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" };};
MessageDirectionWhen
readyCheckup to pageThe 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.
initPage to checkupOnce, after ready. The checkup takes the first one it can read and ignores the rest.
initializedCheckup to pageYour key was accepted. The measurement loads next.
progressCheckup to pageThe measurement moved on: state, and progress from 0 to 100 while it measures.
resultCheckup to pageThe measurement ended: its biomarkers. See Results.
errorCheckup to pageSomething stopped the checkup: see Errors.
checkupPage to checkupAny 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:

stateWhat the person sees
initializationThe measurement is loading.
readyThe checkup waits for the person to press its button.
progressIt measures; progress counts to 100.
extraTimeThe face video needs more time after its minute.
processingIt 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 defines, sends and reads these messages for you:

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:

FieldValue
apiKeyRequired. Your key.
localeen (the default), de, it or es. A region (de-CH) counts as its language; any other counts as left out.
userThe person, below. Can change with each checkup.
modelThe face video model: faceVideo1, faceVideo2 or auto. Can change with each checkup.
themeColours and texts, below.
messagesTexts to replace, by key, below.
orientationportrait (the default) or landscape. Set once per iframe.
mediaShareThe 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.
checkupTypefaceVideo (the default), voice, faceSelfie or bodyComposition. Can change with each checkup.
voiceTypeFor a voice checkup, respiratory (the default) or mental. Can change with each checkup.
diagnosticstrue 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.
scorestrue asks for YOU(th)'s 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, 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.

modelWhich model runs
Left outModel 1 when your key offers it, otherwise model 2
faceVideo1Model 1
faceVideo2Model 2
autoThe 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:

AgeHeight and weightethnicityModel
Over 80AnyAnyfaceVideo2
80 or less, or noneImplausibleAnyfaceVideo1
80 or less, or nonePlausible, or noneblack, africanAmericanfaceVideo2
80 or less, or nonePlausible, or noneunspecified, or nonefaceVideo2
80 or less, or nonePlausible, or nonewhite, hispanicLatino, nativeAmericanfaceVideo1
80 or less, or nonePlausible, or noneasianfaceVideo1

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

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.

Numbers must be above zero. Some biomarkers, such as heart age, need the whole profile, smoking status included: see 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

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.

KeyEnglish text
basicVideoRecordRecord a {duration}-second face video
basicVideoRecordingRecording in progress...
basicVideoProcessingProcessing results...
basicVideoExtraTimeThe scan needs a little more time
basicVideoInstructionsStay still, ensure even face lighting and no light sources behind you
basicPulseMask{pulse} bpm
faceVideoInitializationInitialization ...
faceVideoUnknownUnknown error, try again later.
faceVideoWarningFacePositionPosition your face in the frame
faceVideoWarningFaceRecognizeCan't recognize your face
faceVideoWarningFaceTooFarYour face is too far
faceVideoWarningForeheadUncover your forehead
faceVideoWarningGlassesPlease remove your glasses
faceVideoWarningHeadLevelKeep your head level
faceVideoWarningHoldStillHold still
faceVideoWarningInvalidOrientationInvalid device orientation
faceVideoWarningUnevenLightAdjust the lighting
voiceRespiratoryRecordSay “Aahhh” for 6 seconds
voiceRepeatRespiratoryRecordOne more time: Say “Aahh”
voiceRespiratoryRecordGuideFind a quiet place to record
voiceMentalRecordDescribe your day for 30 sec
voiceUploadingRecordingsUploading your recordings…
voiceCheckRecordingsChecking recording quality…
voiceWaitingResultsWaiting for results…
faceSelfieGuideMake sure the room is well lit and your face is in the center of the frame
faceSelfieModelLoadingLoading the selfie model…
faceSelfieWarningNoFacePlace your face inside the frame
faceSelfieWarningMultipleFacesMake sure only one face is in the frame
faceSelfieWarningTooFarMove closer to the camera
faceSelfieWarningTooCloseMove a little further from the camera
faceSelfieWarningNotCenteredCenter your face in the frame
faceSelfieWarningHeadTurnedLook straight at the camera
faceSelfieWarningTooDarkFind a brighter place
faceSelfieWarningTooBrightToo bright. Avoid direct light on your face
faceSelfieHintHoldStillGreat! Hold still
faceSelfieHintHoldPositionHold your face position: {seconds}
faceSelfieHintReviewCheck your photo
faceSelfieHintAnalyzingAnalyzing your photo…
faceSelfieSendSubmit
faceSelfieRetakeRetake
bodyCompositionTitleFull-body scan
bodyCompositionGuidePhoneA phone’s camera gives the most accurate results
bodyCompositionGuideFrameStand back so that your whole body is in the frame
bodyCompositionGuideTimeYour results take 1–2 minutes
bodyCompositionStartStart the scan
bodyCompositionPreparingPreparing the scan…
bodyCompositionUploadingSending your scan…
bodyCompositionMeasuringMeasuring your body composition…
bodyCompositionMeasuringHintThis takes 1–2 minutes. Keep this page open
bodyCompositionResultsTitleYour results
bodyCompositionScanAgainScan again
bodyCompositionBodyFatBody fat
bodyCompositionVisceralFatVisceral fat
bodyCompositionLeanMassLean mass of arms and legs
bodyCompositionMuscleMassSkeletal muscle mass
bodyCompositionBodyMassIndexBody mass index
bodyCompositionMetabolicAgeMetabolic age
bodyCompositionYears{years} years
bodyCompositionModelLabelYour body in 3D
bodyCompositionTodayToday
bodyCompositionFutureMeTitleFuture Me
bodyCompositionFutureMeHintSee your body at a lower weight
bodyCompositionFutureMeTargetTarget weight: {weight} kg
bodyCompositionFutureMeShowShow my Future Me
bodyCompositionFutureMeMakingMaking your Future Me…
bodyCompositionFutureMeFailedWe couldn’t make your Future Me. Please try again
bodyCompositionFutureMeUsedUpYou can make three Future Mes per scan
bodyCompositionFutureMeAtAt {weight} kg

The selfie's and the body composition checkup's error texts, faceSelfieError… and bodyCompositionError…, are listed with their 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, each result carries them for the person user names, or says why there are none:

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.codeWhy
PROFILE_INCOMPLETEuser 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_UNAVAILABLEThey 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.

CodeWhat happened
INVALID_API_KEYThe key is unknown or revoked.
ORIGIN_NOT_ALLOWEDYour organization lists the origins that may embed the checkup, and your page's is not one of them: see What your page needs.
NETWORKThe checkup could not reach YOU(th) in time. Check the connection.
SERVICE_UNAVAILABLEYOU(th) could not answer just now. Try again later.
UNKNOWNAnything else.

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

CodeWhat happened
PROVIDER_INIT_FAILEDThe measurement could not load.
SERVICE_UNAVAILABLEYOU(th) could not answer.
INVALID_API_KEYThe key no longer opens a measurement, for example because it was revoked.
ORIGIN_NOT_ALLOWEDThe session was renewed from an origin your organization no longer lists.
PROVIDER_CONNECTION_ERRORThe measurement could not connect. Check the connection.
NO_PROVIDER_AVAILABLEThe measurement is not enabled for your key. Tell your YOU(th) contact.
INVALID_PROVIDER_CREDENTIALSThe measurement is not enabled for this site. Tell your YOU(th) contact.
CAMERA_UNAVAILABLEThere 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.

CodeWhat happened
FACE_NOT_DETECTEDModel 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_TIMEOUTThe measurement gave no result in time.
MEASUREMENT_FAILEDThe measurement could not start or could not finish.
CAMERA_UNAVAILABLEThe camera stopped.
SERVICE_UNAVAILABLEWhen the person pressed the button: your organization has reached the monthly limit of the model that runs, or YOU(th) could not answer.
INVALID_API_KEYWhen the person pressed the button: the key was refused, for example because it was revoked.
ORIGIN_NOT_ALLOWEDWhen the person pressed the button: the session was renewed from an origin your organization no longer lists.
NO_PROVIDER_AVAILABLEWhen the person pressed the button: the measurement is not enabled for your key. Tell your YOU(th) contact.
PROVIDER_CONNECTION_ERRORWhen the person pressed the button: the checkup could not reach YOU(th). Check the connection.
PROVIDER_INIT_FAILEDWhen 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.

CodereasonWhat happened
MICROPHONE_UNAVAILABLEpermissionDeniedThe person or the browser did not allow the microphone.
VOICE_TOO_QUIETtooQuietThe voice was too quiet. Ask the person to speak louder.
NETWORKcheckupCreateFailed, uploadFailedThe 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_TIMEOUTresultsUnavailableThe results did not arrive in time. Try again later.
MEASUREMENT_FAILEDtooShort, validationFailed, interrupted, alreadyRecording, invalidFormat, cancelled, failedThe recording ended early, was not clear enough, or failed. With failed, there may also be no microphone, or another app holds it.
SERVICE_UNAVAILABLEanyYour organization has reached the voice checkups' monthly limit, 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:

CodereasonWhat happenedText key
NO_PROVIDER_AVAILABLEcheckupCreateFailed, or the step's belowThe selfie is not enabled for your key, which YOU(th) does by setting its monthly limit: asked before the camera opens, or refused when the person submits. Tell your YOU(th) contact.faceSelfieErrorCheckupCreate
CAMERA_UNAVAILABLEcameraUnavailableThere is no camera, the person did not allow it, or the face detector could not load.faceSelfieErrorCamera
NETWORKcheckupCreateFailed, uploadFailedThe checkup could not be started, or the photo sent: check the connection.faceSelfieErrorCheckupCreate, faceSelfieErrorUpload
MEASUREMENT_FAILEDanalysisFailedThe analysis could not read the photo. Take a new one in even light.faceSelfieErrorAnalysis
MEASUREMENT_FAILEDuploadFailedYOU(th) would not take the photo.faceSelfieErrorUpload
MEASUREMENT_FAILEDcancelled, failedAnything else.faceSelfieErrorCanceled, faceSelfieErrorSomethingWrong
MEASUREMENT_TIMEOUTresultsUnavailableThe results did not arrive in time. Try again later.faceSelfieErrorResultsUnavailable
SERVICE_UNAVAILABLEthe step's belowYour organization has reached the selfie's monthly limit.the step's below
INVALID_API_KEYthe step's belowThe key was refused, for example because it was revoked.the step's below
ORIGIN_NOT_ALLOWEDthe step's belowThe 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:

CodereasonWhat happenedText key
INVALID_USER_DATAuserDataRequireduser lacks age, height, weight or a gender of female or male, or a value is outside what the checkup takes: see Body composition. Nothing is sent.bodyCompositionErrorUserData
NO_PROVIDER_AVAILABLEcheckupCreateFailedBody composition is not enabled for your key. Tell your YOU(th) contact. Nothing is sent.bodyCompositionErrorNotOffered
CAMERA_UNAVAILABLEcameraUnavailableThere is no camera, or the person did not allow it.bodyCompositionErrorCamera
NETWORKcheckupCreateFailed, uploadFailedThe checkup could not be started, or its video sent: check the connection.bodyCompositionErrorCheckupCreate, bodyCompositionErrorUpload
MEASUREMENT_FAILEDcaptureFailed, uploadFailedThe camera could not record, or the video could not be taken.bodyCompositionErrorCapture, bodyCompositionErrorUpload
MEASUREMENT_FAILEDanalysisFailedThe analysis could not measure the video, usually because the whole body was not in the frame. A new checkup is needed.bodyCompositionErrorAnalysis
MEASUREMENT_FAILEDfailedAnything else.bodyCompositionErrorSomethingWrong
MEASUREMENT_TIMEOUTresultsUnavailableThe results did not arrive within four minutes of the video. Try again later.bodyCompositionErrorResultsUnavailable
SERVICE_UNAVAILABLEanyYour organization has reached the body composition monthly limit, when the checkup starts or its video is sent, or the analysis or YOU(th) could not answer.bodyCompositionErrorUnavailable
INVALID_API_KEYanyThe key was refused, for example because it was revoked.bodyCompositionErrorNotOffered
ORIGIN_NOT_ALLOWEDanyThe 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. 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:

CodeWhat happened
LOAD_TIMEOUTThe checkup did not say ready within 30 seconds: it could not load, or its address is wrong. Start it again.
UNSUPPORTED_VERSIONThe 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 and Android pages describe can also receive these. They may change while those setups are previews:

CodeWhat happened
DELIVERY_NOT_ALLOWEDShowing 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_ALLOWEDCustom Tab: the return address is not one your organization has listed. The checkup shows an error, and your app receives nothing.
INVALID_CONFIGCustom Tab: the checkup could not read the init in the address.
CANCELEDCustom Tab: the page was reloaded, so the checkup and its settings are gone. Open a new tab.

Last updated