# YOU(th) docs, in full > Every page of the docs, one after another. # Overview > What partners get from YOU(th): events, FHIR, a read API and SDKs, and how they fit together. YOU(th) runs health checkups and turns them into biomarkers and measurements. These docs are for partners who connect their own systems to it: a clinic's software that files results, an insurer's app that shows them, a coaching platform that starts work when a checkup is done, a company that sells YOU(th) beside its own product. ## What you get - **Access codes.** You [order codes](/docs/access-codes), hand one to each customer, hear when it is redeemed, and end the access with one call. No personal data crosses. - **Events.** A [webhook](/docs/webhooks) tells your system when something happens in your organization, such as a redeemed access code. Each delivery is signed, and carries ids only. - **FHIR.** A checkup is a [FHIR bundle](/docs/data/fhir) and a member a `Patient`, ready to store in a system that speaks FHIR. - **A read API for checkups, as a preview.** Your backend will [read a checkup or a member](/docs/webhooks/catch-up) with a short-lived [token](/docs/authentication), and list the checkups it missed after an outage. It is not available yet, and neither are the checkup and member events. - **A sandbox.** A [second organization](/docs/sandbox) of yours, which only your testers join, to build and test against the live hosts. - **SDKs.** The [SDKs](/docs/sdks) bring the face video and voice checkups into your own web page or Flutter app. ## How it fits together 1. A customer redeems one of your access codes. 2. YOU(th) sends your webhook receiver a signed `AccessCode.redeemed` delivery, with the code's id and where to read it. 3. Your receiver [verifies the signature](/docs/webhooks/verify) and answers at once. 4. Your backend gets a token with its integration's key, and reads the code from the delivery's `resource_url`. ```json { "event_id": "evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c", "event_type": "AccessCode.redeemed", "occurred_at": "2026-12-12T09:30:00.375000Z", "access_code_id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "resource_url": "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34" } ``` ## How to start 1. [Get API credentials](/docs/credentials): an administrator of your organization creates an integration in the YOU(th) console, with a key pair and the scopes it needs. 2. Follow the [quickstart](/docs/quickstart): get a token, create a webhook endpoint, verify a delivery and read what it names. If you sell access, read [Sell access with codes](/docs/access-codes) with it. 3. Read [Retries and duplicates](/docs/webhooks/retries) before you go live. ## Build it with an assistant Hand a coding agent the whole docs in one file, and ask it for the receiver. Put this site's address and your stack in place of the placeholders: ```text Read /llms-full.txt and build a YOU(th) webhook receiver in , with tests. ``` [Use the docs with AI](/docs/ai) has a longer prompt that names each step, and how to hand an assistant a single page. ## Hosts | Host | Serves | | ------------------------ | -------------------------------------------------------- | | `api.youth-platform.io` | The API: every route starts with `/v1` | | `auth.youth-platform.io` | Tokens, at `/realms/youth/protocol/openid-connect/token` | Your live organization and your [sandbox](/docs/sandbox) use the same hosts; your credentials say which one you are. # Quickstart > Get credentials, configure your OAuth library, call the API, then receive and verify a delivery. This walks through an integration end to end. The first three steps get your backend talking to the API: get credentials, configure your OAuth library, make a first call. The rest registers your receiver's address, checks that a delivery is from YOU(th), and reads what the delivery names. ## 1. Get credentials An administrator of your organization creates an integration in the console, with the scopes `webhooks:write` and `access_codes:read`, and downloads its credentials file: see [Get API credentials](/docs/credentials). The file holds four values. Keep them on your server: | Value | In the samples | | --------------- | ------------------- | | The token URL | `TOKEN_URL` | | The client id | `YOUTH_CLIENT_ID` | | The key id | `YOUTH_KEY_ID` | | The private key | `YOUTH_PRIVATE_KEY` | You hold the private key, and YOU(th) holds only its public half. There is no client secret. ## 2. Configure your OAuth library Give your language's OAuth2 library the four values, with the grant `client_credentials`, the client authentication `private_key_jwt`, and your two scopes as `scope`: `webhooks:write access_codes:read`. [Authentication](/docs/authentication#get-a-token) has the settings, and samples for Node, Python and Java. The library signs with your key and gets a token, valid for about five minutes. ## 3. Call the API Send the token with a first call, which answers your organization and your integration: ```bash curl https://api.youth-platform.io/v1/organization \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ## 4. Create a webhook endpoint Register your receiver's HTTPS address, and the events it takes, with `POST /v1/webhook-endpoints`: see [Manage your endpoints](/docs/webhooks/endpoints). The answer shows the endpoint's signing secret, once. Keep it as `YOUTH_WEBHOOK_SECRET`. That page is a preview: the request's fields are not final, so create your first endpoint with your YOU(th) contact. ## 5. Receive and verify a delivery ```typescript import { createServer } from "node:http"; import { verifyDelivery } from "./verify-delivery"; createServer((request, response) => { const chunks: Buffer[] = []; request.on("data", (chunk: Buffer) => chunks.push(chunk)); request.on("end", () => { const body = Buffer.concat(chunks); const signed = verifyDelivery(process.env.YOUTH_WEBHOOK_SECRET ?? "", request.headers, body); response.writeHead(signed ? 200 : 401).end(); if (signed) console.log(JSON.parse(body.toString("utf8")).event_type); }); }).listen(8080); ``` `verifyDelivery` is on [Verify a delivery](/docs/webhooks/verify). It checks the signature over the raw body, exactly as it arrived, and refuses a delivery more than five minutes old. A [Standard Webhooks](https://www.standardwebhooks.com/) library does the same, if you prefer one. Test the check before a real event arrives, with the signed request on [Verify a delivery](/docs/webhooks/verify#try-it). For a real delivery, have a tester redeem a code in your [sandbox](/docs/sandbox#a-whole-run): your receiver logs `AccessCode.redeemed`. ## 6. Read what it names A delivery carries ids and a `resource_url`, never the resource. Read it with your token: ```bash curl https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34 \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` An `AccessCode.redeemed` names the code, which the scope `access_codes:read` reads. ## Next - Answer fast and take each delivery once: [Retries and duplicates](/docs/webhooks/retries). - Know every event and what it carries: [Events](/docs/webhooks). - Sell access to your own customers: [Sell access with codes](/docs/access-codes). - List what you missed while your receiver was down: [access codes](/docs/access-codes/reconcile#catch-up-after-an-outage). - Test with your own testers before a customer is involved: [Sandbox](/docs/sandbox). # Concepts > Organizations, members, checkups, biomarkers and measurements: the words these docs use. The words the webhook, the read API and these docs use, in the order a checkup meets them. ## Your organization The partner YOU(th) answers for. Your integration belongs to one organization, and the API answers only that organization's data: anything else answers `404`, as if it did not exist. No route takes an organization in its address or its body. Your webhook endpoints hear only about your own organization. ## Integration One system of yours that calls the API: a billing backend, a data warehouse. Each integration has its own client id and key pair, and its own scopes, so you can revoke one without touching the others. See [Get API credentials](/docs/credentials). ## Doctor A member of your organization whom its administrators appointed Doctor, with or without a role in the console, and who may read its members' health data. Only a Doctor gives an integration the scopes that read health data: see [Health data](/docs/credentials#health-data). ## Sandbox A second organization of yours, which only your own testers join, to build and test: see [Sandbox](/docs/sandbox). ## Member A person whose checkups your organization receives, once they consented to share their data with it. A member has an id that stays the same, and may have a birth date and a gender. In FHIR terms a member is a `Patient`, because FHIR names any person that way; it does not make them anyone's patient. So the wire keeps FHIR's words: a member's id is `patient_id`, and a new member is the `Patient.registered` event. ## Checkup What a member completes, turned into measurements. Each checkup has a type: `digital`, `lab`, `wearable` or `doctor`. Your YOU(th) contact can limit your webhook to the types you want. ## Measurement and biomarker A measurement is one value a checkup measured, such as a heart rate of 64 bpm. Its biomarker is what it measures, named by a code such as `heart_rate` or `blood_pressure`. A value is a number in its unit, a category such as `low`, or a blood pressure with its systolic and diastolic values. A category is a classification, never a diagnosis. ## Access code and batch An access code gives one person access to YOU(th); a batch is one order of codes. A code has an id, which events and routes name, and names no person: see [Sell access with codes](/docs/access-codes). ## Biomarker codes are open Biomarker codes are stable, and new ones can appear at any time. Keep a code you do not know rather than refusing the checkup. # Get API credentials > Create an integration in the console: its key pair, its credentials file, its scopes, and how to replace a key or revoke it. An API credential is called an integration: one system of yours that calls the API, such as a billing backend or a data warehouse. It proves who it is with a key pair. Your system keeps the private key, and YOU(th) stores only the public key. There is no client secret. ## Who creates it An administrator of your organization, in the YOU(th) console, in your organization's developer settings. Your [sandbox](/docs/sandbox) has integrations of its own, created the same way there. ## Create an integration 1. **Name it** after the system that uses it, such as "Billing backend". 2. **Choose its scopes**: see [Scopes](#scopes). 3. **Choose where its key pair is made:** | Choice | What happens | | ------------------------------ | ----------------------------------------------------------------------------------------------------------- | | The console generates the pair | Your browser makes the key pair, and you download a credentials file, once. YOU(th) receives the public key | | You upload a public key | You make the key pair on your own systems and upload its public key. The private key never leaves your side | Either way, the private key never reaches YOU(th). For a key pair of your own, use an `ES256` key (ECDSA on the P-256 curve); `RS256` works too, with an RSA key of 2048 bits or more. ## The credentials file When the console generates the key pair, it offers a credentials file with the four values your OAuth library needs to [get a token](/docs/authentication#get-a-token): - the token URL; - the client id; - the key id; - the private key, as PEM (PKCS 8). You can download it **once**. The console cannot show the private key again, because YOU(th) does not have it. Put the file's contents in your server's secret store at once, and keep it out of apps, browsers, repositories and logs. If you lose it, [replace the key](#replace-a-key). When you upload your own public key, there is no file: the console shows the integration's client id and the key id, and the token URL is the one on [Authentication](/docs/authentication). ## Scopes A scope is what an integration may do. Give each integration only the scopes its job needs. | Scope | Lets the integration | | -------------------- | --------------------------------------------- | | `access_codes:read` | Read batches and codes | | `access_codes:write` | Order batches, block a code, end an access | | `webhooks:write` | Create, read and disable webhook endpoints | | `checkups:read` | Read checkups: health data | | `patients:read` | Read members, as FHIR `Patient`s: health data | - `access_codes:write` also reads batches and codes. - Webhook endpoints have one scope: reading them takes `webhooks:write` too. - A token request names the scopes it wants, of those the integration was given: see [Get a token](/docs/authentication#get-a-token). ### Health data `checkups:read` and `patients:read` give access to health data, and have rules of their own: - **Only a Doctor gives them.** Being an administrator is not enough: one of your organization's Doctors gives an integration these scopes, and they last as long as that Doctor's own access to health data does. - **Only with consent.** They cover the members who consented to share their data with your organization, and no one else. - **Every read is logged**, before it is answered. > **Preview:** the routes these two scopes read are not available yet: see > [Catch up after an outage](/docs/webhooks/catch-up#the-read-api). ## Check your credentials [Get a token](/docs/authentication#get-a-token), then [ask which organization and integration it belongs to](/docs/api#operation-get_current_organization). The route needs no particular scope: ```bash curl https://api.youth-platform.io/v1/organization \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```json { "organization": { "alias": "example-mobile", "name": "Example Mobile" }, "integration": { "id": "0193b1a0-52c4-7b1e-a2d3-4f5a6b7c8d9e", "name": "Billing backend", "scopes": ["access_codes:read", "access_codes:write"] } } ``` `scopes` holds the scopes of the token you sent. The organization always comes from the integration: no route takes one in its address or its body. ## Replace a key A new key belongs to the same integration, so its client id and scopes stay: 1. Add a second key to the integration, generated in the console or uploaded. 2. Move your servers to the new key. 3. Remove the old key. YOU(th) refuses it from then on. An integration holds two keys at most, which is what a replacement needs. Replace a key at once when it is lost or may have leaked. ## Revoke an integration Revoke an integration when its system is retired, or when you cannot replace a leaked key fast enough. The API refuses it from the next request with `401` and `integration_revoked`, even with a token that has not expired yet. A revoked integration does not come back: create a new one. ## Several integrations An organization can have several integrations, one per system, each with its own key and scopes: five active at most. Revoking one leaves the others untouched, and frees its place. # Authentication > Get a short-lived token with your OAuth library and your integration's private key, and call the API with it. Your backend proves who it is with a key, not a password: 1. **You hold a private key**, and YOU(th) holds only its public half. There is no client secret. 2. **Your code uses the key to prove who it is**, and gets a token that is valid for a few minutes. 3. **You send the token** with each call to the API. 4. **Your OAuth library does the signing.** You give it four values from your credentials file. This is standard OAuth2: the client-credentials grant, with the client authentication that OAuth2 names `private_key_jwt` (RFC 7523). No person or browser is involved. ## What you need An integration, which your organization's administrators create in the console: see [Get API credentials](/docs/credentials). Its credentials file holds four values. Keep them on your server; the samples on this page read three of them from variables: | Value | In the samples | Is | | --------------- | ------------------- | --------------------------------------------------------------------------- | | The token URL | `TOKEN_URL` | `https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token` | | The client id | `YOUTH_CLIENT_ID` | Your integration's id | | The key id | `YOUTH_KEY_ID` | The id of the key you sign with | | The private key | `YOUTH_PRIVATE_KEY` | The key itself, as PEM text (PKCS 8) | ## Get a token Use your language's OAuth2 library, and set it up with these settings, under the names most libraries give them: | Setting | Value | | --------------------- | ----------------------------------------------------------------------------- | | Grant type | `client_credentials` | | Client authentication | `private_key_jwt` | | Token endpoint | The token URL | | Client id | The client id | | Signing key | The private key, with the key id as its `kid` | | Signing algorithm | Your key's: `ES256`, or `RS256` | | Scope | The scopes you want, of those your integration was given, separated by spaces | | Assertion audience | The token URL or the issuer: whichever your library sends | **Always send `scope`.** A token asked for without one is refused by every route of the API, with `401` and `invalid_token`. A library that supports OpenID Connect discovery needs only the issuer, `https://auth.youth-platform.io/realms/youth`, and reads the token URL from its metadata. The issuer is the token URL without `/protocol/openid-connect/token`. The answer holds the token and how many seconds it lasts: ```json { "access_token": "eyJhbGciOiJSUzI1NiIs…", "expires_in": 300, "token_type": "Bearer" } ``` ### Node: openid-client With [openid-client](https://github.com/panva/openid-client) (`npm install openid-client`): ```typescript import { createPrivateKey } from "node:crypto"; import * as client from "openid-client"; const ISSUER = "https://auth.youth-platform.io/realms/youth"; const key = await crypto.subtle.importKey( "pkcs8", createPrivateKey(process.env.YOUTH_PRIVATE_KEY ?? "").export({ type: "pkcs8", format: "der" }), { name: "ECDSA", namedCurve: "P-256" }, false, ["sign"], ); // Discovery reads the token URL from the issuer's metadata. const config = await client.discovery( new URL(ISSUER), process.env.YOUTH_CLIENT_ID ?? "", undefined, client.PrivateKeyJwt({ key, kid: process.env.YOUTH_KEY_ID ?? "" }), ); const tokens = await client.clientCredentialsGrant(config, { scope: "access_codes:read access_codes:write", }); // tokens.access_token, valid for tokens.expires_in seconds ``` ### Python: Authlib With [Authlib](https://docs.authlib.org) and Requests (`pip install authlib requests`). The session gets a token, sends it with each request, and gets a new one when it has expired: ```python import os from authlib.integrations.requests_client import OAuth2Session from authlib.oauth2.rfc7523 import PrivateKeyJWT from joserfc.jwk import ECKey TOKEN_URL = "https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token" session = OAuth2Session( os.environ["YOUTH_CLIENT_ID"], ECKey.import_key(os.environ["YOUTH_PRIVATE_KEY"]), token_endpoint_auth_method=PrivateKeyJWT( TOKEN_URL, headers={"kid": os.environ["YOUTH_KEY_ID"]}, alg="ES256" ), token_endpoint=TOKEN_URL, grant_type="client_credentials", scope="access_codes:read access_codes:write", ) session.fetch_token() response = session.get("https://api.youth-platform.io/v1/organization") response.raise_for_status() ``` ### Java: Nimbus With the [Nimbus OAuth 2.0 SDK](https://connect2id.com/products/nimbus-oauth-openid-connect-sdk) (`com.nimbusds:oauth2-oidc-sdk`): ```java import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.oauth2.sdk.ClientCredentialsGrant; import com.nimbusds.oauth2.sdk.Scope; import com.nimbusds.oauth2.sdk.TokenRequest; import com.nimbusds.oauth2.sdk.TokenResponse; import com.nimbusds.oauth2.sdk.auth.PrivateKeyJWT; import com.nimbusds.oauth2.sdk.id.ClientID; import java.net.URI; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; public class Token { public static void main(String[] args) throws Exception { URI tokenUrl = URI.create("https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token"); String pem = System.getenv("YOUTH_PRIVATE_KEY").replaceAll("-----[A-Z ]+-----|\\s", ""); PrivateKey key = KeyFactory.getInstance("EC") .generatePrivate(new PKCS8EncodedKeySpec(Base64.getDecoder().decode(pem))); PrivateKeyJWT assertion = new PrivateKeyJWT( new ClientID(System.getenv("YOUTH_CLIENT_ID")), tokenUrl, JWSAlgorithm.ES256, key, System.getenv("YOUTH_KEY_ID"), null); TokenRequest request = new TokenRequest( tokenUrl, assertion, new ClientCredentialsGrant(), new Scope("access_codes:read", "access_codes:write")); TokenResponse response = TokenResponse.parse(request.toHTTPRequest().send()); if (!response.indicatesSuccess()) { throw new IllegalStateException(response.toErrorResponse().getErrorObject().toString()); } String token = response.toSuccessResponse().getTokens().getAccessToken().getValue(); } } ``` ## Call the API with it Send the token in the `Authorization` header of every request: ```bash curl https://api.youth-platform.io/v1/organization \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` [`GET /v1/organization`](/docs/credentials#check-your-credentials) answers your organization and your integration, whatever the token's scopes: call it first, to check new credentials. The `curl` examples on the other pages send the token the same way, as `$YOUTH_ACCESS_TOKEN`. A token lasts about five minutes. Reuse it until shortly before it expires, then get a new one; do not get a token for every request. ## Without a library If your stack has no library for `private_key_jwt`, this is what one sends. For every token request, sign a new JWT, the client assertion. Its header names the key: | Header | Holds | | ------ | ---------------------------------------- | | `alg` | The key's algorithm: `ES256`, or `RS256` | | `kid` | The key id | | `typ` | `JWT` | Its claims say who asks, whom, and for how long: | Claim | Holds | | ------------ | --------------------------------------------------------------- | | `iss`, `sub` | Your client id, in both | | `aud` | The token URL, or the issuer | | `jti` | An id of its own, such as a UUID: an assertion is accepted once | | `iat` | Now, in Unix seconds | | `exp` | When it expires: one minute from now is enough | Send it to the token URL, as a form: | Field | Holds | | ----------------------- | -------------------------------------------------------- | | `grant_type` | `client_credentials` | | `scope` | The scopes you want, of those your integration was given | | `client_assertion_type` | `urn:ietf:params:oauth:client-assertion-type:jwt-bearer` | | `client_assertion` | The assertion you signed | The two samples sign with an `ES256` key. For an `RS256` key, change the algorithm they name and sign with. ### In TypeScript With Node's own `crypto`: ```typescript import { createPrivateKey, randomUUID, sign } from "node:crypto"; const TOKEN_URL = "https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token"; // The scopes this system needs, of those your integration was given. const SCOPE = "access_codes:read access_codes:write"; const base64url = (value: object) => Buffer.from(JSON.stringify(value)).toString("base64url"); /** A JWT signed with your private key, which proves one token request is yours. */ function clientAssertion(now: number): string { const clientId = process.env.YOUTH_CLIENT_ID ?? ""; const issuedAt = Math.floor(now / 1000); const header = { alg: "ES256", kid: process.env.YOUTH_KEY_ID ?? "", typ: "JWT" }; const claims = { iss: clientId, sub: clientId, aud: TOKEN_URL, jti: randomUUID(), iat: issuedAt, exp: issuedAt + 60, }; const signed = `${base64url(header)}.${base64url(claims)}`; // A JWT's ES256 signature is the two numbers side by side, not the DER that `sign` defaults to. const signature = sign("sha256", Buffer.from(signed), { key: createPrivateKey(process.env.YOUTH_PRIVATE_KEY ?? ""), dsaEncoding: "ieee-p1363", }); return `${signed}.${signature.toString("base64url")}`; } let cached: { token: string; expiresAt: number } | undefined; /** A token for the API, reused until a minute before it expires. */ export async function accessToken(now = Date.now()): Promise { if (cached && now < cached.expiresAt) return cached.token; const response = await fetch(TOKEN_URL, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ grant_type: "client_credentials", scope: SCOPE, client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", client_assertion: clientAssertion(now), }), }); if (!response.ok) throw new Error(`The token was refused: ${response.status}`); const answer: { access_token: string; expires_in: number } = await response.json(); cached = { token: answer.access_token, expiresAt: now + (answer.expires_in - 60) * 1000 }; return cached.token; } ``` ### In Python With [PyJWT](https://pyjwt.readthedocs.io) and [Requests](https://requests.readthedocs.io) (`pip install "pyjwt[crypto]" requests`): ```python import os import time import uuid import jwt import requests TOKEN_URL = "https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token" def access_token(scope: str) -> str: """A new token for the API. Keep it, and reuse it until shortly before it expires.""" client_id = os.environ["YOUTH_CLIENT_ID"] now = int(time.time()) assertion = jwt.encode( { "iss": client_id, "sub": client_id, "aud": TOKEN_URL, "jti": str(uuid.uuid4()), "iat": now, "exp": now + 60, }, os.environ["YOUTH_PRIVATE_KEY"], algorithm="ES256", headers={"kid": os.environ["YOUTH_KEY_ID"]}, ) response = requests.post( TOKEN_URL, data={ "grant_type": "client_credentials", "scope": scope, "client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", "client_assertion": assertion, }, timeout=10, ) response.raise_for_status() return response.json()["access_token"] token = access_token("access_codes:read access_codes:write") response = requests.get( "https://api.youth-platform.io/v1/organization", headers={"Authorization": f"Bearer {token}"}, timeout=10, ) response.raise_for_status() ``` ## When the token request is refused The token URL answers `400` or `401` with an OAuth2 error, and says more in `error_description`: | `error` | `error_description` | Means | | ---------------- | -------------------------------- | ------------------------------------------------------------------------------------ | | `invalid_client` | `Invalid token audience` | The assertion's audience is neither the token URL nor the issuer, exactly as written | | `invalid_client` | `Token is not active` | The assertion has expired: check your server's clock | | `invalid_client` | `Token reuse detected` | The same assertion came twice: every token request needs a new one | | `invalid_client` | `Unable to load public key` | The key id names no key of this integration, or the key was removed | | `invalid_client` | `Invalid signature algorithm` | The signing algorithm is not that of the key YOU(th) holds | | `invalid_client` | It names the signature | The assertion was signed with another private key | | `invalid_client` | It names `client_assertion_type` | The request sent no assertion, or a client secret in its place | | `invalid_scope` | It names the scopes | `scope` asks for one your integration was not given | ## When the API refuses a token | Answer | `code` | Means | | ------ | --------------------- | --------------------------------------------------------------------- | | `401` | `invalid_token` | No token, an expired or unknown one, or one asked for without `scope` | | `401` | `integration_revoked` | The integration was revoked, even if the token has not expired yet | | `403` | `insufficient_scope` | The token is valid, but lacks the route's scope | A `401` carries a `WWW-Authenticate: Bearer` header: alone when the request had no token, and with `error="invalid_token"` when its token did not hold. Every refusal has the body [Errors and rate limits](/docs/errors) describes. Your integration belongs to one organization, and the API answers only that organization's data: see [Your organization](/docs/concepts#your-organization). No route takes an organization in its address or its body. ## Keep the key safe - Keep the private key on your server, in its secret store: never in an app, a browser or a repository. - Never log the key, an assertion or a token. - Replace a key that is lost or may have leaked: [add a new key](/docs/credentials#replace-a-key) to the same integration, move your servers to it, then remove the old one. Nothing stops in between. - [Revoke an integration](/docs/credentials#revoke-an-integration) you no longer use. The API refuses it from the next request. # Sandbox > Build and test in a second organization of yours, which only your own testers join. Any organization can be used for testing. A sandbox is simply a second organization of yours that you keep for it: same hosts, same routes, same events and signatures as your live one. You decide who joins it. What makes an organization live is your agreement with YOU(th): the codes and limits you agreed are set on your live organization. A sandbox keeps the defaults every new organization starts with. ## What a sandbox has of its own | Yours in the sandbox | Means | | -------------------- | ------------------------------------------------------------------------------------------------- | | Credentials | Integrations, with keys that reach the sandbox only: see [Get API credentials](/docs/credentials) | | Webhook endpoints | Their own addresses and signing secrets, so test deliveries go to your test receiver | | Access codes | Batches and codes of its own, for your testers | | Members | Only the people you gave a sandbox code to | Going live changes your credentials, your signing secret and your receiver's address, and no code of yours. ## Know where you are An integration belongs to one organization. Ask which: ```bash curl https://api.youth-platform.io/v1/organization \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```json { "organization": { "alias": "example-mobile-sandbox", "name": "Example Mobile (sandbox)" }, "integration": { "id": "0193b1a0-52c4-7b1e-a2d3-4f5a6b7c8d9e", "name": "Billing backend (test)", "scopes": ["access_codes:read", "access_codes:write", "webhooks:write"] } } ``` It is also the quickest check that your credentials work. Have your test systems refuse to start when `organization.alias` is not your sandbox. ## A whole run 1. [Create a webhook endpoint](/docs/webhooks/endpoints) for your test receiver. 2. [Order a batch](/docs/access-codes/order) of a few codes and read them. 3. Give one code's `redeem_url` to a tester. They redeem it in the YOU(th) app as a customer would, with an account in your sandbox. 4. Check that your receiver got [`AccessCode.redeemed`](/docs/webhooks#accesscoderedeemed) and stored the time. 5. [End its access](/docs/access-codes/end-access) with `ends_at` left out, and check that your receiver got `Access.ended` and that the tester's app shows it. 6. Stop your receiver, have a second code redeemed, and [catch up](/docs/access-codes/reconcile#catch-up-after-an-outage) from the list. ## Go live 1. In your live organization, create an integration and a webhook endpoint. 2. Give your production backend the live client id, key id, private key and signing secret. 3. Check `GET /v1/organization`: `organization.alias` is your live one. 4. Order your first live batch. Ask your YOU(th) contact for a sandbox when you start. # Sell access with codes > Order codes, hand one to each customer, hear when it is redeemed, and end the access with one call. An access code gives one person access to YOU(th) for as long as you say. You order codes in batches, hand one to each customer, and YOU(th) tells your system when it is redeemed. This is how a company sells YOU(th) beside its own product: a mobile operator, an insurer, a gym. YOU(th) and your system exchange codes and dates only. No name, email address, phone number or health data crosses in either direction. ## How it fits together 1. **You order a batch of codes** with the API, and read them. 2. **You hand a code to a customer**, as a link or as text, wherever you sell: your app, your shop, an email. 3. **The customer redeems it** in the YOU(th) app, where they create their account and accept YOU(th)'s terms. 4. **YOU(th) sends your receiver `AccessCode.redeemed`**, with the code's id and the time. You bill from that time, if you bill by period. 5. **You end the access** with one call when the customer cancels or stops paying. Until then it continues: you send nothing for a renewal. 6. **YOU(th) sends `Access.ended`** when the access has stopped. | Step | Who | With | | --------------------- | -------- | ------------------------------------------------------------------------------------------ | | Order a batch | You | [`POST /v1/access-code-batches`](/docs/access-codes/order) | | Receive the codes | You | [`GET /v1/access-codes`](/docs/access-codes/order#read-the-codes), as JSON or one CSV file | | Hand out a code | You | Your own systems | | Redeem it | Customer | The YOU(th) app | | Learn it was redeemed | YOU(th) | The [`AccessCode.redeemed`](/docs/webhooks#accesscoderedeemed) event | | End the access | You | [`PUT /v1/access-codes/{access_code_id}/access`](/docs/access-codes/end-access) | | Learn it has ended | YOU(th) | The [`Access.ended`](/docs/webhooks#accessended) event | | Check a month | You | [`GET /v1/access-codes?status=`](/docs/access-codes/reconcile) | ## What you build Three things, each small: 1. **A call that orders a batch and reads its codes**, as JSON or as one CSV file: see [Order and read codes](/docs/access-codes/order). 2. **A webhook receiver** that verifies a delivery and stores the time of each `AccessCode.redeemed`: see [Manage your endpoints](/docs/webhooks/endpoints), [Verify a delivery](/docs/webhooks/verify) and [Retries and duplicates](/docs/webhooks/retries). 3. **A call that ends an access**: see [End a customer's access](/docs/access-codes/end-access). Every call takes a token your backend gets with its integration's key: see [Authentication](/docs/authentication). An integration with the scopes `access_codes:write` and `webhooks:write` does all three. ## What you do not build - **No exchange of customer data.** The code is the only thing both sides know. The customer gives YOU(th) their details themselves, when they register. - **No renewal calls.** Access continues until you end it. - **No polling.** YOU(th) tells you about a redemption as it happens. - **No API of yours for YOU(th) to call.** You expose one HTTPS address that takes deliveries. ## A code's life | `status` | Means | Next | | ------------- | ------------------------------------------------- | -------------------------------------- | | `available` | Nobody has redeemed it | `redeemed`, `deactivated` or `expired` | | `redeemed` | A person redeemed it and has access | `ended` | | `ended` | The access it started has stopped | None | | `deactivated` | You blocked it before anyone redeemed it | None | | `expired` | Nobody redeemed it before its batch's `redeem_by` | None | - **A code is used once.** A customer who comes back after their access ended gets a new code. - **A code can wait.** A customer can redeem it weeks after you handed it over, until the batch's `redeem_by`. - **A code names no person.** The API speaks of the access a code started, never of who redeemed it. ## How the customer redeems A code comes with a `redeem_url`, the link that redeems it in the YOU(th) app. Offer the link where you can: - **The link.** It opens the YOU(th) app, or its store page when the app is not installed, with your organization and the code filled in. The customer types nothing. If the app doesn't open on your organization, the customer chooses it from the app's list of organizations when they first open it, then types the code. - **The code as text.** The customer installs the YOU(th) app, chooses your organization from its list, creates an account and types the code, twelve digits, as you show it: without spaces. When your organization's members redeem in an app of its own, not the YOU(th) app, `redeem_url` is `null`: no YOU(th) link opens your app, so hand out the code as text, which the customer types in your app. A code is redeemed with an account created under your organization. The link fills in your organization and the code only in a YOU(th) app that has no organization yet. A YOU(th) app already set up for your organization opens as it is, and the customer types the code. One set up for another organization, YOU(th)'s own included, can't redeem it. ## Try it first A [sandbox](/docs/sandbox) is a second organization of yours, which only your own testers join. Your backend orders codes there, a tester redeems one in the app, and your receiver and your billing are tested end to end before a customer is involved. ## Build it with an assistant [Use the docs with AI](/docs/ai#sell-access-with-codes) has a prompt that builds the receiver and the call that ends an access, in your stack. # Order and read codes > Order a batch of access codes, read them with their links, and block one. A batch is one order of codes: how many, what access each grants, and until when they can be redeemed. Your backend orders a batch with the scope `access_codes:write`, and reads its codes with `access_codes:read` or `access_codes:write`. ## Order a batch ```bash curl https://api.youth-platform.io/v1/access-code-batches \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \ --header "Content-Type: application/json" \ --header "Idempotency-Key: 5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11" \ --data '{ "count": 1000, "label": "december-2026", "redeem_by": "2027-12-31T23:59:59Z", "access": { "term": "until_ended" } }' ``` | Field | Means | | ----------- | ---------------------------------------------------------------------------------------------------------- | | `count` | How many codes, at most 20,000 in one order and within your [daily limit](#the-daily-limit) | | `label` | A name of yours for the batch, such as the month or your order number. It is never shown to a customer | | `redeem_by` | The last moment a code of this batch can be redeemed, still to come and at most five years ahead. Optional | | `access` | What a redeemed code grants: see below | | `access.term` | A redeemed code grants | | ------------- | ------------------------------------------------------------------------------------------ | | `until_ended` | Access until you [end it](/docs/access-codes/end-access): for a service you bill by period | | `fixed_days` | Access for `access.days` days from the redemption, then it ends by itself | The answer is `201` once every code can be read and redeemed, with the batch `ready` and its address in `Location`: ```json { "id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "label": "december-2026", "status": "ready", "count": 1000, "redeem_by": "2027-12-31T23:59:59.000Z", "access": { "term": "until_ended" }, "created_at": "2026-12-01T10:00:00.000Z" } ``` An order must carry an `Idempotency-Key` header of your own, a UUID for example, of at most 255 characters. The same key with the same body answers the first order again, within 24 hours of the latest attempt, so a request you repeat after a timeout never orders twice. | Answer | `code` | Means | | ------ | -------------------------- | ------------------------------------------------------------------------------------------------------ | | `400` | `idempotency_key_required` | The order has no `Idempotency-Key` | | `400` | `idempotency_key_invalid` | The key is empty, or longer than 255 characters | | `409` | `idempotency_conflict` | The key was already used with another body: use a new key | | `409` | `idempotency_in_progress` | An order with the key runs now: send it again after `Retry-After` seconds | | `409` | `app_not_set_up` | Your organization isn't in the YOU(th) app yet, so no code could be redeemed: ask your YOU(th) contact | | `422` | `invalid_request` | A field is missing or not valid, or the order doesn't take it, such as a misspelt one | | `422` | `redeem_by_passed` | `redeem_by` has passed | | `422` | `redeem_by_too_far` | `redeem_by` is more than five years ahead | | `422` | `count_over_limit` | The order would take you past your [daily limit](#the-daily-limit): nothing was made | | `503` | `temporarily_unavailable` | Not now: send the same order again after `Retry-After` seconds | Making thousands of codes takes a few seconds. When an order can't be finished now, it answers `503` with `Retry-After`: repeat it, or one that timed out, with the same key and body, and it goes on with the same batch, never a second one. Every refusal has the body [Errors and rate limits](/docs/errors) describes. ### The daily limit Your organization's batches ordered in one day, from 00:00 UTC, hold at most 1,000 codes together, whatever became of them since. An order that would pass it answers `422` `count_over_limit` and makes nothing: order fewer, with a new `Idempotency-Key` (the refused key answers another body `409`), or wait for the next day. A repeat of an order with the same key goes on with its batch and isn't counted again. Need more? Ask your YOU(th) contact to raise your organization's limit. ## Read a batch ```bash curl https://api.youth-platform.io/v1/access-code-batches/0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21 \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` | `status` | Means | | ---------- | ------------------------------------------------------------------------------------------------------ | | `ready` | Every code can be read and redeemed | | `creating` | An order answered `503` and hasn't been sent again yet: send it again with the same key | | `failed` | No order went on with it for a day: none of its codes is listed or billed. Order again, with a new key | ## Read the codes ```bash curl "https://api.youth-platform.io/v1/access-codes?batch_id=0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21" \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```json { "items": [ { "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "code": "482957362845", "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845", "status": "available", "redeemed_at": null, "access": { "term": "until_ended", "ends_at": null } } ], "next": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34" } ``` | Field | Means | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `id` | The code's id: what events and the other routes name. Store it beside the code | | `code` | What the customer types. An opaque string: store and show it exactly as it is, without spaces | | `redeem_url` | The link that redeems it, or `null` when your members redeem in an app of your own: see [How the customer redeems](/docs/access-codes#how-the-customer-redeems) | | `status` | Where the code is in [its life](/docs/access-codes#a-codes-life) | | `redeemed_at` | When it was redeemed, or `null` | | `access.ends_at` | When its access ends or ended, or `null` while no end is set | - The list holds the codes of `ready` batches alone, in a stable order. - As JSON, the list comes a page at a time, 100 codes unless `limit` says otherwise (at most 1,000). Pass a page's `next` as `after` to read the next page; the last page has no `next`. - `next` is for one pass through the list, not a feed of what is new: a batch that becomes `ready` later can sort before codes you have already read. Read a new batch's codes with `batch_id`. - Send `Accept: text/csv` for one CSV file of every matching code, one code per line. The file is not paged: it takes no `after` or `limit`, and holds every code the filters keep, up to 50,000. More answer `422` `too_many_codes`: filter by `batch_id` or a time range, or read pages as JSON. - An `after` that isn't an id, or an `after` or `limit` sent for a CSV file, answers `422` `invalid_request`. - `GET /v1/access-codes/{access_code_id}` reads one code. Another organization's code, or one that doesn't exist, answers `404` `not_found`. - The code and its link are secrets until redeemed: whoever has one can redeem it. Keep them out of logs, and hand each to one customer only. - Use `redeem_url` exactly as it is: do not build it from the code. ### As a CSV file ```bash curl "https://api.youth-platform.io/v1/access-codes?batch_id=0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21" \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \ --header "Accept: text/csv" \ --output december-2026.csv ``` The file starts with a header line, and an empty field means `null`: ```text id,batch_id,code,redeem_url,status,redeemed_at,access_term,access_ends_at 0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34,0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21,482957362845,https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845,available,,until_ended, ``` Opening the file in a spreadsheet such as Excel, import the `code` column as text: read as a number, a code of twelve digits is shown as `4.82957E+11`, not as the code to give your customer. ## Block a code you will not use A code you handed to nobody, or to the wrong person, can be blocked while nobody has redeemed it, `available` or `expired`: ```bash curl --request POST \ https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/deactivate \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` It becomes `deactivated` and can never be redeemed; the answer is the code. Blocking it again changes nothing and answers the same, so repeat it safely after a timeout. It needs the scope `access_codes:write`. | Answer | `code` | Means | | ------ | ------------------------- | ----------------------------------------------------------------------------------------------- | | `404` | `not_found` | No code of yours has this id | | `409` | `already_redeemed` | Someone redeemed the code: [end its access](/docs/access-codes/end-access) instead | | `409` | `redemption_in_progress` | Someone is redeeming the code this moment: send the same call again after `Retry-After` seconds | | `422` | `invalid_request` | The code's id in the address isn't an id | | `503` | `temporarily_unavailable` | Not now: send the same call again after `Retry-After` seconds | # End a customer's access > Set when the access a code started ends, and what YOU(th) sends when it has. Access that a code started with the term `until_ended` continues until you end it. You end it with one call, when your customer cancels or stops paying. It needs the scope `access_codes:write`. ## End it Get a [token](/docs/authentication), then set when the access ends: ```bash curl --request PUT \ https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/access \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "ends_at": "2027-01-12T00:00:00Z" }' ``` The answer is the code, with the end you set: ```json { "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "code": "482957362845", "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845", "status": "redeemed", "redeemed_at": "2026-12-12T09:30:00.375Z", "access": { "term": "until_ended", "ends_at": "2027-01-12T00:00:00.000Z" } } ``` | `ends_at` | Does | | ---------------------- | ----------------------------------------------------------------------- | | A time to come | Access ends then: the end of the paid period, or of your grace period | | Left out | Access ends now | | A time that has passed | Access ends now, as if left out | | `null` | Removes an end that has not passed yet: the customer changed their mind | - **Call when you know.** Send the end as soon as the customer cancels, with the date to come, or on the day itself. Both work. - **Repeat it safely.** The same call twice leaves the same end, and a call that ends an access already ended answers `200` with the code as it is. Try again after a timeout without checking first. A later call replaces the end while it has not passed. - **A redemption takes a minute to arrive.** The API hears of a redemption within about a minute. A `409` `not_redeemed` for a code your customer has just redeemed is worth repeating a minute later. - **Your rules stay yours.** Billing periods, renewals and grace periods are in your system. YOU(th) keeps one date per code: the end you sent. - **An end that has passed is final.** The code is `ended`: a call that sets a later end, or `null`, answers `409`. A customer who returns gets a new code. ## What happens then When `ends_at` passes, the code answers `ended`. Within about 10 minutes the person can no longer use what the code gave them in the YOU(th) app, and YOU(th) sends your receiver [`Access.ended`](/docs/webhooks#accessended) with the reason `ended_by_partner` and your end as its `occurred_at`; later if YOU(th) can't reach the app then. Stop billing on your own date; the event confirms it. `Access.ended` can also come without a call of yours: | `reason` | Means | | ------------------ | ------------------------------------------------------ | | `ended_by_partner` | The `ends_at` you set has passed | | `term_over` | A code with the term `fixed_days` reached its last day | ## When the call is refused | Answer | `code` | Means | | ------ | ------------------------- | -------------------------------------------------------------------------------------------------------- | | `404` | `not_found` | No code of yours has this id | | `409` | `not_redeemed` | Nobody has redeemed the code: [block it](/docs/access-codes/order#block-a-code-you-will-not-use) instead | | `409` | `access_ended` | Its access has already ended, and the call asks for a later end or for none | | `422` | `invalid_request` | `ends_at` is not a time, the body holds a field the call doesn't take, or the code's id isn't an id | | `422` | `ends_at_beyond_term` | `ends_at` is later than the code's own term: a `fixed_days` code cannot be extended past its days | | `503` | `temporarily_unavailable` | Not now: send the same call again after `Retry-After` seconds | Every refusal has the body [Errors and rate limits](/docs/errors) describes. # Reconcile and catch up > List your codes by what happened to them, to check a month and to catch up after an outage. A webhook is a hint, not the record. The record is the list of your codes: which were redeemed and when, and which have ended. Read it to check a month's invoice, and to catch up after your receiver was down. It needs the scope `access_codes:read`. ## List codes by what happened ```bash curl "https://api.youth-platform.io/v1/access-codes?status=redeemed&redeemed_from=2026-12-01T00:00:00Z" \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` | Filter | Keeps | | --------------- | ------------------------------------------------------------------------ | | `batch_id` | The codes of one batch | | `status` | The codes in one [status](/docs/access-codes#a-codes-life) | | `redeemed_from` | The codes redeemed at or after this time | | `redeemed_to` | The codes redeemed before this time | | `ended_from` | The codes whose access ended at or after this time, and has ended by now | | `after` | The next page: the `next` of the page before | | `limit` | How many codes a page holds: 1 to 1,000, 100 unless set | Each item is a code as [Read the codes](/docs/access-codes/order#read-the-codes) shows it. Send `Accept: text/csv` for a file your finance team can open: one CSV file of every matching code, not paged, up to 50,000 codes. A list longer than that answers `422` `too_many_codes`: ask for a month at a time, with `redeemed_from` and `redeemed_to`, or a batch at a time with `batch_id`. Page through a list in one go, with `after`: `next` is not a feed of what is new, and a batch that becomes `ready` later can sort before codes you have already read. Read a new batch's codes with `batch_id`. ## Check a month Compare the list with your own records: 1. List the codes redeemed up to the end of the month, with `redeemed_to`. 2. For each, compare `redeemed_at` with the activation you stored, and `access.ends_at` with the end you sent. 3. A code that is cancelled in your system, and `redeemed` in the list with no `access.ends_at`, is an end that never reached YOU(th): [send it again](/docs/access-codes/end-access). 4. A code that is `ended` in the list and active in your system is an `Access.ended` you missed: stop billing it. ## Catch up after an outage When your receiver was down for longer than YOU(th) [retries](/docs/webhooks/retries), list the codes redeemed since a little before the newest `AccessCode.redeemed` you have, an hour before for example: ```bash curl "https://api.youth-platform.io/v1/access-codes?redeemed_from=2026-12-12T08:30:00Z" \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` Skip the codes you already have, as you skip an `event_id` you have seen. `redeemed_at` is the time the event carried in `occurred_at`. Then list the accesses that ended meanwhile, which you would have heard of with `Access.ended`: ```bash curl "https://api.youth-platform.io/v1/access-codes?status=ended&ended_from=2026-12-12T08:30:00Z" \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` Each has its end in `access.ends_at`. ## Make it routine Run both lists on a schedule, once a day for example. Then an event lost on the way costs a delay, and never a customer who has access and is not billed. ## Read one code ```bash curl https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34 \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` This is the address an event's `resource_url` names. # Events > What YOU(th) tells your system, and what each delivery carries. When something happens in your organization, to one of its members or to one of its access codes, YOU(th) tells your system with an event: a signed `POST` to the HTTPS address you registered, for each event you subscribed to. A delivery says what happened and where to read it. ## Events | `event_type` | Sent when | Resource | | --------------------- | ------------------------------------------------- | ---------------- | | `AccessCode.redeemed` | A person redeemed one of your access codes | The access code | | `Access.ended` | The access a code started has ended | The access code | | `Checkup.completed` | Preview: a member of yours completed a checkup | `Bundle` (FHIR) | | `Patient.registered` | Preview: a person registered as a member of yours | `Patient` (FHIR) | > **Preview:** `Checkup.completed` and `Patient.registered` are not available yet. What this page > says of them, and of reading a checkup or a member from a `resource_url`, is proposed and may > change. `AccessCode.redeemed` and `Access.ended` are final, and are sent to the endpoints that > take them. Each event type documents its own resource. New event types can appear: answer `2xx` to one you do not handle. A webhook endpoint is one address of yours that takes deliveries: its HTTPS address, and the events it receives. Your backend creates it with the API: see [Manage your endpoints](/docs/webhooks/endpoints). Each endpoint has its own signing secret, shown once when it is created. An organization can have several endpoints, and your [sandbox](/docs/sandbox) has its own. ## The body Every event shares one envelope. A checkup's, a preview, looks like this: ```json { "event_id": "evt_e560fc965cf89b3d5a8c3ed27406806f", "event_type": "Checkup.completed", "occurred_at": "2026-10-01T09:30:00.375000Z", "patient_id": "cfefb422-ac79-4cb9-a849-e80f8a6f21cd", "checkup_id": "64d866f3-0c88-485c-bfe6-3339df1d224a", "resource_url": "https://api.youth-platform.io/v1/checkups/64d866f3-0c88-485c-bfe6-3339df1d224a/fhir" } ``` | Field | Means | | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `event_id` | The event, `evt_` and 32 hex digits. The same on every retry: deduplicate on it | | `event_type` | From the table above | | `occurred_at` | When what the event reports happened, ISO 8601 in UTC: see below | | `patient_id` | The member; in `Checkup.completed` and `Patient.registered` | | `checkup_id` | The checkup; only in `Checkup.completed` | | `access_code_id` | The access code's id; in `AccessCode.redeemed` and `Access.ended` | | `batch_id` | The code's batch; in `AccessCode.redeemed` and `Access.ended` | | `reason` | Why the access ended; only in `Access.ended` | | `resource_url` | Where to read the resource: the checkup's bundle, the member's `Patient` or the access code, in the read-API version your integration is set to, today `/v1`. You can also build it from the ids: see [Versions](/docs/versions) | - `occurred_at` is when what the event reports happened, not when it was sent: - `Checkup.completed`: the checkup's completion, which is the `issued` of its bundle's `DiagnosticReport` and what the [catch-up list](/docs/webhooks/catch-up#list-what-you-missed)'s `completed_from` filters on; - `Patient.registered`: the member's registration; - `AccessCode.redeemed`: the redemption, which is the code's `redeemed_at`; - `Access.ended`: the end you set with [`PUT …/access`](/docs/access-codes/end-access), or the end of the code's term. - Most events are sent within seconds, but one can come later than its `occurred_at`: an `Access.ended` comes once the app has ended the access, within about 10 minutes of its end, later when YOU(th) can't reach the app; and, rarely, an `AccessCode.redeemed` comes up to a day after the redemption. - `AccessCode.redeemed` and `Access.ended` name a code and never a person: they have no `patient_id`. See [their examples](#accesscoderedeemed). - `Patient.registered` has no `checkup_id`; its `resource_url` points at the `Patient`. - Ids are opaque strings. Store them as they are; do not rely on their length or format. - New fields and new event types can appear. Ignore fields you do not know; answer `2xx` to an event you do not handle. A change that could break your receiver comes as a new event type, never as a change to one you receive: see [Versions](/docs/versions). ## What a delivery carries Ids, never the resource: your backend reads it from `resource_url` with an [access token](/docs/authentication). A delivery sent to a wrong address, or kept in a gateway's or a queue's logs, then holds no personal or health data, and every read is checked against your integration's scopes when it happens. - An access event names a code and its batch, never a person. - A checkup's or a member's event is sent only for a member who consented to share their data with your organization, and reading its `resource_url` takes the scope `checkups:read` or `patients:read`: see [Health data](/docs/credentials#health-data). - A checkup's bundle is built once, when the event happens: reading `resource_url` answers the same bundle every time. - Reading a member's `resource_url` answers the `Patient` as it is now. ## The request | | | | --------- | --------------------------------------------------------------------------- | | Method | `POST`, to your HTTPS address, on port 443 | | Body | JSON, compact, keys sorted, UTF-8. Verify the raw bytes; never re-serialize | | Success | Any `2xx` within ten seconds | | Redirects | Not followed. A `3xx` counts as a failure that is not retried | | Order | None. Deliveries can arrive in any order and more than once | Headers, as [Standard Webhooks](https://www.standardwebhooks.com/) names them (their names are case-insensitive): | Header | Holds | | ------------------- | ------------------------------------------------------------------------------------------------ | | `Content-Type` | `application/json` | | `webhook-id` | The `event_id`. The same on every retry: deduplicate on it | | `webhook-timestamp` | When this attempt was signed, in Unix seconds | | `webhook-signature` | `v1,`, or several separated by spaces: see [Verify a delivery](/docs/webhooks/verify) | YOU(th) adds two headers of its own, to route and log a delivery before you read its body: | Header | Holds | | ------------------------ | --------------------------------------------------- | | `youth-event-type` | The `event_type`, such as `Checkup.completed` | | `youth-delivery-attempt` | Which attempt this is: `1` for the first, up to `8` | They are not signed. Act on the verified body, and trust it over them if they ever differ. Verify every delivery before you act on it, and answer fast: see [Retries and duplicates](/docs/webhooks/retries). ## Examples The bodies below are pretty-printed for reading. On the wire a body is compact, with its keys sorted, as in the first example; verify the bytes as you received them. ### A whole request This request is really signed: the fixture secret on [Verify a delivery](/docs/webhooks/verify#try-it) verifies it. ```http POST /youth-webhook HTTP/1.1 Host: partner.example.com Content-Type: application/json webhook-id: evt_e560fc965cf89b3d5a8c3ed27406806f webhook-timestamp: 1790847002 webhook-signature: v1,f/69pGXkwyZXFdzr/vJ44kTIC3ThgR+du6f4olitEV0= youth-event-type: Checkup.completed youth-delivery-attempt: 1 {"checkup_id":"64d866f3-0c88-485c-bfe6-3339df1d224a","event_id":"evt_e560fc965cf89b3d5a8c3ed27406806f","event_type":"Checkup.completed","occurred_at":"2026-10-01T09:30:00.375000Z","patient_id":"cfefb422-ac79-4cb9-a849-e80f8a6f21cd","resource_url":"https://api.youth-platform.io/v1/checkups/64d866f3-0c88-485c-bfe6-3339df1d224a/fhir"} ``` ### `Patient.registered` ```json { "event_id": "evt_3b9e0f6a1c2d4e5f8a7b6c5d4e3f2a1b", "event_type": "Patient.registered", "occurred_at": "2026-10-01T08:12:40.120000Z", "patient_id": "cfefb422-ac79-4cb9-a849-e80f8a6f21cd", "resource_url": "https://api.youth-platform.io/v1/patients/cfefb422-ac79-4cb9-a849-e80f8a6f21cd/fhir" } ``` ### `AccessCode.redeemed` ```json { "event_id": "evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c", "event_type": "AccessCode.redeemed", "occurred_at": "2026-12-12T09:30:00.375000Z", "access_code_id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "resource_url": "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34" } ``` `occurred_at` is the redemption: the time to bill from. `access_code_id` is the `id` you got with the code when you [read the batch](/docs/access-codes/order#read-the-codes). ### `Access.ended` ```json { "event_id": "evt_7c1e5a9b3d2f4a6c8e0b1d3f5a7c9e2b", "event_type": "Access.ended", "occurred_at": "2027-01-12T00:00:00.000000Z", "access_code_id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "reason": "ended_by_partner", "resource_url": "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34" } ``` `reason` is `ended_by_partner` or `term_over`: see [What happens then](/docs/access-codes/end-access#what-happens-then). New reasons can appear. # Manage your endpoints > Create, read and disable the addresses that take your deliveries, and keep each one's signing secret. A webhook endpoint is one address of yours that takes deliveries. Your backend creates and reads its organization's endpoints with the API, with the scope `webhooks:write`. There is no read-only scope for endpoints: reading them takes `webhooks:write` too. ## The routes | Route | Does | | ---------------------------------------------------------- | --------------------------------------------------- | | `POST /v1/webhook-endpoints` | Creates an endpoint, and answers its signing secret | | `GET /v1/webhook-endpoints` | Lists your organization's endpoints | | `GET /v1/webhook-endpoints/{webhook_endpoint_id}` | Reads one | | `POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable` | Stops deliveries to it | The endpoints are your organization's: another organization's endpoint answers `404`. Your [sandbox](/docs/sandbox) has endpoints of its own. ## Create an endpoint ```bash curl https://api.youth-platform.io/v1/webhook-endpoints \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \ --header "Content-Type: application/json" \ --header "Idempotency-Key: 6d1f2b0a-8f3c-4a77-9d1e-3b2f5c6a7d81" \ --data '{ "url": "https://partner.example.com/youth-webhook", "event_types": ["AccessCode.redeemed", "Access.ended"], "description": "Billing" }' ``` | Field | Means | | ------------- | ---------------------------------------------------------------------------------------- | | `url` | Where deliveries go, at most 2,048 characters: see [The address](#the-address) | | `event_types` | The events it receives, at least one and at most 20: see [Events](/docs/webhooks#events) | | `description` | A note of yours about it, such as the system it feeds, at most 200 characters. Optional | The answer is `201`, with the endpoint, its signing secret, and its address in `Location`: ```json { "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", "url": "https://partner.example.com/youth-webhook", "description": "Billing", "event_types": ["Access.ended", "AccessCode.redeemed"], "status": "active", "created_at": "2026-11-20T09:30:00.000Z", "updated_at": "2026-11-20T09:30:00.000Z", "signing_secret": "whsec_Zm9vYmFyYmF6cXV4LWV4YW1wbGUtc2VjcmV0LXZhbHVl" } ``` | Refused with | When | | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | `422` `url_not_allowed` | The address isn't `https` on port 443, carries a user or password, or names a host no delivery may go to: see [The address](#the-address) | | `409` `endpoint_limit_reached` | Your organization keeps ten endpoints already, disabled ones aside: disable one first | | `422` `unknown_event_type` | An event type isn't one YOU(th) sends | | `422` `invalid_request` | A field is missing, not valid, or not one the request takes | | `400` `idempotency_key_required` | The request has no `Idempotency-Key` | | `400` `idempotency_key_invalid` | The key is empty, or longer than 255 characters | | `409` `idempotency_conflict` | The `Idempotency-Key` was used for another body: use a new key | | `409` `idempotency_in_progress` | A request with the key runs now: send it again after `Retry-After` | | `503` `temporarily_unavailable` | The secret can't be made now: send it again after `Retry-After` | ## Read and list endpoints `GET /v1/webhook-endpoints/{webhook_endpoint_id}` answers one endpoint as above, without its `signing_secret`. `GET /v1/webhook-endpoints` answers your endpoints oldest first, a page at a time: `limit` sets the page's length, 50 unless you say, at most 100, and you pass a page's `next` as `after` for the next one. The last page's `next` is `null`. An `after` that isn't one of your endpoints is refused with `422` `invalid_request`. ```json { "items": [ { "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", "url": "https://partner.example.com/youth-webhook", "description": "Billing", "event_types": ["Access.ended", "AccessCode.redeemed"], "status": "active", "created_at": "2026-11-20T09:30:00.000Z", "updated_at": "2026-11-20T09:30:00.000Z" } ], "next": null } ``` ## Disable an endpoint `POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`, with no body, stops an active or a paused endpoint and answers it, `disabled`. Every delivery it still had to receive fails at once: read what it missed from the API. A delivery already on its way when you disable it still arrives. A disabled endpoint can't be turned on again: create one for the address instead. Disabling it again answers it as it stands. ## What an endpoint holds - **Its address**, where YOU(th) sends each delivery: see [The address](#the-address). - **The events it receives**, by `event_type`: see [Events](/docs/webhooks#events). An event type YOU(th) does not know is refused with `422`. - **Its status**: `active`, `paused` or `disabled`. An organization can have several endpoints, each with its own events and its own secret: one for your billing system and one for your data platform, for example. It keeps ten at most, disabled ones aside. ## The signing secret Creating an endpoint answers `201`, with the endpoint and its signing secret, `signing_secret`: a string that starts with `whsec_`. Only the create shows it, and a repeat of the same create (see below). No read returns it, so store it in your server's secret store before you do anything else. Your receiver [verifies each delivery](/docs/webhooks/verify) with it. The request that creates an endpoint must carry an `Idempotency-Key`, as [Errors and rate limits](/docs/errors#repeat-a-request-safely) describes, so a repeat after a timeout does not create a second one. A repeat with the same key and body, within 24 hours, answers the same endpoint as it now stands, with the same secret. ## The address | Rule | Means | | ------------------ | ---------------------------------------------------------------------------------- | | HTTPS, on port 443 | No plain HTTP, and no other port | | A public address | A host that resolves to a private, loopback or link-local address gets no delivery | | No redirects | A `3xx` answer is a failure, and is not followed | YOU(th) resolves the host each time it sends, so the rules hold for every delivery, not only when the endpoint is created. Creating one already refuses a host that can't be public: `localhost`, a name of one label such as `intranet`, or an IP address that is private, loopback or link-local. ## Status | `status` | Means | | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `active` | Deliveries are sent | | `paused` | YOU(th) stopped sending, because the address kept answering `404` or `410`: see [When an address is gone](/docs/webhooks/retries#when-an-address-is-gone) | | `disabled` | You stopped it | A paused or disabled endpoint gets no new deliveries. Read what it missed from the API: [access codes](/docs/access-codes/reconcile#catch-up-after-an-outage) and [checkups](/docs/webhooks/catch-up). ## Move to a new address Create an endpoint for the new address, give your new receiver its secret, check that deliveries arrive, then disable the old endpoint. While both are active, each event comes to both: your receivers skip an `event_id` they have [already handled](/docs/webhooks/retries#take-each-event-once). # Verify a delivery > Check each delivery's signature, in Node or Python. Anyone can send a request to your receiver's address. A delivery from YOU(th) carries a signature only someone with your signing secret could make; check it before you act on a delivery. Deliveries are signed as [Standard Webhooks](https://www.standardwebhooks.com/) describes, so its [libraries](https://github.com/standard-webhooks/standard-webhooks/tree/main/libraries), in C#, Elixir, Go, Java, JavaScript, PHP, Python, Ruby and Rust, verify them with your secret as it is. The samples below do the same in a few lines. ## How a delivery is signed - Your signing secret is a string that starts with `whsec_`, followed by base64. YOU(th) shows it once, in the answer that [creates your endpoint](/docs/webhooks/endpoints#the-signing-secret). - The key is the bytes that base64 decodes to, after `whsec_`: not the text of the secret. - The signed message is the `webhook-id` header, a dot, the `webhook-timestamp` header, a dot, and the raw body exactly as it arrived: `..`. No other header is signed, `youth-event-type` and `youth-delivery-attempt` among them. - The signature is the HMAC-SHA256 of that message, in base64, after `v1,`. - `webhook-signature` can hold more than one signature, separated by spaces, as Standard Webhooks allows: accept the delivery when any one of them verifies. ## Verify it Compute the signature over the raw body, before any JSON parsing, and compare it in constant time. Refuse a delivery whose `webhook-timestamp` is more than 300 seconds from your clock, so a recorded request cannot be played again later. ```typescript import { createHmac, timingSafeEqual } from "node:crypto"; /** Whether a delivery was signed with your secret within the last five minutes. */ export function verifyDelivery( secret: string, headers: Record, rawBody: Buffer, now = Math.floor(Date.now() / 1000), ): boolean { // Node gives header names in lowercase. const header = (name: string) => { const value = headers[name]; return typeof value === "string" ? value : ""; }; const timestamp = header("webhook-timestamp"); if (!/^\d+$/.test(timestamp) || Math.abs(now - Number(timestamp)) > 300) return false; const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64"); const expected = createHmac("sha256", key) .update(Buffer.concat([Buffer.from(`${header("webhook-id")}.${timestamp}.`), rawBody])) .digest(); return header("webhook-signature") .split(" ") .some((entry) => { const at = entry.indexOf(","); if (at < 0 || entry.slice(0, at) !== "v1") return false; const supplied = Buffer.from(entry.slice(at + 1), "base64"); return supplied.length === expected.length && timingSafeEqual(supplied, expected); }); } ``` ```python import base64 import hashlib import hmac import time from collections.abc import Mapping from typing import Optional def verify_delivery( secret: str, headers: Mapping[str, str], raw_body: bytes, now: Optional[int] = None, ) -> bool: """Whether a delivery was signed with your secret within the last five minutes.""" timestamp = headers.get("webhook-timestamp", "") if not (timestamp.isascii() and timestamp.isdigit()): return False if abs((int(time.time()) if now is None else now) - int(timestamp)) > 300: return False key = base64.b64decode(secret.removeprefix("whsec_")) signed = f"{headers.get('webhook-id', '')}.{timestamp}.".encode() + raw_body expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()) return any( version == "v1" and hmac.compare_digest(value.encode(), expected) for version, _, value in ( entry.partition(",") for entry in headers.get("webhook-signature", "").split(" ") ) ) ``` Pass the headers as your framework gives them: Flask, Django and FastAPI all look header names up whatever their case. Answer `401` to a delivery that fails, and do nothing else with it. That answer is not retried. ## Try it This request was signed with the fixture secret `whsec_Zm9vYmFyYmF6cXV4LWV4YW1wbGUtc2VjcmV0LXZhbHVl`. Your check should accept it when your clock is set to its `webhook-timestamp`, and refuse it when one byte of the body changes. ```http POST /youth-webhook HTTP/1.1 Host: partner.example.com Content-Type: application/json webhook-id: evt_e560fc965cf89b3d5a8c3ed27406806f webhook-timestamp: 1790847002 webhook-signature: v1,f/69pGXkwyZXFdzr/vJ44kTIC3ThgR+du6f4olitEV0= youth-event-type: Checkup.completed youth-delivery-attempt: 1 {"checkup_id":"64d866f3-0c88-485c-bfe6-3339df1d224a","event_id":"evt_e560fc965cf89b3d5a8c3ed27406806f","event_type":"Checkup.completed","occurred_at":"2026-10-01T09:30:00.375000Z","patient_id":"cfefb422-ac79-4cb9-a849-e80f8a6f21cd","resource_url":"https://api.youth-platform.io/v1/checkups/64d866f3-0c88-485c-bfe6-3339df1d224a/fhir"} ``` ## Read the raw body Most web frameworks parse JSON before your code runs. Parsed and written again, the body is no longer the bytes YOU(th) signed, and the signature never matches. Read the body as raw bytes on your webhook route, verify it, then parse it. # Retries and duplicates > Answer fast, take each event once, and know when YOU(th) tries again. YOU(th) delivers every event at least once. A delivery your receiver does not take comes again, and one it took can come again too, after a network error. Build your receiver for both. ## Answer fast A delivery counts as taken when your receiver answers any `2xx` within ten seconds. 1. [Verify the signature](/docs/webhooks/verify). 2. If you have seen its `event_id` before, answer `200` and stop. 3. Store the event, answer `200`, and do the work afterwards, outside the request. Answering fast matters more than finishing the work: a receiver that reads the checkup before it answers can run past ten seconds, and then the same event comes again. ## When YOU(th) tries again | Answer | Retried | | ---------------------------------------------- | ------- | | A timeout, a network error, `429` or any `5xx` | Yes | | Any other `4xx`, or any `3xx` | No | Answer `4xx` only when a delivery can never be taken, such as one whose signature fails. YOU(th) makes up to eight attempts, numbered in the `youth-delivery-attempt` header. The waits between them double from about one minute: about 1, 2, 4, 8, 16, 32 and 64 minutes, each varied by up to 20%, about two hours in all. After the eighth attempt, YOU(th) stops trying that event. The API lists what you missed: [access codes](/docs/access-codes/reconcile#catch-up-after-an-outage) and [checkups](/docs/webhooks/catch-up). ## When an address is gone An endpoint that answers `404` or `410` to ten different events in a row is paused: YOU(th) stops sending to it, and its [status](/docs/webhooks/endpoints#status) reads `paused`. Any `2xx` in between resets the count, and a `5xx`, a `429` or a timeout never pauses an endpoint: a receiver that is down comes back. To receive again, [create an endpoint](/docs/webhooks/endpoints#move-to-a-new-address) for an address that answers, disable the paused one, and read what you missed from the API. ## Take each event once An event's `event_id`, also in the `webhook-id` header, stays the same on every attempt. Keep the ids you have handled, for a few days at least, and skip one you have seen. While a new event type is sent beside the one it replaces, the same fact also comes under two `event_id`s: [Versions](/docs/versions) says how to take it once. ## Order Deliveries can arrive in any order: a retry of an older event can come after a newer one. Read the current state from the API rather than relying on the order events came in. ## Test your receiver Send your receiver the signed request on [Verify a delivery](/docs/webhooks/verify#try-it): it must accept it with the fixture secret and your clock set to its `webhook-timestamp`, and refuse it when one byte changes. For real deliveries, signed with your own secret, use your [sandbox](/docs/sandbox#a-whole-run): a tester who redeems a code there makes an `AccessCode.redeemed`. # Catch up after an outage > Read a checkup or a member with the read API, and list the checkups your system missed. > > Preview: proposed, may change. A webhook is a hint, not the record. Your backend reads the record from the read API: a checkup's bundle, a member as they are now, and the checkups you missed while your receiver was down. ## The read API Your backend calls it with an access token, as [Authentication](/docs/authentication) describes: tokens last about five minutes, and each request for one names the scopes it wants. | Route | Answers | Scope | | ------------------------------------------------ | ---------------------------------------------------------------------- | --------------- | | `GET /v1/checkups/{checkup_id}/fhir` | The checkup's FHIR `Bundle`: the same one every time | `checkups:read` | | `GET /v1/patients/{patient_id}/fhir` | The member's FHIR `Patient`, as it is now | `patients:read` | | `GET /v1/checkups?completed_from=&after=&limit=` | Your completed checkups, a page at a time, to catch up after an outage | `checkups:read` | These routes answer health data, so they have rules of their own: - **A Doctor gives the scopes.** Only one of your organization's Doctors can give an integration `checkups:read` or `patients:read`: see [Health data](/docs/credentials#health-data). - **Only with consent.** They answer the members who consented to share their data with your organization, and their checkups. - **Every read is logged**, before it is answered. A checkup or member that is not your organization's answers `404`, as if it did not exist. What the bundle and the `Patient` hold is on [FHIR](/docs/data/fhir). The list pages as every list does: pass a page's `next` as `after`. ## List what you missed Ask for the checkups completed since a little before the newest `occurred_at` you have, an hour before for example. Start early: an `occurred_at` can be a moment after the completion that `completed_from` filters on, and a checkup can join the list a moment after it completed. ```bash curl "https://api.youth-platform.io/v1/checkups?completed_from=2026-10-01T08:30:00Z" \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` Then read the bundle of each checkup you do not have yet. ## Skip what you already have A checkup you stored from a delivery, or from the last time you caught up, comes again in the list. Skip the checkup ids you already have, as you skip an `event_id` you have seen. ## Make it routine Run the same list on a schedule, every hour for example, from a little before the newest checkup you have. Then an event lost on the way, or a receiver that answered `200` but failed afterwards, costs a delay and never a checkup. # FHIR > A checkup as a FHIR bundle and a member as a Patient: the resources, codes and values. A checkup reaches you as a FHIR `Bundle`, and a member as a FHIR `Patient`. This page describes those resources, which is the format YOU(th) sends today. Both are health data, shared only for members who consented to share their data with your organization. > **Preview:** reading them from the [read API](/docs/webhooks/catch-up#the-read-api), at > `GET /v1/checkups/{checkup_id}/fhir` and `GET /v1/patients/{patient_id}/fhir`, is not available > yet. The routes are proposed and may change; the resources' format is not. Resources are FHIR R4, checked against the R4B structures. YOU(th) never sends or answers a resource that fails that check. Passing it does not certify a resource against any profile or for clinical use. ## A checkup: `Bundle` A `Bundle` of type `collection`, with a `timestamp`. The bundle only packs the resources together: its own `id` does not name the checkup. | Resource | One for | Holds | | ------------------ | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `Patient` | The member | `id`, an `identifier`, `active`, and `birthDate` and `gender` where known | | `DiagnosticReport` | The checkup | `id` and `identifier`: the checkup's id. `status` `final`. `category`: the checkup type. `code.text`: the checkup's name. `effectiveDateTime`: when the member took it. `issued`: when it was completed, the webhook's `occurred_at` or a moment before. `result`: its Observations | | `Observation` | Each measurement | The biomarker's code, its value, and `effectiveDateTime`: when it was measured | - Every entry has a `fullUrl` of the form `urn:uuid:`, stable for that resource. References between resources use it, so they resolve inside the bundle. Resource `id`s are YOU(th)'s ids. - A measurement's `code` is the biomarker's code, such as `heart_rate`, in YOU(th)'s biomarker code system; [Biomarkers](/docs/data/biomarkers) lists them. Codes are open: new biomarkers can appear at any time; keep a code you do not know. - A number is a `valueQuantity`: the unit as text, plus `system` `http://unitsofmeasure.org` and the `code` in UCUM, the Unified Code for Units of Measure, where the unit has one (`bpm` is `/min`, `mmHg` is `mm[Hg]`). - A category, such as a risk level `low`, is a `valueCodeableConcept`, coded in a YOU(th) code system. A category is a classification, never a diagnosis. - Blood pressure is one Observation: code LOINC `85354-9` beside YOU(th)'s `blood_pressure`, with two components, systolic LOINC `8480-6` and diastolic LOINC `8462-4`. When only one side was measured, both components are still there, and the missing one has a `dataAbsentReason` of `unknown` (system `http://terminology.hl7.org/CodeSystem/data-absent-reason`) instead of a value. In this example, shortened, the blood pressure was measured on one side only: ```json { "resourceType": "Bundle", "id": "90970514-fbcb-4c07-aee3-3778f4dc594a", "type": "collection", "timestamp": "2026-10-01T09:30:00Z", "entry": [ { "fullUrl": "urn:uuid:797790be-4a7b-4aeb-a554-e2685ee57942", "resource": { "resourceType": "Patient", "id": "cfefb422-ac79-4cb9-a849-e80f8a6f21cd", "identifier": [ { "system": "https://api.youth-platform.io/fhir/identifiers/patients", "value": "cfefb422-ac79-4cb9-a849-e80f8a6f21cd" } ], "active": true, "birthDate": "1988-04-12", "gender": "female" } }, { "fullUrl": "urn:uuid:3bc83773-8e40-465d-b194-5b52c797f59d", "resource": { "resourceType": "DiagnosticReport", "id": "64d866f3-0c88-485c-bfe6-3339df1d224a", "identifier": [ { "system": "https://api.youth-platform.io/fhir/identifiers/checkups", "value": "64d866f3-0c88-485c-bfe6-3339df1d224a" } ], "status": "final", "category": [ { "coding": [ { "system": "https://api.youth-platform.io/fhir/codes/checkup-type", "code": "digital", "display": "Digital checkup" } ] } ], "code": { "text": "Digital checkup" }, "subject": { "reference": "urn:uuid:797790be-4a7b-4aeb-a554-e2685ee57942" }, "effectiveDateTime": "2026-10-01T09:28:00Z", "issued": "2026-10-01T09:30:00Z", "result": [ { "reference": "urn:uuid:c47f1291-702c-42a1-a0f6-bbf4cb4eee15" }, { "reference": "urn:uuid:d0851610-7047-40c5-a486-a80dacdbe56c" }, { "reference": "urn:uuid:960272da-d72c-413b-92ff-83acdf46709e" } ] } }, { "fullUrl": "urn:uuid:c47f1291-702c-42a1-a0f6-bbf4cb4eee15", "resource": { "resourceType": "Observation", "id": "119d03ca-128d-4a26-8924-fa76fa92fbfe", "status": "final", "code": { "coding": [ { "system": "https://api.youth-platform.io/fhir/codes/biomarkers", "code": "heart_rate" } ] }, "subject": { "reference": "urn:uuid:797790be-4a7b-4aeb-a554-e2685ee57942" }, "effectiveDateTime": "2026-10-01T09:24:00Z", "valueQuantity": { "value": 64, "unit": "bpm", "system": "http://unitsofmeasure.org", "code": "/min" } } }, { "fullUrl": "urn:uuid:d0851610-7047-40c5-a486-a80dacdbe56c", "resource": { "resourceType": "Observation", "id": "c3a1f0d2-8e4b-5b7a-9f61-2d0e7c5b4a38", "status": "final", "code": { "coding": [ { "system": "https://api.youth-platform.io/fhir/codes/biomarkers", "code": "blood_pressure" }, { "system": "http://loinc.org", "code": "85354-9" } ] }, "subject": { "reference": "urn:uuid:797790be-4a7b-4aeb-a554-e2685ee57942" }, "effectiveDateTime": "2026-10-01T09:26:00Z", "component": [ { "code": { "coding": [{ "system": "http://loinc.org", "code": "8480-6" }] }, "valueQuantity": { "value": 122, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]" } }, { "code": { "coding": [{ "system": "http://loinc.org", "code": "8462-4" }] }, "dataAbsentReason": { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/data-absent-reason", "code": "unknown" } ] } } ] } }, { "fullUrl": "urn:uuid:960272da-d72c-413b-92ff-83acdf46709e", "resource": { "resourceType": "Observation", "id": "cd127997-4727-4795-b34c-227ac825d3e0", "status": "final", "code": { "coding": [ { "system": "https://api.youth-platform.io/fhir/codes/biomarkers", "code": "high_fasting_glucose_risk" } ] }, "subject": { "reference": "urn:uuid:797790be-4a7b-4aeb-a554-e2685ee57942" }, "effectiveDateTime": "2026-10-01T09:25:00Z", "valueCodeableConcept": { "coding": [ { "system": "https://api.youth-platform.io/fhir/codes/risk-level", "code": "low" } ], "text": "low" } } } ] } ``` ## A member: `Patient` A member on their own is the same `Patient` as in the bundle: `id`, `identifier`, `active`, and `birthDate` and `gender` where known. No name, and no extensions. ## Code and identifier systems Every code and identifier YOU(th) sends names the system it belongs to. A system is a name, not an address to call, and it never changes: store it with the code, and match on both. | System | Holds | | --------------------------------------------------------- | ----------------------------------------------------------------- | | `https://api.youth-platform.io/fhir/codes/biomarkers` | A measurement's code, such as `heart_rate` | | `https://api.youth-platform.io/fhir/codes/checkup-type` | The checkup type, in the `DiagnosticReport`'s `category` | | `https://api.youth-platform.io/fhir/codes/risk-level` | A risk level, such as `low`; each scale of categories has its own | | `https://api.youth-platform.io/fhir/identifiers/patients` | The member's id, in the `Patient`'s `identifier` | | `https://api.youth-platform.io/fhir/identifiers/checkups` | The checkup's id, in the `DiagnosticReport`'s `identifier` | New codes join a system; a code never changes its meaning. Blood pressure is the one measurement that carries a LOINC code beside YOU(th)'s own. A coding added later never breaks a receiver that ignores codings it does not know. # Biomarkers > Every biomarker code YOU(th) sends, and the channels that send it. The biomarkers are grouped by what they are about. A checkup completed in the Health Hub app carries the ones it measured, each as an [Observation](/docs/data/fhir#a-checkup-bundle); a checkup completed at a kiosk does too, with the differences below. The SDKs hand theirs to your app as [results](/docs/sdks/results), in the units that page names. - **Code**: the biomarker's code in YOU(th)'s biomarker code system. Codes are open: new ones can appear at any time; keep one you do not know rather than refusing the checkup. - **Deprecated**: a code a channel still sends that another code replaces. Keep reading it from the channels it names until they send the new code. - **Formerly**: a code the biomarker was sent under before. - **Value**: a number in its unit, as a `valueQuantity`, or a category, as a `valueCodeableConcept`. A category is a classification, never a diagnosis. The list names each category's values as YOU(th)'s catalog has them; keep a value you do not know. For now the kiosk sends a category as a `valueString`, and codes blood pressure's two sides `systolic` and `diastolic` in its own code system, without LOINC. - **UCUM**: the unit's code in [UCUM](https://ucum.org), the Unified Code for Units of Measure that FHIR uses, sent beside the unit's text. Read the unit from this code, not from the text, which is for people: `bpm` is `/min`. Tap or point at a unit in the list to see its code, or that it has none: that unit is sent as text only. A category has no unit. The kiosk sends the unit's text only for now. - **Checkups**: the checkup types that can measure it. - **Sent by**: the channels that send it: the Health Hub, the kiosk, the Flutter SDK and the Web SDK. Every channel sends a biomarker under its code, but for older names two channels keep for now, which the biomarker names: the Health Hub's webhook until it moves to the [API's webhooks](/docs/webhooks), in preview, which send the codes, and the Flutter SDK's `type` until its 1.0, beside its `code`, which is the biomarker's code. Such as `hrv_rri` for `hrv_mean_rri`. ## Activity | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `daily_steps` | **Daily steps**: Steps reported in a provider daily activity summary | steps | `{steps}` | wearable | Health Hub | | `workout_days_7d` | **Workout days (7 days)**: Days with at least one recorded workout in the past 7 days | days | `d` | wearable | Health Hub | ## Advanced glycation | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `advanced_glycation_endproducts` | **A.G.E. (advanced glycation endproducts)**: Compounds formed when sugars bind to proteins or lipids; they build up with high blood sugar and with age | AU | `[arb'U]` | lab | Health Hub | ## Aging | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `daily_bio_age_acceleration` | **Daily bio age acceleration**: Daily difference between the daily biological age and the chronological age | years | `a` | digital | Health Hub | | `resilience` | **Resilience**: Recovery time from stressful events | weeks | `wk` | digital | Health Hub | ## Blood | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `basophil_count` | **Basophil count**: Absolute number of basophils involved in allergic responses | 10⁹/L | `10*9/L` | lab | Health Hub | | `basophils_differential_count` | **Basophils %**: Percent of white cells that are basophils | % | `%` | lab | Health Hub | | `eosinophil_count` | **Eosinophil count**: Absolute number of eosinophils tied to allergy and parasite defense | 10⁹/L | `10*9/L` | lab | Health Hub | | `eosinophil_differential_count` | **Eosinophils %**: Percent of white cells that are eosinophils | % | `%` | lab | Health Hub | | `hematocrit` | **Hematocrit (HCT)**: Percentage of the blood made up of red blood cells | % | `%` | lab | Health Hub | | `hemoglobin` | **Hemoglobin**: Distributes oxygen to muscles and tissues | g/dL | `g/dL` | digital, lab | Health Hub, Kiosk, Flutter SDK | | `hemoglobin_index` | **Hemoglobin index**: Estimates whether hemoglobin is in a healthy range | category: very_low, low, normal, high | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `low_hemoglobin_risk` | **Low hemoglobin risk**: An index for patterns associated with low hemoglobin | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `lymphocyte_count` | **Lymphocyte count**: Absolute number of lymphocytes that support adaptive immunity | 10⁹/L | `10*9/L` | lab | Health Hub | | `lymphocytes_differential_count` | **Lymphocytes %**: Percent of white cells that are lymphocytes | % | `%` | lab | Health Hub | | `monocyte_count` | **Monocyte count**: Absolute number of monocytes that mature into tissue macrophages | 10⁹/L | `10*9/L` | lab | Health Hub | | `monocytes_differential_count` | **Monocytes %**: Percent of white cells that are monocytes | % | `%` | lab | Health Hub | | `neutrophil_count` | **Neutrophil count**: Absolute number of neutrophils that fight bacterial infections | 10⁹/L | `10*9/L` | lab | Health Hub | | `neutrophil_differential_count` | **Neutrophils %**: Percent of white cells that are neutrophils | % | `%` | lab | Health Hub | | `platelet_count` | **Platelet count**: Number of platelets, which help the blood clot | 10⁹/L | `10*9/L` | lab | Health Hub | | `red_cell_count` | **Red cell count**: Number of red blood cells in circulation | 10¹²/L | `10*12/L` | lab | Health Hub | | `white_cell_count` | **White cell count**: Total number of white blood cells, which support the immune system | 10⁹/L | `10*9/L` | lab | Health Hub | ## Body composition | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `body_appendicular_lean_mass_percentage` | **Appendicular lean mass (ALM) %**: Estimates the percentage of lean mass in the arms and legs | % | `%` | digital | Health Hub as `appendicular_lean_mass_percentage`, Flutter SDK, Web SDK | | `body_composition_total_body_water_percentage` | **Total body water**: Total-body-water percentage reported by a compatible wearable provider | % | `%` | wearable | Health Hub | | `body_fat_percentage` | **Body fat percentage**: Estimates the percentage of the body weight that is fat | % | `%` | digital, wearable | Health Hub as `body_composition_body_fat_percentage`, Flutter SDK, Web SDK | | `body_mass_index` | **BMI**: Body mass index (BMI): weight relative to height | kg/m² | `kg/m2` | digital, wearable | Health Hub as `body_composition_body_mass_index`, Flutter SDK, Web SDK | | `body_metabolic_age` | **Metabolic age, years**: A reflection of how "young" or "old" the metabolism is compared to the chronological age | years | `a` | digital | Health Hub as `metabolic_age_years`, Flutter SDK, Web SDK | | `body_skeletal_muscle_mass_percentage` | **Skeletal muscle mass (SMM) %**: Estimates the percentage of the body weight made up of skeletal muscle | % | `%` | digital | Health Hub as `skeletal_muscle_mass_percentage`, Flutter SDK, Web SDK | | `body_vat_percentage` | **Visceral adipose tissue (VAT) %**: Estimates the percentage of visceral fat surrounding the internal organs | % | `%` | digital | Health Hub as `vat_percentage`, Flutter SDK, Web SDK | ## Body composition (bioimpedance) | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `appendicular_skeletal_muscle_mass` | **Appendicular skeletal muscle mass**: Muscle mass in limbs (arms + legs), sarcopenia screening indicator | kg | `kg` | lab | Health Hub | | `basal_metabolic_rate` | **Basal metabolic rate (BMR)**: Calories burned at rest | kcal/day | `kcal/d` | lab | Health Hub | | `bia_body_fat_percentage` | **Body fat percentage**: Fat mass relative to total body weight | % | `%` | lab | Health Hub as `body_fat_percentage` | | `bia_body_mass_index` | **Body mass index (BMI)**: Weight-to-height ratio, a basic proxy for adiposity | kg/m² | `kg/m2` | lab | Health Hub as `body_mass_index` | | `lean_body_mass` | **Lean body mass %**: Non-fat tissue as share of total body weight | % | `%` | lab | Health Hub | | `total_body_water` | **Total body water (%)**: Hydration status relative to total body mass | % | `%` | lab | Health Hub | | `visceral_fat_index` | **Visceral fat index**: Fat surrounding internal organs, key metabolic risk marker | UI (units) | none | lab | Health Hub | ## Body skin | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `body_skin_abnormal_index` | **Abnormal skin index**: Assesses the presence of visible skin anomalies requiring attention | category: low, high | — | digital | Health Hub as `abnormal_skin_index`, Kiosk | | `body_skin_acne_index` | **Acne index**: Signs of acne-prone areas or inflammatory lesions | category: low, high | — | digital | Health Hub as `acne_index`, Kiosk | | `body_skin_benign_nevus_index` | **Benign nevus index**: An index from a skin photo for patterns associated with benign moles | category: low, high | — | digital | Health Hub as `benign_nevus_index`, Kiosk | | `body_skin_dermatitis_index` | **Dermatitis index**: Signs of general skin irritation or inflammation, possibly due to contact allergens or irritants | category: low, high | — | digital | Health Hub as `dermatitis_index`, Kiosk | | `body_skin_eczema_index` | **Eczema index**: Indications of eczema-related skin inflammation, dryness, or irritation | category: low, high | — | digital | Health Hub as `eczema_index`, Kiosk | | `body_skin_fungal_infection_index` | **Fungal infections index**: Probability of fungal-related skin infections like ringworm or candidiasis | category: low, high | — | digital | Health Hub as `fungal_infection_index`, Kiosk | | `body_skin_herpesvirus_index` | **Herpesvirus index**: Probability of skin manifestations linked to herpes viruses (e.g., HSV or shingles) | category: low, high | — | digital | Health Hub as `herpesvirus_index`, Kiosk | | `body_skin_no_pathologies_index` | **No pathologies index**: An index from a skin photo for whether no skin condition is visible | category: low, high | — | digital | Health Hub as `no_pathologies_index`, Kiosk | | `body_skin_papulosquamous_index` | **Papulosquamous index**: Likelihood of scaly skin conditions such as psoriasis or lichen planus | category: low, high | — | digital | Health Hub as `papulosquamous_index`, Kiosk | | `body_skin_pre_abnormal_index` | **Pre-abnormal skin index**: Early signs of skin irregularities that may evolve into relevant skin issues | category: low, high | — | digital | Health Hub as `pre_abnormal_skin_index`, Kiosk | | `body_skin_viral_index` | **Viral index**: Risk of viral skin conditions including warts or molluscum contagiosum | category: low, high | — | digital | Health Hub as `viral_index`, Kiosk | ## Cardiovascular | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `apolipoprotein_a` | **Apo A**: Major protein component of HDL particles | g/L | `g/L` | lab | Health Hub | | `apolipoprotein_b` | **Apo B**: Primary protein on atherogenic particles like LDL and VLDL | g/L | `g/L` | lab | Health Hub | | `ascvd_risk` | **ASCVD risk**: Estimated atherosclerotic cardiovascular disease risk | % | `%` | digital | Health Hub, Flutter SDK, Web SDK | | `ascvd_risk_level` | **ASCVD risk level**: Estimated atherosclerotic cardiovascular disease risk, as a level | category: low, medium, high | — | digital | Flutter SDK, Web SDK | | `blood_pressure` | **Blood pressure**: Systolic and diastolic, as two components: systolic LOINC `8480-6` and diastolic LOINC `8462-4`, under LOINC `85354-9` | mmHg, two components | `mm[Hg]` | digital, wearable | Health Hub, Kiosk, Web SDK | | `blood_pressure_diastolic` (deprecated, replaced by `blood_pressure`) | **Diastolic blood pressure**: The pressure in the arteries between heartbeats | mmHg | `mm[Hg]` | digital | Flutter SDK | | `blood_pressure_systolic` (deprecated, replaced by `blood_pressure`) | **Systolic blood pressure**: The pressure in the arteries while the heart beats | mmHg | `mm[Hg]` | digital | Flutter SDK | | `cardiac_workload` | **Cardiac workload**: How hard the heart works to pump blood | mmHg/s | `mm[Hg]/s` | digital | Kiosk, Flutter SDK, Web SDK | | `cardiorespiratory_wellness` | **Cardiorespiratory wellness**: An indication of cardiovascular wellness over the next 5 to 10 years | number, no unit | none | digital | Health Hub, Kiosk, Flutter SDK as `wellness_index`, Web SDK | | `cardiorespiratory_wellness_level` | **Wellness level**: Cardiorespiratory wellness as a level | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK as `wellness_level`, Web SDK | | `hdl_cholesterol` | **HDL cholesterol**: High-density lipoprotein that helps clear cholesterol from the bloodstream | mmol/L | `mmol/L` | lab | Health Hub | | `heart_age` | **Heart age**: Estimated age of the cardiovascular system | years | `a` | digital | Health Hub, Flutter SDK, Web SDK | | `heart_rate` | **Resting heart rate**: Number of heartbeats per minute | bpm | `/min` | digital, wearable | Health Hub, Kiosk, Flutter SDK, Web SDK | | `heart_rate_recovery_1m` | **1-minute heart rate recovery**: How far the heart rate falls in the first minute after exercise | bpm | `/min` | wearable | Health Hub | | `high_total_cholesterol_risk` | **High total cholesterol index**: Proxy for the body's cholesterol balance | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `hrv_lf_hf` | **LF/HF**: Ratio of low- to high-frequency heart rate variability | number, no unit | none | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `hrv_mean_rri` | **Average heartbeats interval**: The average time between two heartbeats | ms | `ms` | digital | Health Hub as `hrv_rri`, Kiosk, Flutter SDK as `hrv_rri`, Web SDK | | `hrv_rmssd` | **Instant heart rate variability (RMSSD)**: How much the time between consecutive heartbeats changes from one beat to the next | ms | `ms` | digital, wearable, lab | Health Hub, Kiosk, Flutter SDK, Web SDK | | `hrv_sd1` | **SD1**: Short-term heart rate variability | ms | `ms` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `hrv_sd2` | **SD2**: Long-term heart rate variability | ms | `ms` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `hrv_sdnn` | **Total heart rate variability (SDNN)**: How much the time between heartbeats varies overall during the full checkup | ms | `ms` | digital, wearable, lab | Health Hub, Kiosk, Flutter SDK, Web SDK | | `hypertension_risk` | **Hypertension index**: An index for patterns associated with hypertension | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `ldl_cholesterol` | **LDL cholesterol**: Low-density lipoprotein that delivers cholesterol to tissues | mmol/L | `mmol/L` | lab | Health Hub | | `mean_arterial_pressure` | **Mean arterial pressure**: The average pressure in the arteries over one heartbeat | mmHg | `mm[Hg]` | digital | Kiosk, Flutter SDK, Web SDK | | `pulse_pressure` | **Pulse pressure**: The difference between systolic and diastolic blood pressure | mmHg | `mm[Hg]` | digital | Kiosk, Flutter SDK, Web SDK | | `stress_level` | **Heart stress index**: The body's reaction to a challenge or demand | category: low, normal, mild, high, extreme | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `total_cholesterol` | **Total cholesterol**: Sum of cholesterol carried by LDL, HDL, and other lipoproteins | mmol/L | `mmol/L` | lab | Health Hub | | `triglycerides` | **Triglycerides**: Blood fats used for energy; high levels can raise cardiovascular risk | mmol/L | `mmol/L` | lab | Health Hub | ## Energy and stress | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `cortisol` | **Cortisol**: Stress hormone that helps regulate energy, blood pressure, and inflammation | nmol/L | `nmol/L` | lab | Health Hub | | `normalized_stress_index` | **Normalized stress index**: Stress index on a 0–100% scale | number, no unit | none | digital, wearable | Health Hub, Kiosk, Flutter SDK, Web SDK | | `parasympathetic_activity` | **Parasympathetic activity**: How active the rest-and-digest part of the nervous system is | % | `%` | digital | Kiosk, Web SDK | | `pns_index` | **Rest response (PNS)**: How strongly the body's "rest and digest" system is active | number, no unit | none | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `recovery_ability` | **Recovery ability**: Ability to recover and regulate bodily functions after stressful occurrences | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `sns_index` | **Alert response (SNS)**: How strongly the body's "fight or flight" system is active | number, no unit | none | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `stress_index` | **Stress index (Baevsky)**: How much stress the body is under right now | number, no unit | none | digital | Health Hub as `baevsky_stress_index`, Kiosk, Flutter SDK as `baevsky_stress_index`, Web SDK | | `stress_index_scaled` | **Stress index, from 0 to 10**: How much stress the body is under right now, on a scale from 0 to 10 | number, no unit | none | digital | Web SDK | | `stress_response` | **Stress response**: Physiological reaction to an imminent stressful event | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | ## Face skin | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `face_skin_acne_index` | **Acne index**: Presence and severity of visible breakouts, such as acne, pimples and other spots (Health Hub and kiosk from 18 December 2026; acne spots alone before) | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_eye_age` | **Eye age**: Visual age of the skin around both eyes | years | `a` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_eye_area_condition` | **Eye area condition**: Visual health of the skin under both eyes: in the Health Hub and kiosk from 18 December 2026, the mean of dark circles and puffiness (one blended measure before); in the SDKs' selfie, puffiness alone until the mean from 4 January 2027 (model version 2027.01) | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_hydration` | **Skin hydration**: Estimates visual signs of dehydrated skin on the face | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_perceived_age` | **Perceived age**: Visual age of the skin on the face | years | `a` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_pigmentation_index` | **Pigmentation index**: Estimates the size and severity of localized skin darkening caused by excess melanin | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_pores_health` | **Pores health**: Estimates how visible the pores are, enlarged pores weighing most (Health Hub and kiosk from 18 December 2026; their presence and density before) | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_redness` | **Skin redness**: Estimates the visible presence and intensity of increased skin redness or irritation spots | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_uniformness` | **Skin uniformness**: Estimates how even the skin's colour looks; patches and an uneven tone lower it (Health Hub and kiosk from 18 December 2026; its texture before) | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `face_skin_wrinkles_index` | **Lines index**: Presence and severity of wrinkles caused by the loss of natural moisture and elasticity of the skin | % | `%` | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | ## Fatty acids | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `arachidonic_acid_20_4_w6` | **Arachidonic acid (20:4, ω6)**: An omega-6 fatty acid used to make signaling molecules that drive inflammation and repair | %(rel. quant.) | `%` | lab | Health Hub | | `dihomo_gamma_linolenic_acid_dgla_20_3_w6` | **Dihomo-γ-linolenic acid (DGLA, 20:3, ω6)**: An omega-6 fat that can form anti-inflammatory series-1 prostaglandins | %(rel. quant.) | `%` | lab | Health Hub | | `docosahexaenoic_acid_dha_22_6_w3` | **Docosahexaenoic acid (DHA, 22:6, ω3)**: A brain- and retina-rich omega-3 fat important for cognition and vision | %(rel. quant.) | `%` | lab | Health Hub | | `eicosapentaenoic_acid_epa_20_5_w3` | **Eicosapentaenoic acid (EPA, 20:5, ω3)**: A marine omega-3 fatty acid with anti-inflammatory and heart-protective effects | %(rel. quant.) | `%` | lab | Health Hub | | `omega3_index_epa_plus_dha` | **Omega-3 index (EPA + DHA)**: Relative percent of EPA and DHA, a marker of omega-3 status | %(rel. quant.) | `%` | lab | Health Hub | | `omega6_to_omega3_ratio` | **Omega-6 / omega-3 ratio**: Balance between omega-6 and omega-3 fats, an indicator of inflammatory tone | %(rel. quant.) | none | lab | Health Hub | | `palmitoleic_acid_16_1` | **Palmitoleic acid (16:1)**: An omega-7 monounsaturated fat; higher levels may reflect liver fat production | %(rel. quant.) | `%` | lab | Health Hub | | `peroxidation_index_pi` | **Peroxidation index (PI)**: How susceptible the fatty-acid pool is to oxidative damage | %(rel. quant.) | `%` | lab | Health Hub | | `sfa_to_mufa_ratio` | **SFA/MUFA ratio**: Membrane saturation: more SFA means stiffer membranes, more MUFA more fluid ones | %(rel. quant.) | none | lab | Health Hub | | `total_sfas` | **Total SFAs (saturated fatty acids)**: Combined share of saturated fats in blood lipids | %(rel. quant.) | `%` | lab | Health Hub | | `trans_18_1` | **Trans 18:1**: Trans-monounsaturated fatty acids, often a dietary marker of industrial trans fats | %(rel. quant.) | `%` | lab | Health Hub | | `trans_20_4` | **Trans 20:4**: Trans isomers of arachidonic-like fatty acids; generally undesirable | %(rel. quant.) | `%` | lab | Health Hub | | `unsaturation_index_ui` | **Unsaturation index (UI)**: Weighted count of double bonds across fatty acids; a higher UI means more fluid membranes | %(rel. quant.) | `%` | lab | Health Hub | ## Inflammation | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `c_reactive_protein` | **C-reactive protein (CRP)**: Protein made by the liver that rises with inflammation | mg/L | `mg/L` | lab | Health Hub | ## Mental | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `anxiety_index_mental` | **Psychological resilience index**: Capacity to recover from psychological stress and adversity | category: low, medium, high | — | digital | Health Hub, Kiosk | | `depression_index_mental` | **Psychological wellbeing index**: Emotional wellbeing, mood stability, and motivational drive | category: low, medium, high | — | digital | Health Hub, Kiosk | | `mental_fitness_score` | **Mental fitness score**: Cognitive performance, sustained attention, and mental endurance | number, no unit | none | digital | Health Hub, Kiosk | | `pause_duration` | **Pause duration**: Average duration of pauses between speech sounds | sec | `s` | digital | Health Hub, Kiosk, Flutter SDK as `voice_pause_mental_duration`, Web SDK | | `speech_rate` | **Speech rate**: Number of words spoken per minute | words/min | `{words}/min` | digital | Health Hub, Kiosk, Flutter SDK as `voice_speech_mental_rate`, Web SDK | | `voice_clarity` | **Voice clarity**: Range of sounds made while speaking by changing the shape of tongue, mouth and throat | kHz² | `kHz2` | digital | Health Hub, Kiosk, Flutter SDK as `voice_mental_clarity`, Web SDK | | `voice_control` | **Voice control**: Regularity of voice pitch amplitude | % | `%` | digital | Health Hub, Kiosk, Flutter SDK as `voice_mental_control`, Web SDK | | `voice_crispness` | **Voice crispness**: Average time of single speech sounds measured from beginning to end of vocal cord vibration | ms | `ms` | digital | Health Hub, Kiosk, Flutter SDK as `voice_mental_crispness`, Web SDK | | `voice_energy_range` | **Voice energy range**: Range of vocal intensity used while speaking | dB | `dB` | digital | Health Hub, Kiosk, Flutter SDK as `voice_mental_energy_range`, Web SDK | | `voice_liveliness` | **Voice liveliness**: Range of vocal pitch used while speaking | octaves | none | digital | Health Hub, Kiosk, Flutter SDK as `voice_mental_liveliness`, Web SDK | | `voice_smoothness` | **Voice smoothness**: Regularity of voice pitch periods | % | `%` | digital | Health Hub, Kiosk, Flutter SDK as `voice_mental_smoothness`, Web SDK | ## Metabolic | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `blood_glucose` | **Blood glucose**: Sugar level in the blood at the time of the test | mmol/L | `mmol/L` | lab | Health Hub | | `hba1c` | **HbA1c**: Glycated hemoglobin measured by a lab: average blood sugar in the last 3 months | % | `%` | lab | Health Hub | | `hba1c_estimate` | **Average glucose index**: The camera's estimate of HbA1c: a proxy for average blood sugar in the last 3 months | % | `%` | digital | Health Hub as `hba1c`, Kiosk, Flutter SDK, Web SDK | | `high_fasting_glucose_risk` | **High fasting glucose index**: Proxy for the body's glucose balance | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `high_hba1c_risk` | **Metabolic index**: Proxy for metabolic wellness, and an index for patterns associated with diabetes | category: low, medium, high | — | digital | Health Hub, Kiosk, Flutter SDK as `diabetes_risk`, Web SDK | ## Oxidative stress | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `plasma_antioxidant_capacity` (formerly `pat`) | **Plasma antioxidant capacity**: Overall antioxidant capacity of plasma, the body's ability to neutralize free radicals | μmol/L | `umol/L` | lab | Health Hub | | `reactive_oxygen_metabolites` (formerly `d_roms`) | **Reactive oxygen metabolites**: Circulating oxidants, an estimate of oxidative stress load | U-CARR | none | lab | Health Hub | ## Respiratory | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `breathing_rate` | **Breathing rate**: Number of breaths taken per minute | bpm | `/min` | digital, wearable | Health Hub, Kiosk, Flutter SDK, Web SDK | | `oxygen_saturation` | **Oxygen saturation index**: % of hemoglobin in the blood carrying oxygen | % | `%` | digital, wearable | Health Hub, Kiosk, Flutter SDK, Web SDK | | `pulse_respiration_quotient` | **Pulse respiratory quotient (PRQ)**: Captures the states of cardiorespiratory integrative activity | number, no unit | none | digital | Health Hub as `prq`, Kiosk, Flutter SDK as `prq`, Web SDK | | `respiratory_fitness` | **Respiratory fitness**: Proxy for respiratory wellness | number, no unit | none | digital | Health Hub | | `respiratory_symptoms_score` | **Respiratory symptoms score**: Reflects the vocal similarity to vocal characteristics observed in people with low respiratory wellness | number, no unit | none | digital | Health Hub, Kiosk, Flutter SDK, Web SDK | | `vo2_max` | **VO₂ max**: How efficiently the body uses oxygen during hard effort | mL/kg/min | `mL/kg/min` | wearable | Health Hub | ## Sleep | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `sleep_average_hrv` | **Sleep HRV**: Heart-rate variability reported during the main sleep session | ms | `ms` | wearable | Health Hub | | `sleep_breathing_rate` | **Sleep breathing rate**: Breathing rate reported during the main sleep session | bpm | `/min` | wearable | Health Hub | | `sleep_efficiency` | **Sleep efficiency**: Share of time in bed spent asleep during the main sleep session | ratio | `1` | wearable | Health Hub | | `sleep_latency` | **Sleep latency**: Time from going to bed until sleep begins | min | `min` | wearable | Health Hub | | `sleep_resting_heart_rate` | **Sleep resting heart rate**: Resting heart rate reported by the wearable for the main sleep session | bpm | `/min` | wearable | Health Hub | | `sleep_score` | **Sleep score**: Sleep quality score calculated by the wearable provider for the main sleep session | number, no unit | none | wearable | Health Hub | | `sleep_total_sleep_time` | **Total sleep time**: Total sleep time reported for the main sleep session | hours | `h` | wearable | Health Hub | ## Vitamins | Code | Measures | Value | UCUM | Checkups | Sent by | | --- | --- | --- | --- | --- | --- | | `cobalamin` | **Vitamin B12**: Needed for red blood cells, nerves and DNA synthesis | pmol/L | `pmol/L` | lab | Health Hub | | `vitamin_d` | **Vitamin D (25-OH)**: Supports bone, muscle and immune health | nmol/L | `nmol/L` | lab | Health Hub | # YOU(th) API reference > Every route of the API: its scope, parameters, request body, answers, errors and samples, drawn from the API's OpenAPI description. This page is drawn from the API's [OpenAPI description](/openapi.json), which is generated from the API's own routes, so it says what the API does. Hand that file to your own tools to generate a client or import the routes. [Get API credentials](/docs/credentials) first, then [get a token](/docs/authentication#get-a-token) and send it with every request. A refused request answers a Problem document: [Errors and rate limits](/docs/errors) says how to read one and when to try again. The API partners' servers call, under `/v1`, with an OAuth access token their client credentials get. - Base URL: `https://api.youth-platform.io` - Token endpoint: `https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token` - Version: `1` ## Organization The organization an integration's credentials belong to, and the integration itself. ### The organization the credentials belong to, and the integration calling `GET /v1/organization` Needs no particular scope, but the token must be requested with at least one granted scope, which gives it the API's audience: a partner calls it to check new credentials. The organization is the credentials', never the request's. Any token of the API: no particular scope. #### Responses **200** The organization and the integration. `application/json`: [CurrentOrganization](/docs/api#schema-CurrentOrganization). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`. Example: `identity_unavailable`. | #### Request samples ```bash curl https://api.youth-platform.io/v1/organization \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/organization", { headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.get( "https://api.youth-platform.io/v1/organization", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "organization": { "alias": "example-clinic", "name": "Example Clinic" }, "integration": { "id": "3f2b8c1e-9a47-4d65-b0e2-7c1a5d9e4f08", "name": "Billing", "scopes": [ "access_codes:read" ] } } ``` ## Access codes Batches of access codes your organization orders, and the codes in them: each gives one person access to YOU(th), and names no one. ### Order a batch of access codes `POST /v1/access-code-batches` Makes `count` codes for your organization and answers `201` once every one can be read and redeemed. When that can't be finished now, it answers `503` with `Retry-After`: send the same order again, with the same `Idempotency-Key` and body, and it goes on with the same batch, never a second one. Your organization's batches ordered in one day, from 00:00 UTC, hold at most its daily limit of codes together: 1,000 unless YOU(th) raised it, on request. A repeat that goes on with a batch isn't counted again. Requires an `Idempotency-Key`. Needs `access_codes:write`. Scope: [`access_codes:write`](/docs/api#scope-access_codes:write) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `idempotency-key` | header | string | yes | A key of yours for the request, such as a UUID, at most 255 characters. The same key and body answer the first request again, and resume it after a `503`, for 24 hours after the latest attempt. Example: `5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11`. | #### Request body `application/json`: [AccessCodeBatchOrder](/docs/api#schema-AccessCodeBatchOrder). #### Responses **201** The batch, `ready`, at the address in `Location`. `application/json`: [AccessCodeBatch](/docs/api#schema-AccessCodeBatch). | Header | Type | Required | Description | | --- | --- | --- | --- | | `location` | string | yes | Where the batch is read. Example: `/v1/access-code-batches/0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21`. | **400** The body can't be parsed (`malformed_request`), the order has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`malformed_request`](/docs/api#error-malformed_request), [`idempotency_key_required`](/docs/api#error-idempotency_key_required), [`idempotency_key_invalid`](/docs/api#error-idempotency_key_invalid). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `malformed_request`, `idempotency_key_required`, `idempotency_key_invalid`. Example: `malformed_request`. | **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **409** The key was used with another body (`idempotency_conflict`): use a new key. An order with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization isn't in the app yet, so no code could be redeemed (`app_not_set_up`): ask YOU(th). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`idempotency_conflict`](/docs/api#error-idempotency_conflict), [`idempotency_in_progress`](/docs/api#error-idempotency_in_progress), [`app_not_set_up`](/docs/api#error-app_not_set_up). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `idempotency_conflict`, `idempotency_in_progress`, `app_not_set_up`. Example: `idempotency_conflict`. | **413** The body is over the API's limit (`too_large`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`too_large`](/docs/api#error-too_large). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `too_large`. Example: `too_large`. | **415** The body isn't JSON (`unsupported_media_type`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`unsupported_media_type`](/docs/api#error-unsupported_media_type). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `unsupported_media_type`. Example: `unsupported_media_type`. | **422** A field is missing, not valid or not one the order takes (`invalid_request`), `redeem_by` has passed (`redeem_by_passed`) or is more than five years ahead (`redeem_by_too_far`), or the order would take your organization past its daily limit (`count_over_limit`): nothing was made. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request), [`redeem_by_passed`](/docs/api#error-redeem_by_passed), [`redeem_by_too_far`](/docs/api#error-redeem_by_too_far), [`count_over_limit`](/docs/api#error-count_over_limit). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_request`, `redeem_by_passed`, `redeem_by_too_far`, `count_over_limit`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out), [`temporarily_unavailable`](/docs/api#error-temporarily_unavailable). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`, `temporarily_unavailable`. Example: `identity_unavailable`. | #### Request samples ```bash curl --request POST https://api.youth-platform.io/v1/access-code-batches \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \ --header "idempotency-key: 5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11" \ --header "Content-Type: application/json" \ --data '{ "count": 1000, "label": "december-2026", "redeem_by": "2027-12-31T23:59:59Z", "access": { "term": "until_ended" } }' ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/access-code-batches", { method: "POST", headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, "Content-Type": "application/json", "idempotency-key": "5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11", }, body: JSON.stringify({ "count": 1000, "label": "december-2026", "redeem_by": "2027-12-31T23:59:59Z", "access": { "term": "until_ended" } }), }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.post( "https://api.youth-platform.io/v1/access-code-batches", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", "idempotency-key": "5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11", }, json={ "count": 1000, "label": "december-2026", "redeem_by": "2027-12-31T23:59:59Z", "access": { "term": "until_ended", }, }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "label": "december-2026", "status": "ready", "count": 1000, "redeem_by": "2027-12-31T23:59:59.000Z", "access": { "term": "until_ended" }, "created_at": "2026-12-01T10:00:00.000Z" } ``` ### Read a batch of access codes `GET /v1/access-code-batches/{batch_id}` One of your organization's batches. Needs `access_codes:read` or `access_codes:write`. Scope: [`access_codes:read`](/docs/api#scope-access_codes:read) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `batch_id` | path | string | yes | The batch's id. Format: `uuid`. Example: `0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21`. | #### Responses **200** The batch. `application/json`: [AccessCodeBatch](/docs/api#schema-AccessCodeBatch). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **404** No batch of yours has this id (`not_found`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`not_found`](/docs/api#error-not_found). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `not_found`. Example: `not_found`. | **422** A field is missing or not valid (`invalid_request`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `invalid_request`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`. Example: `identity_unavailable`. | #### Request samples ```bash curl https://api.youth-platform.io/v1/access-code-batches/0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21 \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/access-code-batches/0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", { headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.get( "https://api.youth-platform.io/v1/access-code-batches/0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "label": "december-2026", "status": "ready", "count": 1000, "redeem_by": "2027-12-31T23:59:59.000Z", "access": { "term": "until_ended" }, "created_at": "2026-12-01T10:00:00.000Z" } ``` ### List access codes `GET /v1/access-codes` Your organization's codes of batches that are `ready`, that the filters keep, in a stable order. As JSON, a page at a time: pass a page's `next` as `after` for the next one. With `Accept: text/csv`, one CSV file of every code the filters keep, not paged, up to 50,000 codes. Needs `access_codes:read` or `access_codes:write`. Scope: [`access_codes:read`](/docs/api#scope-access_codes:read) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `batch_id` | query | string | no | The codes of one batch. Format: `uuid`. Example: `0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21`. | | `status` | query | string | no | The codes in one status. One of `available`, `redeemed`, `ended`, `deactivated`, `expired`. Example: `redeemed`. | | `redeemed_from` | query | string | no | The codes redeemed at or after this time. Format: `date-time`. Example: `2026-12-01T00:00:00Z`. | | `redeemed_to` | query | string | no | The codes redeemed before this time. Format: `date-time`. Example: `2027-01-01T00:00:00Z`. | | `ended_from` | query | string | no | The codes whose access ended at or after this time, and has ended by now: an end still ahead isn't kept. Format: `date-time`. Example: `2026-12-12T08:30:00Z`. | | `after` | query | string | no | The next page: the `next` of the page before. Not with `Accept: text/csv`. Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | | `limit` | query | integer | no | How many codes a page holds, at most 1,000; 100 unless set. Not with `Accept: text/csv`. At least `1`. At most `1000`. Example: `100`. | #### Responses **200** A page of codes, or every one as CSV. `application/json`: [AccessCodePage](/docs/api#schema-AccessCodePage). `text/csv`: string. A header line, then one line per code: `id`, `batch_id`, `code`, `redeem_url`, `status`, `redeemed_at`, `access_term`, `access_ends_at`, each empty for none. **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **422** A field is missing or not valid (`invalid_request`), or a CSV file would hold more than 50,000 codes (`too_many_codes`): filter by `batch_id` or a time range, or read pages as JSON. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request), [`too_many_codes`](/docs/api#error-too_many_codes). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_request`, `too_many_codes`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`. Example: `identity_unavailable`. | #### Request samples ```bash curl https://api.youth-platform.io/v1/access-codes \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/access-codes", { headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.get( "https://api.youth-platform.io/v1/access-codes", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "items": [ { "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "code": "482957362845", "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845", "status": "available", "redeemed_at": null, "access": { "term": "until_ended", "ends_at": null } } ], "next": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34" } ``` ### Read an access code `GET /v1/access-codes/{access_code_id}` One of your organization's codes, with its `redeem_url`: the address an event's `resource_url` names. Needs `access_codes:read` or `access_codes:write`. Scope: [`access_codes:read`](/docs/api#scope-access_codes:read) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `access_code_id` | path | string | yes | The code's id. Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | #### Responses **200** The code. `application/json`: [AccessCode](/docs/api#schema-AccessCode). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **404** No code of yours has this id (`not_found`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`not_found`](/docs/api#error-not_found). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `not_found`. Example: `not_found`. | **422** A field is missing or not valid (`invalid_request`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `invalid_request`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`. Example: `identity_unavailable`. | #### Request samples ```bash curl https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34 \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", { headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.get( "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "code": "482957362845", "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845", "status": "available", "redeemed_at": null, "access": { "term": "until_ended", "ends_at": null } } ``` ### Block an access code `POST /v1/access-codes/{access_code_id}/deactivate` Blocks one of your organization's codes nobody redeemed, which then can never be redeemed, and answers it `deactivated`. Blocking it again changes nothing. A redeemed code is refused: end its access instead. Needs `access_codes:write`. Scope: [`access_codes:write`](/docs/api#scope-access_codes:write) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `access_code_id` | path | string | yes | The code's id. Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | #### Responses **200** The code, `deactivated`. `application/json`: [AccessCode](/docs/api#schema-AccessCode). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **404** No code of yours has this id (`not_found`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`not_found`](/docs/api#error-not_found). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `not_found`. Example: `not_found`. | **409** Someone redeemed the code (`already_redeemed`): end its access instead. Someone is redeeming it this moment (`redemption_in_progress`, with `Retry-After`): send it again then. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`already_redeemed`](/docs/api#error-already_redeemed), [`redemption_in_progress`](/docs/api#error-redemption_in_progress). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `already_redeemed`, `redemption_in_progress`. Example: `already_redeemed`. | **422** A field is missing or not valid (`invalid_request`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `invalid_request`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out), [`temporarily_unavailable`](/docs/api#error-temporarily_unavailable). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`, `temporarily_unavailable`. Example: `identity_unavailable`. | #### Request samples ```bash curl --request POST https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/deactivate \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/deactivate", { method: "POST", headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.post( "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/deactivate", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "code": "482957362845", "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845", "status": "available", "redeemed_at": null, "access": { "term": "until_ended", "ends_at": null } } ``` ### End the access a code started `PUT /v1/access-codes/{access_code_id}/access` Sets when the access one of your organization's redeemed codes started ends, and answers the code. A time to come ends it then; one that has passed, or none sent, ends it now; `null` undoes an end that hasn't passed. The access stops in the YOU(th) app within about 10 minutes after its end, later when the app can't be reached then. The same call twice leaves the same end. An end that has passed is final: ending it again answers the code as it is. Needs `access_codes:write`. Scope: [`access_codes:write`](/docs/api#scope-access_codes:write) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `access_code_id` | path | string | yes | The code's id. Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | #### Request body `application/json`: [AccessEndChange](/docs/api#schema-AccessEndChange). #### Responses **200** The code, with the end set. `application/json`: [AccessCode](/docs/api#schema-AccessCode). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **404** No code of yours has this id (`not_found`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`not_found`](/docs/api#error-not_found). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `not_found`. Example: `not_found`. | **409** Nobody redeemed the code (`not_redeemed`): block it instead. Its access has ended, and the call asks for a later end or none (`access_ended`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`not_redeemed`](/docs/api#error-not_redeemed), [`access_ended`](/docs/api#error-access_ended). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `not_redeemed`, `access_ended`. Example: `not_redeemed`. | **413** The body is over the API's limit (`too_large`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`too_large`](/docs/api#error-too_large). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `too_large`. Example: `too_large`. | **415** The body isn't JSON (`unsupported_media_type`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`unsupported_media_type`](/docs/api#error-unsupported_media_type). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `unsupported_media_type`. Example: `unsupported_media_type`. | **422** A field is missing, not valid or not one the call takes (`invalid_request`), or the end is later than a `fixed_days` code's own term (`ends_at_beyond_term`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request), [`ends_at_beyond_term`](/docs/api#error-ends_at_beyond_term). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_request`, `ends_at_beyond_term`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out), [`temporarily_unavailable`](/docs/api#error-temporarily_unavailable). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`, `temporarily_unavailable`. Example: `identity_unavailable`. | #### Request samples ```bash curl --request PUT https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/access \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "ends_at": "2027-01-12T00:00:00Z" }' ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/access", { method: "PUT", headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, "Content-Type": "application/json", }, body: JSON.stringify({ "ends_at": "2027-01-12T00:00:00Z" }), }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.put( "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34/access", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, json={ "ends_at": "2027-01-12T00:00:00Z", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "code": "482957362845", "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845", "status": "available", "redeemed_at": null, "access": { "term": "until_ended", "ends_at": null } } ``` ## Webhooks Your organization's webhook endpoints: the HTTPS addresses YOU(th) sends signed events to, each with its own signing secret and the events it receives. ### List your webhook endpoints `GET /v1/webhook-endpoints` Your organization's endpoints, oldest first, a page at a time: pass a page's `next` as `after` for the next. An `after` that isn't one of your endpoints is refused with `422 invalid_request`. Needs `webhooks:write`: there is no read-only webhook scope. Scope: [`webhooks:write`](/docs/api#scope-webhooks:write) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `after` | query | string | no | The `next` of the page before; none for the first page. Format: `uuid`. Example: `0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90`. | | `limit` | query | integer | no | How many endpoints a page holds, at most 100. At least `1`. At most `100`. Default: `50`. Example: `50`. | #### Responses **200** A page of the endpoints. `application/json`: [WebhookEndpointPage](/docs/api#schema-WebhookEndpointPage). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **422** A field is missing or not valid (`invalid_request`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `invalid_request`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`. Example: `identity_unavailable`. | #### Request samples ```bash curl https://api.youth-platform.io/v1/webhook-endpoints \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/webhook-endpoints", { headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.get( "https://api.youth-platform.io/v1/webhook-endpoints", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "items": [ { "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", "url": "https://partner.example.com/youth-webhook", "description": "Billing", "event_types": [ "Access.ended", "AccessCode.redeemed" ], "status": "active", "created_at": "2026-11-20T09:30:00.000Z", "updated_at": "2026-11-20T09:30:00.000Z" } ], "next": null } ``` ### Create a webhook endpoint `POST /v1/webhook-endpoints` Creates an endpoint of your organization's and answers `201` with it and its signing secret, the only answer that carries the secret. Send the same create again, with the same `Idempotency-Key` and body, and it answers the same endpoint and secret, never a second endpoint. Requires an `Idempotency-Key`. Needs `webhooks:write`. Scope: [`webhooks:write`](/docs/api#scope-webhooks:write) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `idempotency-key` | header | string | yes | A key of yours for the request, such as a UUID, at most 255 characters. The same key and body answer the first request again, and resume it after a `503`, for 24 hours after the latest attempt. Example: `5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11`. | #### Request body `application/json`: [WebhookEndpointRequest](/docs/api#schema-WebhookEndpointRequest). #### Responses **201** The endpoint, with its signing secret, at the address in `Location`. `application/json`: [CreatedWebhookEndpoint](/docs/api#schema-CreatedWebhookEndpoint). | Header | Type | Required | Description | | --- | --- | --- | --- | | `location` | string | yes | Where the endpoint is read. Example: `/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90`. | **400** The body can't be parsed (`malformed_request`), the create has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`malformed_request`](/docs/api#error-malformed_request), [`idempotency_key_required`](/docs/api#error-idempotency_key_required), [`idempotency_key_invalid`](/docs/api#error-idempotency_key_invalid). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `malformed_request`, `idempotency_key_required`, `idempotency_key_invalid`. Example: `malformed_request`. | **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **409** The key was used with another body (`idempotency_conflict`): use a new key. A create with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization keeps ten endpoints already, disabled ones aside (`endpoint_limit_reached`): disable one first. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`idempotency_conflict`](/docs/api#error-idempotency_conflict), [`idempotency_in_progress`](/docs/api#error-idempotency_in_progress), [`endpoint_limit_reached`](/docs/api#error-endpoint_limit_reached). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `idempotency_conflict`, `idempotency_in_progress`, `endpoint_limit_reached`. Example: `idempotency_conflict`. | **413** The body is over the API's limit (`too_large`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`too_large`](/docs/api#error-too_large). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `too_large`. Example: `too_large`. | **415** The body isn't JSON (`unsupported_media_type`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`unsupported_media_type`](/docs/api#error-unsupported_media_type). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `unsupported_media_type`. Example: `unsupported_media_type`. | **422** A field is missing, not valid or not one the create takes (`invalid_request`), the address isn't https on port 443 without credentials, or its host is localhost, a name of one label or an IP address that isn't public (`url_not_allowed`), or an event type isn't one YOU(th) sends (`unknown_event_type`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request), [`url_not_allowed`](/docs/api#error-url_not_allowed), [`unknown_event_type`](/docs/api#error-unknown_event_type). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_request`, `url_not_allowed`, `unknown_event_type`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out), [`temporarily_unavailable`](/docs/api#error-temporarily_unavailable). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`, `temporarily_unavailable`. Example: `identity_unavailable`. | #### Request samples ```bash curl --request POST https://api.youth-platform.io/v1/webhook-endpoints \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" \ --header "idempotency-key: 5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11" \ --header "Content-Type: application/json" \ --data '{ "url": "https://partner.example.com/youth-webhook", "event_types": [ "AccessCode.redeemed", "Access.ended" ], "description": "Billing" }' ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/webhook-endpoints", { method: "POST", headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, "Content-Type": "application/json", "idempotency-key": "5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11", }, body: JSON.stringify({ "url": "https://partner.example.com/youth-webhook", "event_types": [ "AccessCode.redeemed", "Access.ended" ], "description": "Billing" }), }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.post( "https://api.youth-platform.io/v1/webhook-endpoints", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", "idempotency-key": "5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11", }, json={ "url": "https://partner.example.com/youth-webhook", "event_types": [ "AccessCode.redeemed", "Access.ended", ], "description": "Billing", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", "url": "https://partner.example.com/youth-webhook", "description": "Billing", "event_types": [ "Access.ended", "AccessCode.redeemed" ], "status": "active", "created_at": "2026-11-20T09:30:00.000Z", "updated_at": "2026-11-20T09:30:00.000Z", "signing_secret": "whsec_Zm9vYmFyYmF6cXV4LWV4YW1wbGUtc2VjcmV0LXZhbHVl" } ``` ### Read a webhook endpoint `GET /v1/webhook-endpoints/{webhook_endpoint_id}` One of your organization's endpoints, without its signing secret. Needs `webhooks:write`. Scope: [`webhooks:write`](/docs/api#scope-webhooks:write) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `webhook_endpoint_id` | path | string | yes | The endpoint's id. Format: `uuid`. Example: `0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90`. | #### Responses **200** The endpoint. `application/json`: [WebhookEndpoint](/docs/api#schema-WebhookEndpoint). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **404** No endpoint of yours has this id (`not_found`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`not_found`](/docs/api#error-not_found). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `not_found`. Example: `not_found`. | **422** A field is missing or not valid (`invalid_request`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `invalid_request`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`. Example: `identity_unavailable`. | #### Request samples ```bash curl https://api.youth-platform.io/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90 \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", { headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.get( "https://api.youth-platform.io/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", "url": "https://partner.example.com/youth-webhook", "description": "Billing", "event_types": [ "Access.ended", "AccessCode.redeemed" ], "status": "active", "created_at": "2026-11-20T09:30:00.000Z", "updated_at": "2026-11-20T09:30:00.000Z" } ``` ### Disable a webhook endpoint `POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable` Stops deliveries to one of your organization's endpoints, active or paused: what it still had to receive fails at once, and you read it from the API. It can't be turned on again; create an endpoint for the address instead. Disabling it again answers it as it stands. Needs `webhooks:write`. Scope: [`webhooks:write`](/docs/api#scope-webhooks:write) #### Parameters | Parameter | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `webhook_endpoint_id` | path | string | yes | The endpoint's id. Format: `uuid`. Example: `0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90`. | #### Responses **200** The endpoint, `disabled`. `application/json`: [WebhookEndpoint](/docs/api#schema-WebhookEndpoint). **401** No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_token`](/docs/api#error-invalid_token), [`integration_revoked`](/docs/api#error-integration_revoked). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `invalid_token`, `integration_revoked`. Example: `invalid_token`. | **403** The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`insufficient_scope`](/docs/api#error-insufficient_scope). | Header | Type | Required | Description | | --- | --- | --- | --- | | `www-authenticate` | string | yes | What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold. Example: `Bearer error="invalid_token"`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `insufficient_scope`. Example: `insufficient_scope`. | **404** No endpoint of yours has this id (`not_found`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`not_found`](/docs/api#error-not_found). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `not_found`. Example: `not_found`. | **422** A field is missing or not valid (`invalid_request`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`invalid_request`](/docs/api#error-invalid_request). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `invalid_request`. Example: `invalid_request`. | **500** The API failed; the request id in the answer names the request (`internal_error`). `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`internal_error`](/docs/api#error-internal_error). | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | Always `internal_error`. Example: `internal_error`. | **503** The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. `application/problem+json`: [Problem](/docs/api#schema-Problem). Codes: [`identity_unavailable`](/docs/api#error-identity_unavailable), [`timed_out`](/docs/api#error-timed_out). | Header | Type | Required | Description | | --- | --- | --- | --- | | `retry-after` | string | no | In how many seconds to send the same request again. Example: `10`. | | Field | Type | Required | Description | | --- | --- | --- | --- | | `code` | string | yes | One of `identity_unavailable`, `timed_out`. Example: `identity_unavailable`. | #### Request samples ```bash curl --request POST https://api.youth-platform.io/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90/disable \ --header "Authorization: Bearer $YOUTH_ACCESS_TOKEN" ``` ```typescript const response = await fetch("https://api.youth-platform.io/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90/disable", { method: "POST", headers: { Authorization: `Bearer ${process.env.YOUTH_ACCESS_TOKEN}`, }, }); console.log(response.status, await response.text()); ``` ```python import os import requests response = requests.post( "https://api.youth-platform.io/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90/disable", headers={ "Authorization": f"Bearer {os.environ['YOUTH_ACCESS_TOKEN']}", }, ) print(response.status_code, response.text) ``` #### Response sample ```json { "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90", "url": "https://partner.example.com/youth-webhook", "description": "Billing", "event_types": [ "Access.ended", "AccessCode.redeemed" ], "status": "active", "created_at": "2026-11-20T09:30:00.000Z", "updated_at": "2026-11-20T09:30:00.000Z" } ``` ## Schemas ### AccessCodeRedeemed object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `event_id` | string | yes | Matches `^evt_[0-9a-f]{32}$`. Example: `evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c`. | | `event_type` | string | yes | Always `AccessCode.redeemed`. Example: `AccessCode.redeemed`. | | `occurred_at` | string | yes | Format: `date-time`. Example: `2026-12-12T09:30:00.375000Z`. | | `resource_url` | string | yes | Format: `uri`. Example: `https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | | `access_code_id` | string | yes | Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | | `batch_id` | string | yes | Format: `uuid`. Example: `0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21`. | ### AccessEnded object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `event_id` | string | yes | Matches `^evt_[0-9a-f]{32}$`. Example: `evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c`. | | `event_type` | string | yes | Always `Access.ended`. Example: `Access.ended`. | | `occurred_at` | string | yes | Format: `date-time`. Example: `2026-12-12T09:30:00.375000Z`. | | `resource_url` | string | yes | Format: `uri`. Example: `https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | | `access_code_id` | string | yes | Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | | `batch_id` | string | yes | Format: `uuid`. Example: `0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21`. | | `reason` | string | yes | One of `ended_by_partner`, `term_over`. Example: `ended_by_partner`. | ### CurrentOrganization object. The organization the credentials belong to, and the integration calling: what a partner reads to check new credentials. | Field | Type | Required | Description | | --- | --- | --- | --- | | `organization` | object | yes | The organization the credentials belong to. | | `organization.alias` | string | yes | The organization's alias, which never changes. 1 to 255 characters. Example: `example-clinic`. | | `organization.name` | string | yes | The organization's name. Example: `Example Clinic`. | | `integration` | object | yes | The integration calling. | | `integration.id` | string | yes | The integration's id. Example: `3f2b8c1e-9a47-4d65-b0e2-7c1a5d9e4f08`. | | `integration.name` | string | yes | The name its admins gave it. Example: `Billing`. | | `integration.scopes` | array of string | yes | The OAuth scopes the calling token holds, in the catalogue's order. Today: access_codes:read, access_codes:write, webhooks:write, checkups:read, patients:read. A scope added later appears here without a new version, so read each as text. Example: `["access_codes:read"]`. | ### Problem object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `type` | string | yes | Always `about:blank`: the status and `code` say what happened. Always `about:blank`. Example: `about:blank`. | | `title` | string | yes | The status's English name, for logs; match on `code` instead. Example: `Unauthorized`. | | `status` | integer | yes | The HTTP status of the answer. Example: `401`. | | `code` | string | yes | What happened, stable and in snake_case; clients translate it. Codes can be added within v1, so a client treats a code it doesn't know by the HTTP status. Matches `^[a-z][a-z0-9_]*$`. Example: `invalid_token`. | | `request_id` | string | yes | The request's id, as the logs name it. Example: `7f3c2a9e-5b1d-4c6a-9e0f-2d8b4a1c6e53`. | ### AccessCodeBatch object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `id` | string | yes | The batch's id: what its codes and the other routes name. Format: `uuid`. Example: `0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21`. | | `label` | string | yes | The name of yours the order gave it. Example: `december-2026`. | | `status` | string | yes | `ready` once every code can be read and redeemed, which an order answers with. `creating` while an order that answered `503` hasn't been sent again; `failed` when none was within a day, and then none of its codes is listed or billed. One of `creating`, `ready`, `failed`. Example: `ready`. | | `count` | integer | yes | How many codes it holds. Example: `1000`. | | `redeem_by` | string or null | yes | The last moment one of its codes can be redeemed; none for no end. Format: `date-time`. Example: `2027-12-31T23:59:59.000Z`. | | `access` | [FixedDaysAccess](/docs/api#schema-FixedDaysAccess) or [UntilEndedAccess](/docs/api#schema-UntilEndedAccess) | yes | What a redeemed code grants. Example: `{"term":"until_ended"}`. | | `created_at` | string | yes | When it was ordered. Format: `date-time`. Example: `2026-12-01T10:00:00.000Z`. | ### FixedDaysAccess object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `term` | string | yes | Access for `days` days from the redemption, which then ends by itself. Always `fixed_days`. Example: `fixed_days`. | | `days` | integer | yes | How many days a redeemed code's access lasts. At least `1`. At most `3650`. Example: `30`. | ### UntilEndedAccess object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `term` | string | yes | Access until the organization ends it, for a service billed by period. Always `until_ended`. Example: `until_ended`. | ### AccessCodeBatchOrder object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `count` | integer | yes | How many codes, at most 20,000, and within your organization's daily limit: 1,000 codes a day unless YOU(th) raised it. At least `1`. At most `20000`. Example: `1000`. | | `label` | string | yes | A name of yours for the batch, such as the month or your order number. It is never shown to a customer. 1 to 100 characters. Example: `december-2026`. | | `redeem_by` | string or null | no | The last moment a code of the batch can be redeemed, still to come and at most five years ahead; none for no end. Format: `date-time`. Example: `2027-12-31T23:59:59Z`. | | `access` | [FixedDaysAccessOrder](/docs/api#schema-FixedDaysAccessOrder) or [UntilEndedAccessOrder](/docs/api#schema-UntilEndedAccessOrder) | yes | What a redeemed code of the batch grants. Example: `{"term":"until_ended"}`. | ### FixedDaysAccessOrder object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `term` | string | yes | Access for `days` days from the redemption, which then ends by itself. Always `fixed_days`. Example: `fixed_days`. | | `days` | integer | yes | How many days a redeemed code's access lasts. At least `1`. At most `3650`. Example: `30`. | ### UntilEndedAccessOrder object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `term` | string | yes | Access until the organization ends it, for a service billed by period. Always `until_ended`. Example: `until_ended`. | ### AccessCodePage object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `items` | array of [AccessCode](/docs/api#schema-AccessCode) | yes | The page's codes, in order of their ids. Example: `[{"id":"0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34","batch_id":"0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21","code":"482957362845","redeem_url":"https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845","status":"available","redeemed_at":null,"access":{"term":"until_ended","ends_at":null}}]`. | | `next` | string or null | yes | Pass it as `after` to read the next page; none on the last. Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | ### AccessCode object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `id` | string | yes | The code's id: what events and the other routes name. Store it beside the code. Format: `uuid`. Example: `0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34`. | | `batch_id` | string | yes | Its batch's id. Format: `uuid`. Example: `0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21`. | | `code` | string | yes | What the customer types. An opaque string: store and show it exactly as it is, without spaces. A secret until redeemed. Example: `482957362845`. | | `redeem_url` | string or null | yes | The link that redeems it in the YOU(th) app, with your organization and the code filled in: use it exactly as it is. Absent (`null`) when your organization's members redeem in an app of its own. Format: `uri`. Example: `https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845`. | | `status` | string | yes | `available` until someone redeems it, then `redeemed`, then `ended` once its access has stopped; or `deactivated` once you block it, or `expired` past its batch's `redeem_by`. One of `available`, `redeemed`, `ended`, `deactivated`, `expired`. Example: `available`. | | `redeemed_at` | string or null | yes | When it was redeemed; none until it is. Format: `date-time`. Example: `null`. | | `access` | object | yes | The access it grants, once redeemed. | | `access.term` | string | yes | Its batch's term. One of `fixed_days`, `until_ended`. Example: `until_ended`. | | `access.ends_at` | string or null | yes | When its access ends or ended: the end you set, or a `fixed_days` code's last day once redeemed; none while no end is set. Format: `date-time`. Example: `null`. | ### AccessEndChange object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `ends_at` | string or null | no | When the access ends. A time to come ends it then; one that has passed, or none sent, ends it now; `null` undoes an end that hasn't passed, back to the code's own term. Format: `date-time`. Example: `2027-01-12T00:00:00Z`. | ### CreatedWebhookEndpoint [WebhookEndpoint](/docs/api#schema-WebhookEndpoint). | Field | Type | Required | Description | | --- | --- | --- | --- | | `signing_secret` | string | yes | What your receiver verifies each delivery with: `whsec_` and its key. Only the create answers it, and a repeat of the create with the same `Idempotency-Key` within 24 hours; store it in your secret store at once. Example: `whsec_Zm9vYmFyYmF6cXV4LWV4YW1wbGUtc2VjcmV0LXZhbHVl`. | ### WebhookEndpoint object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `id` | string | yes | The endpoint's id. Format: `uuid`. Example: `0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90`. | | `url` | string | yes | Where its deliveries go. Example: `https://partner.example.com/youth-webhook`. | | `description` | string or null | yes | Your note about it; none if you gave none. Example: `Billing`. | | `event_types` | array of string | yes | The events it receives, in alphabetical order. Example: `["Access.ended","AccessCode.redeemed"]`. | | `status` | string | yes | `active`: deliveries are sent. `paused`: YOU(th) stopped sending, because the address kept answering `404` or `410`. `disabled`: you stopped it. One of `active`, `paused`, `disabled`. Example: `active`. | | `created_at` | string | yes | When it was created, in UTC. Format: `date-time`. Example: `2026-11-20T09:30:00.000Z`. | | `updated_at` | string | yes | When it last changed, in UTC. Format: `date-time`. Example: `2026-11-20T09:30:00.000Z`. | ### WebhookEndpointRequest object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `url` | string | yes | Where deliveries go: an `https` address on port 443, without credentials, whose host resolves to public addresses when each delivery is sent. At most 2048 characters. Example: `https://partner.example.com/youth-webhook`. | | `event_types` | array of string | yes | The events it receives, by `event_type`; each named once is enough. 1 to 20 items. Each item: 1 to 100 characters. Example: `["AccessCode.redeemed","Access.ended"]`. | | `description` | string | no | A note of yours about it, such as the system it feeds. 1 to 200 characters. Example: `Billing`. | ### WebhookEndpointPage object. | Field | Type | Required | Description | | --- | --- | --- | --- | | `items` | array of [WebhookEndpoint](/docs/api#schema-WebhookEndpoint) | yes | The page's endpoints, oldest first. Example: `[{"id":"0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90","url":"https://partner.example.com/youth-webhook","description":"Billing","event_types":["Access.ended","AccessCode.redeemed"],"status":"active","created_at":"2026-11-20T09:30:00.000Z","updated_at":"2026-11-20T09:30:00.000Z"}]`. | | `next` | string or null | yes | Pass as `after` for the next page; none after the last. Format: `uuid`. Example: `null`. | ## Errors | Code | Status | Means | Routes | | --- | --- | --- | --- | | `invalid_token` | `401` | No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). | [`GET /v1/organization`](/docs/api#operation-get_current_organization), [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `integration_revoked` | `401` | No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`). | [`GET /v1/organization`](/docs/api#operation-get_current_organization), [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `internal_error` | `500` | The API failed; the request id in the answer names the request (`internal_error`). | [`GET /v1/organization`](/docs/api#operation-get_current_organization), [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `identity_unavailable` | `503` | The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds. | [`GET /v1/organization`](/docs/api#operation-get_current_organization), [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `timed_out` | `503` | The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds. The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds. | [`GET /v1/organization`](/docs/api#operation-get_current_organization), [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `malformed_request` | `400` | The body can't be parsed (`malformed_request`), the order has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). The body can't be parsed (`malformed_request`), the create has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `idempotency_key_required` | `400` | The body can't be parsed (`malformed_request`), the order has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). The body can't be parsed (`malformed_request`), the create has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `idempotency_key_invalid` | `400` | The body can't be parsed (`malformed_request`), the order has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). The body can't be parsed (`malformed_request`), the create has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`). | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `insufficient_scope` | `403` | The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none. | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `idempotency_conflict` | `409` | The key was used with another body (`idempotency_conflict`): use a new key. An order with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization isn't in the app yet, so no code could be redeemed (`app_not_set_up`): ask YOU(th). The key was used with another body (`idempotency_conflict`): use a new key. A create with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization keeps ten endpoints already, disabled ones aside (`endpoint_limit_reached`): disable one first. | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `idempotency_in_progress` | `409` | The key was used with another body (`idempotency_conflict`): use a new key. An order with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization isn't in the app yet, so no code could be redeemed (`app_not_set_up`): ask YOU(th). The key was used with another body (`idempotency_conflict`): use a new key. A create with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization keeps ten endpoints already, disabled ones aside (`endpoint_limit_reached`): disable one first. | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `app_not_set_up` | `409` | The key was used with another body (`idempotency_conflict`): use a new key. An order with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization isn't in the app yet, so no code could be redeemed (`app_not_set_up`): ask YOU(th). | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch) | | `too_large` | `413` | The body is over the API's limit (`too_large`). | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `unsupported_media_type` | `415` | The body isn't JSON (`unsupported_media_type`). | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `invalid_request` | `422` | A field is missing, not valid or not one the order takes (`invalid_request`), `redeem_by` has passed (`redeem_by_passed`) or is more than five years ahead (`redeem_by_too_far`), or the order would take your organization past its daily limit (`count_over_limit`): nothing was made. A field is missing or not valid (`invalid_request`). A field is missing or not valid (`invalid_request`), or a CSV file would hold more than 50,000 codes (`too_many_codes`): filter by `batch_id` or a time range, or read pages as JSON. A field is missing, not valid or not one the call takes (`invalid_request`), or the end is later than a `fixed_days` code's own term (`ends_at_beyond_term`). A field is missing, not valid or not one the create takes (`invalid_request`), the address isn't https on port 443 without credentials, or its host is localhost, a name of one label or an IP address that isn't public (`url_not_allowed`), or an event type isn't one YOU(th) sends (`unknown_event_type`). | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `redeem_by_passed` | `422` | A field is missing, not valid or not one the order takes (`invalid_request`), `redeem_by` has passed (`redeem_by_passed`) or is more than five years ahead (`redeem_by_too_far`), or the order would take your organization past its daily limit (`count_over_limit`): nothing was made. | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch) | | `redeem_by_too_far` | `422` | A field is missing, not valid or not one the order takes (`invalid_request`), `redeem_by` has passed (`redeem_by_passed`) or is more than five years ahead (`redeem_by_too_far`), or the order would take your organization past its daily limit (`count_over_limit`): nothing was made. | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch) | | `count_over_limit` | `422` | A field is missing, not valid or not one the order takes (`invalid_request`), `redeem_by` has passed (`redeem_by_passed`) or is more than five years ahead (`redeem_by_too_far`), or the order would take your organization past its daily limit (`count_over_limit`): nothing was made. | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch) | | `temporarily_unavailable` | `503` | The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds. | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `not_found` | `404` | No batch of yours has this id (`not_found`). No code of yours has this id (`not_found`). No endpoint of yours has this id (`not_found`). | [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `too_many_codes` | `422` | A field is missing or not valid (`invalid_request`), or a CSV file would hold more than 50,000 codes (`too_many_codes`): filter by `batch_id` or a time range, or read pages as JSON. | [`GET /v1/access-codes`](/docs/api#operation-list_access_codes) | | `already_redeemed` | `409` | Someone redeemed the code (`already_redeemed`): end its access instead. Someone is redeeming it this moment (`redemption_in_progress`, with `Retry-After`): send it again then. | [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code) | | `redemption_in_progress` | `409` | Someone redeemed the code (`already_redeemed`): end its access instead. Someone is redeeming it this moment (`redemption_in_progress`, with `Retry-After`): send it again then. | [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code) | | `not_redeemed` | `409` | Nobody redeemed the code (`not_redeemed`): block it instead. Its access has ended, and the call asks for a later end or none (`access_ended`). | [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end) | | `access_ended` | `409` | Nobody redeemed the code (`not_redeemed`): block it instead. Its access has ended, and the call asks for a later end or none (`access_ended`). | [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end) | | `ends_at_beyond_term` | `422` | A field is missing, not valid or not one the call takes (`invalid_request`), or the end is later than a `fixed_days` code's own term (`ends_at_beyond_term`). | [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end) | | `endpoint_limit_reached` | `409` | The key was used with another body (`idempotency_conflict`): use a new key. A create with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization keeps ten endpoints already, disabled ones aside (`endpoint_limit_reached`): disable one first. | [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `url_not_allowed` | `422` | A field is missing, not valid or not one the create takes (`invalid_request`), the address isn't https on port 443 without credentials, or its host is localhost, a name of one label or an IP address that isn't public (`url_not_allowed`), or an event type isn't one YOU(th) sends (`unknown_event_type`). | [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | | `unknown_event_type` | `422` | A field is missing, not valid or not one the create takes (`invalid_request`), the address isn't https on port 443 without credentials, or its host is localhost, a name of one label or an IP address that isn't public (`url_not_allowed`), or an event type isn't one YOU(th) sends (`unknown_event_type`). | [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint) | ## Scopes | Scope | Gives | Routes | | --- | --- | --- | | `access_codes:read` | Read batches and codes | [`GET /v1/access-code-batches/{batch_id}`](/docs/api#operation-get_access_code_batch), [`GET /v1/access-codes`](/docs/api#operation-list_access_codes), [`GET /v1/access-codes/{access_code_id}`](/docs/api#operation-get_access_code) | | `access_codes:write` | Order batches, block a code, end an access | [`POST /v1/access-code-batches`](/docs/api#operation-create_access_code_batch), [`POST /v1/access-codes/{access_code_id}/deactivate`](/docs/api#operation-deactivate_access_code), [`PUT /v1/access-codes/{access_code_id}/access`](/docs/api#operation-set_access_end) | | `webhooks:write` | Create, read and disable webhook endpoints | [`GET /v1/webhook-endpoints`](/docs/api#operation-list_webhook_endpoints), [`POST /v1/webhook-endpoints`](/docs/api#operation-create_webhook_endpoint), [`GET /v1/webhook-endpoints/{webhook_endpoint_id}`](/docs/api#operation-get_webhook_endpoint), [`POST /v1/webhook-endpoints/{webhook_endpoint_id}/disable`](/docs/api#operation-disable_webhook_endpoint) | | `checkups:read` | Read checkups | | | `patients:read` | Read members | | ## Events ### AccessCode.redeemed AccessCode.redeemed A code of your organization's was redeemed. `occurred_at` is the redemption: the time to bill from. #### Payload `application/json`: [AccessCodeRedeemed](/docs/api#schema-AccessCodeRedeemed). ```json { "event_id": "evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c", "event_type": "AccessCode.redeemed", "occurred_at": "2026-12-12T09:30:00.375000Z", "resource_url": "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "access_code_id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21" } ``` ### Access.ended Access.ended The access a code started ended: the end you set passed (`ended_by_partner`), or a `fixed_days` code reached its last day (`term_over`). `occurred_at` is when it ended. New reasons can appear. #### Payload `application/json`: [AccessEnded](/docs/api#schema-AccessEnded). ```json { "event_id": "evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c", "event_type": "Access.ended", "occurred_at": "2026-12-12T09:30:00.375000Z", "resource_url": "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "access_code_id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34", "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21", "reason": "ended_by_partner" } ``` # Overview > Run the face video and voice checkups inside your own product: what the SDKs do, and what you need. The SDKs run YOU(th)'s checkups inside your own product, and hand the person's biomarkers to your page or app: - **The face video checkup.** The person looks at their camera for about a minute while the checkup guides them. It returns heart rate, blood pressure, heart rate variability, stress and more. - **The voice checkups.** The person says a long "Aahh" twice, and the respiratory checkup returns a score; or describes their day for 30 seconds, and the mental one returns eight voice features. - **The selfie checkup.** The person takes one photo of their face, and it returns ten skin biomarkers, such as redness, hydration and perceived age. See it in the [Web SDK](/docs/sdks/web#the-selfie-checkup) and the [Flutter SDK](/docs/sdks/flutter/selfie). - **The body composition checkup.** The person turns around once in front of their phone's camera, and a couple of minutes later it returns body fat, visceral fat, muscle and lean mass, BMI and metabolic age. See it in the [Web SDK](/docs/sdks/web#body-composition) and the [Flutter SDK](/docs/sdks/flutter#run-a-body-composition-checkup). | SDK | For | Status | | ----------------------------- | -------------------------------------------------- | ---------------- | | [Flutter](/docs/sdks/flutter) | A Flutter app on Android or iOS, as a Dart package | Available, 0.6.0 | | [Web](/docs/sdks/web) | A web page, desktop or mobile, in an iframe | Available, 0.8.0 | Both return their [results](/docs/sdks/results) the same way. ## How they fit with the API - **The SDKs** measure in your product and hand the results to it. They do not send them to the YOU(th) API, so no webhook announces them. - **The API** answers checkups members complete with YOU(th): at a YOU(th) kiosk or in the YOU(th) Health Hub app. ## What you need - **Keys.** Your organization has a test key, `pk_test_…`, and a live key, `pk_live_…`. The key alone decides which a checkup is: there is no setting for it, and going live is swapping the key. Test checkups are never billed. Once YOU(th) gives you access to the console, at [admin.youth-platform.io](https://admin.youth-platform.io), your organization's admins issue and revoke keys there, under SDK, Keys; a key is shown once, when it is issued. - **A key is public.** It travels to the person's device inside your page or app, where anyone can read it. Put it in your build's configuration rather than in your code, and revoke it if it is misused. A Flutter app can keep the key on your backend instead: see [Keep your key on your backend](/docs/sdks/flutter#keep-your-key-on-your-backend). - **What each SDK needs** from your page or app: see the [Flutter SDK](/docs/sdks/flutter#what-your-app-needs) and the [Web SDK](/docs/sdks/web#what-your-page-needs). ## Monthly limits Your organization can run each face video model a set number of times a month, the voice checkups another, shared by both, and the selfie and body composition checkups one each of their own. YOU(th) sets the limits, and a key opens no checkup until they are set: a face video model without one does not run. Test and live keys count separately, each against its own limits. The months start on the first day in UTC. Past a limit, the checkup is refused and your page or app receives an error; the other checkups still run. Each SDK's reference says which: [Flutter](/docs/sdks/flutter/reference#errors), [Web](/docs/sdks/web/reference#errors). ## Your organization's settings Your organization's admins can save settings for the checkups in the YOU(th) console: a theme, fonts, the checkups' texts in each language, a default language and, for the Flutter SDK, whether it draws its face guide. The Web SDK applies them the next time it opens a checkup, and the Flutter SDK the next time your app starts it, with no release of your page or app. The theme chosen in the console colours the record button's progress ring and the voice checkups' recording animation with its brand colour. What your code passes wins, field by field: a colour or a language you set in code stays as you set it, and the saved settings fill what you leave out. What neither sets keeps the checkup's own look. "Powered by YOU(th)" shows on every checkup. Only YOU(th) can hide it for your organization, so ask your YOU(th) contact; no code hides or rewords it. ## What leaves the device The face video stays on the person's device. Voice recordings, the selfie's photo and the body composition video go to YOU(th) for analysis, each checkup tells YOU(th) that it ran (that is how checkups are counted), and the SDKs report their own errors unless `diagnostics: false` turns that off; none of it says who the person is. Some checkups also run a library that sends data of its own, such as face video model 2's crash reports and diagnostics. [Data and privacy](/docs/sdks/privacy) says exactly what each part sends. ## Not for medical use The biomarkers are for general fitness and wellness, not for diagnosis. Tell the person so before their first measurement and wherever you show results, and remind them to consult a healthcare professional for medical advice. In an app, [App Store and Google Play](/docs/sdks/app-stores#say-what-your-app-is) gives the words to use. ## Native iOS and Android apps There are no native iOS or Android SDKs. A Flutter app uses the [Flutter SDK](/docs/sdks/flutter). A native app can show the Web SDK's checkup in a web view or a browser tab, in setups YOU(th) has not verified on devices yet: see [iOS](/docs/sdks/ios) and [Android](/docs/sdks/android). # SDK quickstart > From a key to a first result with each SDK, step by step. From a key to a first result, step by step. Each step links to the part of the SDK's own page that shows it. ## Flutter 1. **Ask your YOU(th) contact** to switch on checkups in an app for your organization, to set its monthly limits and the face video models your key may run, for access to the packages, and for access to the YOU(th) console for an admin of your organization. 2. **Issue a test key** in the YOU(th) console, at [admin.youth-platform.io](https://admin.youth-platform.io): see [Keys](/docs/sdks#what-you-need). 3. **Add the packages** and set up Android and iOS: see [Add it to your app](/docs/sdks/flutter#add-it-to-your-app). 4. **Start the SDK** with your test key: see [Start it](/docs/sdks/flutter#start-it). 5. **Show the checkup**, after [asking the person for the camera](/docs/sdks/flutter#ask-for-the-camera): see [Show the checkup](/docs/sdks/flutter#show-the-checkup). 6. **Run it on a phone**, not an emulator or a simulator. Press record and hold still in even light for about a minute. Your console then prints one line per biomarker, such as `heart_rate 64 bpm`. ## Web 1. **Ask your YOU(th) contact** to set your organization's monthly limits and the face video models your key may run, and for access to the YOU(th) console for an admin of your organization. 2. **Issue a test key** in the YOU(th) console, at [admin.youth-platform.io](https://admin.youth-platform.io): see [Keys](/docs/sdks#what-you-need). 3. **List your page's origin**, such as `http://localhost:5173` while you develop, in the console under SDK, Access, or tell your YOU(th) contact. Once one origin is listed, the checkup refuses every other: see [What your page needs](/docs/sdks/web#what-your-page-needs). 4. **Serve a page** over HTTPS (`localhost` counts while you develop) with the two cross-origin isolation headers: see [What your page needs](/docs/sdks/web#what-your-page-needs). 5. **Add the iframe and the script**, and start the checkup at `https://sdk.youth-platform.io` with your test key: see [Start a checkup](/docs/sdks/web#start-a-checkup). 6. **Open the page** on a device with a camera, allow the camera, press record and hold still in even light for about a minute. Your browser's console then shows a table of biomarkers. Before you go live, [test your integration](/docs/sdks/web#test-your-integration). [Results](/docs/sdks/results) says what each biomarker is. # Results > What a checkup returns in both SDKs, and how to read it so that no result breaks your app. A checkup ends with a list of biomarkers. Each is named by its code in YOU(th)'s catalog, the code the kiosk sends too: in the Web SDK as `type`, in the Flutter SDK as `code`. The Flutter SDK's `type` keeps older codes for a few until its 1.0, which the tables below list. The SDKs hand the biomarkers to your page or app, and no webhook announces them. The SDKs send some of them back to YOU(th) only to be scored, when your app or page asks for YOU(th)'s scores ([Flutter](/docs/sdks/flutter#youths-scores), [Web](/docs/sdks/web#youths-scores)), and YOU(th) keeps none of them: [what the SDKs send](/docs/sdks/privacy#what-the-sdks-send) lists exactly what. ## What a biomarker holds | Field | What it is | | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `type` | The biomarker's code, such as `heart_rate`. Match on it. In the Flutter SDK, match on `code` instead: its `type` is deprecated, and keeps older codes for a few biomarkers until 1.0. | | `name` | A name to show, in English. It can change; never match on it. | | `value` | The measured value: a number, whole or not, or for `status` a [level](#status-levels), such as `low`. In the Web SDK, `blood_pressure` holds both numbers in mmHg: `{ "systolic": 118, "diastolic": 76 }`. | | `unit` | The value's unit, as a label such as `bpm`, `%` or `ms`; the tables below give each biomarker's. `num` is a plain number, `status` a level, and `unknown` a unit the SDK does not know. In Flutter it is a `YouthBioUnitType`, whose `unit` is this label. | | `model` | The model that measured the value, such as `face_video_1`. | | `modelVersion` | That model's version, such as `2026.11`. | `model` and `modelVersion` say what measured the value, so that results stay comparable over time: - **`model`** is the YOU(th) model that produced the value: `face_video_1`, `face_video_2`, `voice_1`, `face_selfie_1` or `body_composition_1`. A model's id never changes meaning. In the Web SDK and the Flutter SDK it is a field of each biomarker; every biomarker of one checkup names the same model. - **`modelVersion`** is a date, `YYYY.MM`, with `.2` for a second change in one month. It changes whenever anything that can move a value changes: the engine behind the model, how its output is mapped, or units. A face video model runs in the browser or on the device, so its version is fixed by the SDK release that measured: the Web SDK's by the checkup page YOU(th) hosts, the Flutter SDK's by the release you ship. The two SDKs run different builds of a model's engine, so the same version in both does not promise the same values. Voice and face selfie run on YOU(th)'s service, which names the version in each result; so does body composition. Either field reads `unknown` when the SDK was not told what measured the value. Keep such a result, and compare it only with others that say `unknown`. In the Flutter SDK a few biomarkers also carry a confidence: see its [reference](/docs/sdks/flutter/reference#results). ## Write for what can change What one checkup returns depends on the person, their profile, the device, how well the measurement went, and what your organization uses. So that no result breaks your app: - Treat every biomarker as optional, even heart rate. The list can even be empty. - Skip a code you do not know, `unknown` among them: new ones are added. - Read `value` by its `unit`. [Flutter SDK examples](/docs/sdks/flutter/examples) shows whole and partial results from made-up checkups. ## Status levels A `status` value is a lowercase word, one of the levels below. In the Flutter SDK, `unknown` means the measurement could not tell: treat it as missing. The Web SDK leaves such a biomarker out. | Biomarkers | Levels, from low to high | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | | `stress_level` | `low`, `normal`, `mild`, `high`, `extreme` | | `hemoglobin_index` | `very_low`, `low`, `normal`, `high` | | `ascvd_risk_level`, `cardiorespiratory_wellness_level`, `high_fasting_glucose_risk`, `high_hba1c_risk`, `high_total_cholesterol_risk`, `hypertension_risk`, `low_hemoglobin_risk`, `recovery_ability`, `stress_response` | `low`, `medium`, `high` | The Flutter SDK's `type` names two of them by older codes until its 1.0: `wellness_level` for `cardiorespiratory_wellness_level`, and `diabetes_risk` for `high_hba1c_risk`. ## How YOU(th) bands a value YOU(th)'s own app and kiosk put each value in a band: strong, moderate or weak. You can use the same bands, for example to colour a value. They describe wellness, not a diagnosis, and they are not reference ranges for medical use. Some biomarkers draw questions in app review: see [App Store and Google Play](/docs/sdks/app-stores) before you choose what to show. A band runs from its first number, included, to its second: "below" leaves that number out, and "to" takes it in. "Above" leaves its number out too. Numbers are rounded to two decimals. Each row names the biomarker's code; [the biomarkers](#the-biomarkers) give the Flutter SDK's `type` where it differs. | Code | Strong | Moderate | Weak | | ---------------------------------- | -------------------- | -------------------------------- | ------------------------ | | `blood_pressure`, diastolic | 60 to 80 | above 80 to 89 | below 60, above 89 | | `blood_pressure`, systolic | 90 to 120 | above 120 to 139 | below 90, above 139 | | `breathing_rate` | 12.01 to below 20.01 | 6 to below 12.01 | below 6, 20.01 or more | | `cardiac_workload` | 70 to below 150.01 | below 70, 150.01 to below 173.01 | 173.01 or more | | `cardiorespiratory_wellness` | 8 or more | 4 to below 8 | below 4 | | `cardiorespiratory_wellness_level` | `high` | `medium` | `low` | | `face_skin_acne_index` | 50 or more | 30 to below 50 | below 30 | | `face_skin_eye_area_condition` | 50 or more | 30 to below 50 | below 30 | | `face_skin_hydration` | 50 or more | 30 to below 50 | below 30 | | `face_skin_pigmentation_index` | 50 or more | 30 to below 50 | below 30 | | `face_skin_pores_health` | 50 or more | 30 to below 50 | below 30 | | `face_skin_redness` | 50 or more | 30 to below 50 | below 30 | | `face_skin_uniformness` | 50 or more | 30 to below 50 | below 30 | | `face_skin_wrinkles_index` | 50 or more | 30 to below 50 | below 30 | | `hba1c_estimate` | below 5.7 | 5.7 to 6.5 | above 6.5 | | `heart_rate` | 47 to below 75.01 | 75.01 to below 88.01 | below 47, 88.01 or more | | `hemoglobin_index` | `normal` | `low` | `very_low`, `high` | | `high_fasting_glucose_risk` | `low` | `medium` | `high` | | `high_hba1c_risk` | `low` | `medium` | `high` | | `high_total_cholesterol_risk` | `low` | `medium` | `high` | | `hrv_lf_hf` | below 1.51 | 1.51 to below 3.01 | 3.01 or more | | `hypertension_risk` | `low` | `medium` | `high` | | `low_hemoglobin_risk` | `low` | `medium` | `high` | | `mean_arterial_pressure` | 70 to below 93.33 | 93.33 to below 105.67 | below 70, 105.67 or more | | `normalized_stress_index` | below 30 | 30 to below 50.01 | 50.01 or more | | `oxygen_saturation` | 95 or more | 90 to below 95 | below 90 | | `parasympathetic_activity` | 40 or more | 25 to below 40 | below 25 | | `pns_index` | 1.01 or more | -1 to below 1.01 | below -1 | | `pulse_pressure` | 25 to below 60 | – | below 25, 60 or more | | `pulse_respiration_quotient` | 4 to below 5.01 | below 4 | 5.01 or more | | `recovery_ability` | `high` | `medium` | `low` | | `sns_index` | below -1 | -1 to below 1.01 | 1.01 or more | | `stress_index` | 80 to below 150.01 | below 80, 150.01 to below 300 | 300 or more | | `stress_level` | `low`, `normal` | `mild` | `high`, `extreme` | | `stress_response` | `low` | `medium` | `high` | Heart rate variability is banded by age. Each cell gives where the strong and the moderate band start, included; a lower value is weak. | Code | 18 to 25 | 26 to 35 | 36 to 45 | 46 to 55 | 56 to 65 | 66 and over | | -------------- | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | | `hrv_mean_rri` | 910, 720 | 880, 700 | 850, 670 | 820, 645 | 800, 630 | 790, 620 | | `hrv_rmssd` | 60, 45 | 50, 40 | 40, 30 | 30, 22 | 25, 18 | 20, 15 | | `hrv_sd1` | 42.43, 31.82 | 35.36, 28.28 | 28.28, 21.21 | 21.21, 15.56 | 17.68, 12.73 | 14.14, 10.61 | | `hrv_sd2` | 120, 78.66 | 100, 64.81 | 80, 52.44 | 60, 39.47 | 49.25, 32.98 | 40, 26.22 | | `hrv_sdnn` | 90, 60 | 75, 50 | 60, 40 | 45, 30 | 37, 25 | 30, 20 | The selfie's two ages are banded against the person's own age: `face_skin_eye_age` and `face_skin_perceived_age`. Up to the person's age is strong, up to two years over it moderate, and more than that weak. YOU(th) does not band `ascvd_risk`, `ascvd_risk_level`, `heart_age` or `stress_index_scaled`: show them as values. ## The biomarkers The codes a face video checkup can return, and the SDKs that return them. Each code links to its row in the [biomarker list](/docs/data/biomarkers), which also names the other channels that send it. No checkup returns them all: which ones arrive depends on the person and the measurement. | Code | Measures | Unit | SDKs | | -------------------------------------------------------------------------------------------- | -------------------------------------------- | ----------------------- | ------------ | | [`ascvd_risk`](/docs/data/biomarkers#ascvd_risk) | ASCVD risk | `%` | Web, Flutter | | [`ascvd_risk_level`](/docs/data/biomarkers#ascvd_risk_level) | ASCVD risk, as a level | `status` | Web, Flutter | | [`blood_pressure`](/docs/data/biomarkers#blood_pressure) | Blood pressure: `systolic` and `diastolic` | `mmHg` | Web | | [`breathing_rate`](/docs/data/biomarkers#breathing_rate) | Breathing rate | `bpm` | Web, Flutter | | [`cardiac_workload`](/docs/data/biomarkers#cardiac_workload) | Cardiac workload | `mmHgPerSec` | Web, Flutter | | [`cardiorespiratory_wellness`](/docs/data/biomarkers#cardiorespiratory_wellness) | Wellness index | `num` | Web | | [`cardiorespiratory_wellness_level`](/docs/data/biomarkers#cardiorespiratory_wellness_level) | Wellness level | `status` | Web | | [`heart_age`](/docs/data/biomarkers#heart_age) | Heart age | `year` | Web, Flutter | | [`heart_rate`](/docs/data/biomarkers#heart_rate) | Resting heart rate | `bpm` | Web, Flutter | | [`hba1c_estimate`](/docs/data/biomarkers#hba1c_estimate) | Average glucose index | `%` | Web, Flutter | | [`hemoglobin`](/docs/data/biomarkers#hemoglobin) | Hemoglobin, as the camera estimates it | `g/dL` | Flutter | | [`hemoglobin_index`](/docs/data/biomarkers#hemoglobin_index) | Hemoglobin, as its band for the person's sex | `status` | Web, Flutter | | [`high_fasting_glucose_risk`](/docs/data/biomarkers#high_fasting_glucose_risk) | High fasting glucose index | `status` | Web, Flutter | | [`high_hba1c_risk`](/docs/data/biomarkers#high_hba1c_risk) | Metabolic index | `status` | Web | | [`high_total_cholesterol_risk`](/docs/data/biomarkers#high_total_cholesterol_risk) | High total cholesterol index | `status` | Web, Flutter | | [`hrv_lf_hf`](/docs/data/biomarkers#hrv_lf_hf) | LF/HF | `num` | Web, Flutter | | [`hrv_mean_rri`](/docs/data/biomarkers#hrv_mean_rri) | Average heartbeats interval | `ms` | Web | | [`hrv_rmssd`](/docs/data/biomarkers#hrv_rmssd) | Instant heart rate variability (RMSSD) | `ms` | Web, Flutter | | [`hrv_sd1`](/docs/data/biomarkers#hrv_sd1) | SD1 | `ms` | Web, Flutter | | [`hrv_sd2`](/docs/data/biomarkers#hrv_sd2) | SD2 | `ms` | Web, Flutter | | [`hrv_sdnn`](/docs/data/biomarkers#hrv_sdnn) | Total heart rate variability (SDNN) | `ms` | Web, Flutter | | [`hypertension_risk`](/docs/data/biomarkers#hypertension_risk) | Hypertension index | `status` | Web, Flutter | | [`low_hemoglobin_risk`](/docs/data/biomarkers#low_hemoglobin_risk) | Low hemoglobin risk | `status` | Web, Flutter | | [`mean_arterial_pressure`](/docs/data/biomarkers#mean_arterial_pressure) | Mean arterial pressure, in mmHg | `mmHg` (Flutter: `num`) | Web, Flutter | | [`normalized_stress_index`](/docs/data/biomarkers#normalized_stress_index) | Normalized stress index | `num` (Flutter: `%`) | Web, Flutter | | [`oxygen_saturation`](/docs/data/biomarkers#oxygen_saturation) | Oxygen saturation index | `%` | Web, Flutter | | [`parasympathetic_activity`](/docs/data/biomarkers#parasympathetic_activity) | Parasympathetic activity | `%` | Web | | [`pns_index`](/docs/data/biomarkers#pns_index) | Rest response (PNS) | `num` | Web, Flutter | | [`pulse_pressure`](/docs/data/biomarkers#pulse_pressure) | Pulse pressure, in mmHg | `mmHg` (Flutter: `num`) | Web, Flutter | | [`pulse_respiration_quotient`](/docs/data/biomarkers#pulse_respiration_quotient) | Pulse respiratory quotient (PRQ) | `num` | Web | | [`recovery_ability`](/docs/data/biomarkers#recovery_ability) | Recovery ability | `status` | Web, Flutter | | [`sns_index`](/docs/data/biomarkers#sns_index) | Alert response (SNS) | `num` | Web, Flutter | | [`stress_index`](/docs/data/biomarkers#stress_index) | Stress index (Baevsky) | `num` | Web | | [`stress_index_scaled`](/docs/data/biomarkers#stress_index_scaled) | Stress index, from 0 to 10 | `num` | Web | | [`stress_level`](/docs/data/biomarkers#stress_level) | Stress level | `status` | Web, Flutter | | [`stress_response`](/docs/data/biomarkers#stress_response) | Stress response | `status` | Web, Flutter | The Flutter SDK's `type` names some of them by older codes until its 1.0, and it sends blood pressure as two biomarkers, each in `mmHg`: | Code | The Web SDK's | SDKs | | ---------------------------------------------------------------------------- | ---------------------------------- | ------- | | [`baevsky_stress_index`](/docs/data/biomarkers#stress_index) | `stress_index` | Flutter | | [`blood_pressure_diastolic`](/docs/data/biomarkers#blood_pressure_diastolic) | `blood_pressure`'s `diastolic` | Flutter | | [`blood_pressure_systolic`](/docs/data/biomarkers#blood_pressure_systolic) | `blood_pressure`'s `systolic` | Flutter | | [`diabetes_risk`](/docs/data/biomarkers#high_hba1c_risk) | `high_hba1c_risk` | Flutter | | [`hrv_rri`](/docs/data/biomarkers#hrv_mean_rri) | `hrv_mean_rri` | Flutter | | [`prq`](/docs/data/biomarkers#pulse_respiration_quotient) | `pulse_respiration_quotient` | Flutter | | [`wellness_index`](/docs/data/biomarkers#cardiorespiratory_wellness) | `cardiorespiratory_wellness` | Flutter | | [`wellness_level`](/docs/data/biomarkers#cardiorespiratory_wellness_level) | `cardiorespiratory_wellness_level` | Flutter | Until its 1.0, the Flutter SDK also sends its HbA1c estimate as `hba1c`, the same value as `hba1c_estimate`, and its hemoglobin in g/dL as `hemoglobin`, beside `hemoglobin_index`. Show `hba1c_estimate` and `hemoglobin_index`: in YOU(th)'s catalog `hba1c` is a lab's value, and the camera's g/dL is too rough to show. ## The voice checkups Both SDKs run the voice checkups. The respiratory one returns one biomarker. | Code | Measures | Unit | SDKs | | -------------------------------------------------------------------------------- | ----------------------------------------------------- | -------------------- | ------------ | | [`respiratory_symptoms_score`](/docs/data/biomarkers#respiratory_symptoms_score) | Respiratory symptoms score, as a number from 0 to 100 | `num` (Flutter: `%`) | Web, Flutter | The mental one returns eight voice features of mental fitness, each a number. All but the pause duration are better higher. Each code links to its biomarker's row in the list. | Code | Measures | Unit | SDKs | | ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ----------- | ---- | | [`voice_smoothness`](/docs/data/biomarkers#voice_smoothness) | Smoothness: how regular the voice's pitch periods are; normally 88–100 | `%` | Web | | [`voice_control`](/docs/data/biomarkers#voice_control) | Control: how regular the voice's pitch amplitude is; normally 78–93 | `%` | Web | | [`voice_liveliness`](/docs/data/biomarkers#voice_liveliness) | Liveliness: the range of pitch used while speaking; normally 0–0.45 | `octaves` | Web | | [`voice_energy_range`](/docs/data/biomarkers#voice_energy_range) | Energy range: the range of loudness used while speaking; normally 3–12 | `dB` | Web | | [`voice_clarity`](/docs/data/biomarkers#voice_clarity) | Clarity: the range of sounds made by shaping the tongue, mouth and throat; normally 0.20–1.20 | `kHz²` | Web | | [`voice_crispness`](/docs/data/biomarkers#voice_crispness) | Crispness: the average length of a single speech sound; normally 100–400 | `ms` | Web | | [`speech_rate`](/docs/data/biomarkers#speech_rate) | Speech rate: words spoken per minute; normally 25–220 | `words/min` | Web | | [`pause_duration`](/docs/data/biomarkers#pause_duration) | Pause duration: the average pause between speech sounds, better lower; normally 0.1–1.0 | `sec` | Web | The Flutter SDK's `type` names them by older codes until its 1.0: | Code | The Web SDK's | SDKs | | ----------------------------------------------------------------------- | -------------------- | ------- | | [`voice_mental_smoothness`](/docs/data/biomarkers#voice_smoothness) | `voice_smoothness` | Flutter | | [`voice_mental_control`](/docs/data/biomarkers#voice_control) | `voice_control` | Flutter | | [`voice_mental_liveliness`](/docs/data/biomarkers#voice_liveliness) | `voice_liveliness` | Flutter | | [`voice_mental_energy_range`](/docs/data/biomarkers#voice_energy_range) | `voice_energy_range` | Flutter | | [`voice_mental_clarity`](/docs/data/biomarkers#voice_clarity) | `voice_clarity` | Flutter | | [`voice_mental_crispness`](/docs/data/biomarkers#voice_crispness) | `voice_crispness` | Flutter | | [`voice_speech_mental_rate`](/docs/data/biomarkers#speech_rate) | `speech_rate` | Flutter | | [`voice_pause_mental_duration`](/docs/data/biomarkers#pause_duration) | `pause_duration` | Flutter | ## The selfie checkup The selfie checkup returns up to ten biomarkers, in the Web SDK and the Flutter SDK, all from one photo of the face. Each is a number. The eight scores run from 0 to 100, and higher is always better, even for an index: a high acne index means few visible breakouts. The two ages are in years. | Code | Measures | Unit | SDKs | | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ------ | ------------ | | [`face_skin_redness`](/docs/data/biomarkers#face_skin_redness) | Redness: visible redness and irritation; above 80, none visible, or simply a pale tone | `%` | Web, Flutter | | [`face_skin_uniformness`](/docs/data/biomarkers#face_skin_uniformness) | Uniformness: how even the skin's colour is; patches and an uneven tone lower it; experimental | `%` | Web, Flutter | | [`face_skin_hydration`](/docs/data/biomarkers#face_skin_hydration) | Hydration: visible signs of dry skin; experimental | `%` | Web, Flutter | | [`face_skin_pores_health`](/docs/data/biomarkers#face_skin_pores_health) | Pores health: how visible the pores are, enlarged pores weighing most | `%` | Web, Flutter | | [`face_skin_acne_index`](/docs/data/biomarkers#face_skin_acne_index) | Acne index: how many breakouts show, such as acne, pimples and other spots | `%` | Web, Flutter | | [`face_skin_wrinkles_index`](/docs/data/biomarkers#face_skin_wrinkles_index) | Lines index: how visible lines and wrinkles are | `%` | Web, Flutter | | [`face_skin_pigmentation_index`](/docs/data/biomarkers#face_skin_pigmentation_index) | Pigmentation index: visible dark spots | `%` | Web, Flutter | | [`face_skin_eye_area_condition`](/docs/data/biomarkers#face_skin_eye_area_condition) | Eye area condition: puffiness under the eyes; from 4 January 2027, mean of dark circles and puffiness | `%` | Web, Flutter | | [`face_skin_perceived_age`](/docs/data/biomarkers#face_skin_perceived_age) | Perceived age: how old the skin of the face looks, 18 or more | `year` | Web, Flutter | | [`face_skin_eye_age`](/docs/data/biomarkers#face_skin_eye_age) | Eye age: how old the skin around the eyes looks, 18 or more | `year` | Web, Flutter | ### What changes on 18 December 2026 The selfie checkup of the Web SDK and the Flutter SDK has always run on YOU(th)'s current skin analysis, and the descriptions above are what its values mean. On 18 December 2026 the Health Hub, the kiosk and YOU(th)'s earlier selfie page, from before the Web SDK, move their face-skin values to the same analysis. If you also receive face-skin values from them, values from before 18 December and after it are not comparable there, and four meanings change for them: uniformness measures how even the skin's colour is, no longer its texture; pores health weighs enlarged pores more heavily; the acne index counts breakouts, broader than acne alone; and the eye area condition becomes the mean of dark circles and puffiness, where it used to blend dark circles, bags and tear troughs. For the SDKs' selfie, two things follow: - **The bands change.** The face-skin bands in [How YOU(th) bands a value](#how-youth-bands-a-value) move to the new analysis's scale on 18 December, and this page will show them. Until then, the table bands the selfie on the earlier analysis's scale. The values themselves do not change on that day. - **The eye area becomes the same mean on 4 January 2027.** Until then the SDKs' `face_skin_eye_area_condition` reads puffiness under the eyes alone: see [What changes on 4 January 2027](#what-changes-on-4-january-2027). ### What changes on 4 January 2027 For selfie checkups started from 4 January 2027, 00:00 UTC, `face_skin_eye_area_condition` is the mean of dark circles and puffiness under the eyes, as the Health Hub and the kiosk give it from 18 December 2026, and the results name `face_selfie_1` version `2027.01`. A checkup started before keeps puffiness alone and version `2026.11`, even when its result is read later. The code, name, unit and range stay the same, and no other selfie value changes. Compare a person's eye area only within one version. Only the biomarkers the analysis returned are present. They describe how the skin looks in one photo, not a skin diagnosis: light, make-up and the camera change them, so compare results taken in similar conditions. A weak camera still gets results, without an error, so a result does not prove the photo was good. The results are [not for medical use](/docs/sdks#not-for-medical-use). ## The body composition checkup The body composition checkup returns six biomarkers, in the Web SDK and the Flutter SDK, all from one video of the whole body, measured with the person's sex, year of birth, height and weight. Each code links to its biomarker's row in the list, which holds body fat and BMI under the codes the Health Hub sends: match on the code below, the one the SDKs send. | Code | Measures | Unit | SDKs | | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ------- | ------------ | | [`body_fat_percentage`](/docs/data/biomarkers#body_fat_percentage) | Body fat: the share of the body's weight that is fat | `%` | Web, Flutter | | [`body_vat_percentage`](/docs/data/biomarkers#body_vat_percentage) | Visceral fat: the share of fat around the internal organs | `%` | Web, Flutter | | [`body_appendicular_lean_mass_percentage`](/docs/data/biomarkers#body_appendicular_lean_mass_percentage) | Appendicular lean mass: the share of lean mass in the arms and legs | `%` | Web, Flutter | | [`body_skeletal_muscle_mass_percentage`](/docs/data/biomarkers#body_skeletal_muscle_mass_percentage) | Skeletal muscle mass: the share of the body's weight that is skeletal muscle | `%` | Web, Flutter | | [`body_mass_index`](/docs/data/biomarkers#body_mass_index) | Body mass index (BMI): weight relative to height | `kg/m²` | Web, Flutter | | [`body_metabolic_age`](/docs/data/biomarkers#body_metabolic_age) | Metabolic age: how old the metabolism looks, compared with the person's age | `year` | Web, Flutter | The results are [not for medical use](/docs/sdks#not-for-medical-use). # Data and privacy > What a checkup sends off the device in both SDKs, and what the checkups' own libraries send. What a checkup sends off the person's device, in both SDKs, and what the libraries some checkups embed send on their own. Your privacy policy, the App Store's privacy details and Google Play's Data safety form need it: [App Store and Google Play](/docs/sdks/app-stores#say-what-happens-to-the-data) says how to fill them in. ## What the SDKs send This is every connection the SDKs make themselves, as the Flutter SDK makes it; the Web SDK differs on a few points, [listed below](#where-the-web-sdk-differs). What the checkups' libraries send on their own is in [the next section](#what-the-checkups-libraries-send). | Connection | What it sends | What it never sends | | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | **Starting the SDK** opens a session with YOU(th) | Your key, `delivery: native`, the platform (`ios` or `android`) and the SDK's version. With `initWithSessionProvider`, your backend opens the session with your key and sends these fields itself, and your app holds only a short-lived session token. Every later connection to YOU(th) carries the session's token, never the key | Anything about the person | | **A face video measurement**, model 1 or model 2 | First it asks YOU(th) for a scan: which model, and whether the person asked to measure or the SDK prepared the scan ahead. YOU(th) answers with a random id for the scan and the credential the model's library starts with. Then it reports the scan's status under that id, with the model's name: `started`, then `completed` or `failed`. That is how checkups are counted | The video or any frame of it, the details you pass in about the person, or anything else about them. The results are worked out on the device and handed to your app; they leave it only to be scored, below | | **A voice checkup** | The person's year of birth and gender, and which voice checkup it is (respiratory or mental fitness). Then the recordings. Then it asks YOU(th) to analyse them, under an id YOU(th) gave the checkup, and asks for the results until they are ready | Anything else about the person | | **A selfie checkup** | One photo of the person's face, once they submit it. Then it asks for the results until they are ready. YOU(th) passes the photo on to the analysis under an id made for that checkup alone, with nothing that names the person, and keeps no photo. YOU(th) asks the analysis to delete the photo and its results as soon as the results are ready. An hourly job asks again when that deletion failed, and for a checkup that never finished, from two hours after it was made. It retries until the deletion succeeds, a limited number of checkups each run, and waits while a photo is still being uploaded, so a photo can stay with the analysis longer when the analysis cannot be reached. YOU(th) keeps the results for a day, for the SDK to read | Anything else about the person. The SDK keeps the photo in memory only, never in a file | | **A body composition checkup** | The person's sex, year of birth (worked out from their age), height and weight, once the capture is done, which makes the checkup. Then the video of their body, which the capture writes to a file on the device: the SDK deletes the file once it is uploaded, or when the checkup ends. Then it asks for the results until they are ready. YOU(th) passes the profile and the video on to the analysis under an id made for that checkup alone, with nothing that names the person, and keeps neither | Anything else about the person, such as a `userId` you pass in | | **YOU(th)'s scores**, only when your app passes `onFinalScores` and your organization gets scores | After a checkup's results: the person's age and sex (`female` or `male`), and the code and value of every biomarker the checkup returned, scored or not (such as `heart_age`), except `hemoglobin` and `hba1c`, whose estimates go as `hemoglobin_index` and `hba1c_estimate`. YOU(th) answers with the scores, and keeps neither them nor what it was sent | The person's other details, the video, photo or recordings, or anything that names the person | | **Error reports** of errors in the SDK's own code, and of the errors it gives your app | The error's type; its stack frames, the SDK's own with their file, function and line, any other package's reduced to the package's name; the SDK's version; the platform (`ios` or `android`); the step the SDK was at; the error code your app was given and the checkup it came from; the stage of YOU(th)'s service; whether your key is a test or a live key; and a random id and the time of the report. The SDK rebuilds each report from these fields alone before it leaves the device | The error's message, the person, your key, a session token, a scan, a result, or anything about the device beyond the platform. No record of what happened before the error | The Web SDK makes a body composition checkup before its capture rather than after it: see [below](#where-the-web-sdk-differs). YOU(th)'s servers see the device's IP address with each request and keep it in their request logs; the error reports don't store it. ### Error reports - **They are about the SDK only.** The SDK keeps its own error reporting, apart from your app's: it never reads or changes your app's error reporting, and never reports an error from outside the SDK. - **The same error is sent at most once a minute,** so an error that repeats in a loop sends one report a minute. - **They go to a service hosted in the EU,** which does not store the device's IP address. The reports also tell it not to work out where the device is from that address. - **You can turn them off.** `diagnostics: false` when you start an SDK turns them off, and so do [your organization's settings](/docs/sdks#your-organizations-settings) when you leave `diagnostics` out. YOU(th) recommends leaving them on: they are how YOU(th) sees a checkup fail in your product. ### Where the Web SDK differs - **The session** sends, besides your key and the SDK's version, how the checkup is shown: in an iframe, with `web` and the origin of the page that embeds it; in an app's web view, with `ios` or `android` when the app says which; or in a Custom Tab, with `android` and the address the result goes back to. - **A body composition checkup** sends the person's sex, year of birth, height and weight once they press Start, which makes the checkup. Then the video of their body, once recorded: it is held in memory only, never in a file or the browser's storage. Then it asks for the results until they are ready. YOU(th) holds the profile until the video arrives, then passes the profile and the video on to the analysis under an id made for that checkup alone, with nothing that names the person, and keeps neither. When no video comes, the profile is never passed on, and YOU(th) deletes it within about two hours. It never sends your `user`'s other fields. With the results, it reads the body's 3D model and its picture, which YOU(th) passes on from the analysis without keeping them, and it shows them in memory only. A Future Me sends the target weight the person picks, which YOU(th) keeps with the checkup for a day; the analysis deletes the model, the scan and the Future Mes within about two hours. - **YOU(th)'s scores** are asked only when your page passes `onScores`, or sends `scores: true` in `init`, and your organization gets scores. After a result, the checkup sends the person's age and sex (`female` or `male`) and the code and value of each biomarker the scoring takes, nothing of the person besides. YOU(th) answers with the scores, and keeps neither them nor what it was sent. - **A face video model's licence check** can go through YOU(th) on a network that blocks the library's licence servers, as [the next section](#what-the-checkups-libraries-send) says. YOU(th) then passes on the library's own licence request and its answer. - **Error reports** also carry the browser and its major version, the system (such as `ios`, `android` or `windows`), the kind of device (phone, tablet or desktop), how the checkup is shown, the origin of the page that embeds it, the model in use, the checkup's phase, the code of what caused the error, whether the page was visible and online, and how long it had been open, in broad ranges. Every frame keeps its function and line, and its script's path without the host. A report is also sent when the checkup's page stops responding. With `diagnostics` left out, the reports are on until your key is accepted, and your organization's setting decides after that. The SDKs hold no analytics or advertising library and do not track people across apps or sites. ## What the checkups' libraries send Some checkups run a library of the company whose technology measures them. Here is what each sends on its own, besides what the SDKs send: | Checkup | What its library sends on its own | Can you turn it off? | | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | Face video, model 1 | It checks its licence online when a scan opens, and sends nothing else. In the Web SDK, on a network that blocks its licence servers, that check goes through YOU(th). Its optional usage analytics stay off | No: a scan does not start without its licence | | Face video, model 2 | It checks its licence online when a scan opens, and sends its own crash reports and diagnostics (measurement events, timings, device and signal-quality information), with an identifier of the device. It gets nothing about the person: no age, height, weight, sex or smoking status, and no user id. Its local history, its video recording and its own screens are off. Its diagnostics may include measurement values: declare them as health data | No. Run model 1 only if you don't want it: in the Flutter SDK, install `youth_sdk_face_video_1`, which leaves model 2 out of your app | | Voice | Nothing: the recordings go to YOU(th) only | Nothing to turn off | | Selfie | Nothing: its face detection runs on the device and sends nothing. The Web SDK serves the face detector from YOU(th)'s own address, with its usage reports switched off | Nothing to turn off | | Body composition (Web) | Nothing: the Web SDK runs its capture with its usage reports taken out, and serves the model and files it loads from YOU(th)'s own address. It keeps nothing in the browser | Nothing to turn off | | Body composition (Flutter) | Events about its capture screen (when the capture closes, and its status), with an identifier of the device, whenever a capture runs. Its iOS privacy manifest declares them | No. Leave the package out if you don't use the checkup | Model 2 runs in both SDKs. In the Flutter SDK, which models your app carries depends on its packages: | Package | Carries | | ------------------------ | ------------ | | `youth_sdk_face_video` | Both models | | `youth_sdk_face_video_1` | Model 1 only | | `youth_sdk_face_video_2` | Model 2 only | ## On iOS Each Flutter package carries a privacy manifest that declares what that package collects, none of it linked to the person or used for tracking, so App Store Connect's privacy report lists only the checkups your app installed. Model 2's package declares health data, crash, performance and other diagnostic data and a device identifier, for what its library sends. The camera, microphone and on-device face detection the SDK uses collect and send nothing. # App Store and Google Play > Prepare an app that runs a checkup for store review: what to say, what to show and what reviewers ask for. A checkup makes your app a health app in the eyes of App Store and Google Play reviewers, whichever SDK runs it. They look closely at what the app claims to measure and at what happens to the person's data. This page says what to prepare before you submit, from the stores' rules and from what reviewers have asked of apps that run these checkups. You submit the app, so the choices and the answers to the stores are yours, and following this page does not guarantee approval. The rules change, and the stores' own text always wins: the [App Review Guidelines](https://developer.apple.com/app-store/review/guidelines/) and Google Play's [health apps policy](https://support.google.com/googleplay/android-developer/answer/16679511). This page reflects them as of November 2026. ## Say what your app is Describe a general fitness and wellness product. Make no medical or diagnostic claims in the app's name, category, description, keywords, screenshots or review notes. The statement below is the one place those words belong. Use a statement like this one. Google Play requires the words from "not a medical device" to "medical condition" in the description of any health app not regulated as a medical device, and both stores want people reminded to see a professional: ```text The results are for general fitness and wellness. This app is not a medical device and does not diagnose, treat, cure, or prevent any medical condition. Consult a healthcare professional for medical advice, diagnosis, or treatment, and before making medical decisions. ``` Put it in your store description, before the person's first measurement and wherever you show results. Tell the reviewer where to find it. Whether your app is a medical device depends on what you claim and where you offer it, so take your own regulatory advice before you submit. App Review has asked for a legal opinion on why an app that runs these checkups is not one. If your app is regulated as a medical device, declare it in Play Console and send Apple a link to its clearance. ## Choose the results you show [Guideline 1.4.1](https://developer.apple.com/app-store/review/guidelines/#physical-harm) names blood pressure, blood glucose and blood oxygen among the measurements an app may not claim to take with the device's sensors alone, and rejects accuracy claims it cannot validate. The face video checkup can return these biomarkers on those subjects: | Subject | Codes | | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Blood pressure | `blood_pressure` (in the Flutter SDK `blood_pressure_systolic` and `blood_pressure_diastolic`), `pulse_pressure`, `mean_arterial_pressure`, `cardiac_workload`, `hypertension_risk` | | Blood glucose | `hba1c_estimate`, `high_fasting_glucose_risk`, `high_hba1c_risk` (in the Flutter SDK also `hba1c`, and as its `type` `diabetes_risk`) | | Blood oxygen | `oxygen_saturation` | The safest submission leaves them out. Skip these codes when you show [results](/docs/sdks/results), and keep them out of your screenshots, demo videos and descriptions. Ask your YOU(th) contact whether your key can leave them out altogether, and check what your checkup screen says: the ready-made face video screen can show a message that names blood pressure. Documentation does not lift this rule. The guideline says these claims are not permitted, and rejections have offered to consider documentation of the data and methodology, added to the App Review Information section in App Store Connect, without promising that it is enough. If you keep them, expect to be rejected and be ready to answer. Apple's list is only examples. Reviewers have also questioned camera-based wellness ratings, and results that read as a disease risk or a blood value, such as `ascvd_risk`, `high_total_cholesterol_risk`, `hemoglobin` and `hemoglobin_index`, can draw the same question. On Google Play, an app that uses the camera for a health function must state in its description which devices it works on. The [Flutter SDK](/docs/sdks/flutter#android) and the [Web SDK](/docs/sdks/web#what-your-page-needs) say what they need. Ask your YOU(th) contact before you make any claim about accuracy or list any devices, and for the documentation YOU(th) can give you for a review. ## Ask first, and show that it is recording [Guideline 2.5.14](https://developer.apple.com/app-store/review/guidelines/#software-requirements) asks for explicit consent and a clear indication whenever an app records with the camera or the microphone. - **Before the first checkup,** say what the checkup records, what your app does with the results, and let the person decline. - **While it records,** keep the indication on screen. The ready-made screens show the recording's progress. If you build your own screen, show it yourself, and never let the screen go blank. - **Explain each permission** with a purpose string that says what the camera or the microphone is for, with an example. Apple has sent apps back for vague ones: see the [Flutter SDK](/docs/sdks/flutter#ios) for a start. A Flutter app on iOS with face video model 1 (`youth_sdk_face_video_1` or `youth_sdk_face_video`) also needs a Bluetooth purpose string, which says that the app does not use Bluetooth: that page gives one. - **Ask only for what you use.** Google Play wants unused permissions removed, and the Flutter SDK's libraries bring permissions of their own into your Android app. If your app never runs the voice checkup, leave out the microphone line the Flutter SDK page shows. The [Android permissions](/docs/sdks/flutter#android-permissions) say what each package adds, and which of those your app can remove. On iOS, keep the purpose strings of the packages you install. ## Say what happens to the data Your privacy policy has to cover the checkup, and a link to it belongs in Play Console and in the app. Fill in the App Store's privacy details and Google Play's Data safety form from this table and from what your own app does: | What | Where it goes | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | The face video | Analysed on the person's device. The SDKs neither save it nor send it anywhere. | | The voice checkup | The recordings are sent to the cloud for analysis, with the person's year of birth and gender, and the results come back to your app. | | The selfie photo | One photo of the face, sent to the cloud for analysis once the person submits it; the results come back to your app. YOU(th) asks for the photo's deletion once they are ready, and an hourly job retries until it succeeds: see [Data and privacy](/docs/sdks/privacy#what-the-sdks-send). | | The person's details | What you pass in for the face video checkup is used on the device. | | The results | Handed to your page or app. What happens next is up to you. | | The checkup's run | YOU(th) is told that it started and whether it completed or failed, with a random id and nothing about the person or their results. | | YOU(th)'s scores | Only when your app asks for them: the person's age and sex and the results are sent to YOU(th), which answers with the scores and keeps neither. | | Error reports | The SDKs report their own errors to YOU(th): what failed and where in the SDK, never the person or their results. `diagnostics: false` turns them off. | | Checkups' libraries | Face video model 2's library sends its crash reports and diagnostics with a device identifier: [Data and privacy](/docs/sdks/privacy) says what each sends. | On iOS, each Flutter package carries a privacy manifest that declares what it collects, none of it linked to the person or used for tracking, so App Store Connect's privacy report lists only the checkups your app installed ([Data and privacy](/docs/sdks/privacy#on-ios)). On Google Play's form, data processed only on the device is not collected, and data sent off it is. So the voice recordings and the details sent with them count, as do the selfie's photo and face video model 2's diagnostics and device identifier when your app runs model 2; the reports of the checkup's run and the SDKs' error reports can, and so do results your app sends to your server, and the results, age and sex the Flutter SDK sends for YOU(th)'s scores when your app asks for them. Apple has asked apps that run these checkups to answer these about face data, so write your answers before you submit: - What face data does the app collect, and what is it used for? - Is it shared with third parties, and where is it stored? - How long is it kept? - Which section of the privacy policy covers this? Quote the text. Your own product's handling of results matters as much: - **Let the person control their results.** They can skip or delete a measurement, and delete what they uploaded. Say which of their information other users can see. - **Offer account deletion in the app,** if the person can create an account there. Apple requires it, and Google Play's form asks whether a person can request deletion. - **Keep health data out of advertising.** [Guideline 5.1.3](https://developer.apple.com/app-store/review/guidelines/#health-and-health-research) forbids using it for advertising or marketing. - **Take care with HealthKit.** The same guideline forbids writing inaccurate data to it and storing personal health information in iCloud. Say in your app's interface where you use HealthKit. ## Prepare the review - **Write the review notes.** Say what the app does, that it is for wellness, where the statement above appears, how the checkup works in plain words, and where your privacy policy is. - **Give the reviewer a way in:** a demo account, and an access code if your app uses them, with where people get one. If your app sells a subscription, include an account that can reach the purchase. - **Link a video of a checkup working,** and check that the link opens. Keep it to the results you show in the app. - **Test on an iPad too,** even if you build for iPhone only: iPads run iPhone apps. Reviewers have tested on an iPad and failed the app when the checkup showed an error, and the checkup screens are laid out for a phone. - **Cite your sources.** Apple has asked for citations for medical information, so link the sources of any ranges and recommendations you show. - **Complete the Health apps declaration** on the App content page in Play Console. # Web SDK > Run the face video and voice checkups in your web page, in an iframe: set it up, start it, read its results. The Web SDK runs the face video, voice, selfie and body composition checkups inside your web page. The checkup is a page YOU(th) hosts, which you put in an ` ``` Load YOU(th)'s script, which defines `YouthSDK`. It is pinned to its version and its integrity, so it never changes under your page; a new version comes with a new address and a new `integrity`: ```html ``` Then start the checkup with your key: ```html ``` In a web app with a build step, install the same code from npm in place of the script tag: ```sh npm install @youth-healthtech/web-sdk ``` ```typescript import { startCheckup } from "@youth-healthtech/web-sdk"; const stop = startCheckup( document.getElementById("checkup") as HTMLIFrameElement, "https://sdk.youth-platform.io/embed.html", { apiKey: "your test key" }, { onResult: (biomarkers) => console.table(biomarkers), onError: (code, detail) => console.error(code, detail?.message), }, ); ``` The package has no dependencies, and each of its versions has the same code as the script of that version. In React, start the checkup in an effect and return `stop` as its cleanup: starting again on the same iframe stops the earlier checkup first, so each event arrives once. Open the page on a device with a camera, allow the camera, press record and hold still in even light for about a minute. `onResult` then receives the biomarkers: [Results](/docs/sdks/results) says what they hold. If `onError` says `INVALID_API_KEY`, check the key; if it says `ORIGIN_NOT_ALLOWED`, check that your page's origin is on your organization's list. The [errors](/docs/sdks/web/reference#errors) list the rest. `startCheckup` lets the iframe use the camera and the microphone, loads the checkup and listens only to it. `stop()` unloads the checkup, which lets go of the camera and the microphone: call it when the person is done. A page that cannot load the script can [speak the messages itself](#without-the-script). ## Tell it about the person The measurement is better with the person's profile, and some biomarkers need it. Send it as `user`. Every field is optional, except for [body composition](#body-composition). Send age, height and weight together: some measurements use the profile only when all three are there and plausible. ```json { "apiKey": "your test key", "user": { "age": 42, "gender": "female", "height": 168, "weight": 61.5, "smokingState": "nonSmoker" } } ``` | Field | Value | | -------------- | -------------------------------------- | | `age` | Years | | `gender` | `female`, `male` or `unspecified` | | `height` | Centimetres | | `weight` | Kilograms | | `smokingState` | `smoker`, `nonSmoker` or `unspecified` | Send `smokingState` whenever you know it. Face video model 1 returns `ascvd_risk`, `ascvd_risk_level` and `heart_age` together, and only when `gender` and `smokingState` are set, not `unspecified`, the age is 18 to 80 and the BMI from height and weight 15 to 50; with one missing, all three are. Model 2 is told nothing about the person and never returns them. ## Choose the face video model The face video checkup measures with a YOU(th) model. There are two, `faceVideo1` and `faceVideo2`, the same as in the Flutter SDK, and YOU(th) sets which of them your key may run, separately for your test and live keys. Name one with `model`: ```json { "apiKey": "your test key", "model": "faceVideo1" } ``` | `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: see the [rules](/docs/sdks/web/reference#the-face-video-model) | The person's profile chooses the model only with `auto`. A model your key does not offer ends the checkup with `NO_PROVIDER_AVAILABLE` before the camera starts, and no other model runs in its place. Model 2's library sends data of its own: [Data and privacy](/docs/sdks/privacy) says what. Model 2 measures until it has 45 seconds of footage it can use. Moments it can't use, such as while the face is being placed, don't count, so its measurement can run longer, by an amount that varies. Name a model when your product relies on a biomarker only one model returns, or when results must stay comparable across a person's measurements. Every result names the model and the version that produced it: see [What a biomarker holds](/docs/sdks/results#what-a-biomarker-holds). ## The next person `YouthSDK.nextCheckup` starts again with another profile, or another checkup, without loading the iframe again. A measurement under way is dropped: ```html ``` It replaces the last checkup's settings: send every field you need again, such as `user`, `model`, `checkupType` and `voiceType`. It is also how you try again after the measurement could not load: see [Errors](/docs/sdks/web/reference#errors). ## The voice checkups Send `checkupType: "voice"` to run a voice checkup instead of the face video one, and `voiceType` to choose it: | `voiceType` | The person | Results | | ------------- | -------------------------------------------- | ------------------------------------------- | | `respiratory` | Says "Aahh" twice, six seconds each. Default | One biomarker, `respiratory_symptoms_score` | | `mental` | Describes their day for 30 seconds | Eight voice features of mental fitness | ```json { "apiKey": "your test key", "checkupType": "voice", "voiceType": "mental" } ``` The voice checkups work best on a phone held close. On a computer or a kiosk the microphone is farther away and the room noisier: ask the person to come close to the microphone and speak up, and expect results there to be less reliable than on a phone. The recordings leave the device for analysis: tell the person so before they record. While they record, `onProgress` also says which recording it is. A voice error carries a `reason` as well as its `code`: see [Errors](/docs/sdks/web/reference#errors), and [Results](/docs/sdks/results#the-voice-checkups) for the biomarkers. ## The selfie checkup Send `checkupType: "faceSelfie"` to take one photo of the person's face and return up to ten skin biomarkers, such as redness, hydration, lines and perceived age: ```json { "apiKey": "your test key", "checkupType": "faceSelfie" } ``` The selfie takes nothing of the person; send `user`, with their age and gender, only for [YOU(th)'s scores](#youths-scores). It needs the camera alone: an iframe you write yourself needs at least `camera` and `cross-origin-isolated` in its `allow`. 1. **The person places their face.** The checkup checks in the browser that one face is in the frame, close enough, centred, looking straight ahead and in good light, and says what to change. No frame leaves the device while it does. 2. **A short countdown** starts once all is right, and the photo is taken. 3. **The person checks the photo**, and taps Submit, or Retake for a new one. 4. **The photo is analysed**, usually in 5 to 15 seconds, and `onResult` receives the biomarkers: see [Results](/docs/sdks/results#the-selfie-checkup). `progress` says `ready`, with `progress: 0`, while the camera waits for a good frame, and `processing`, with `progress: 100`, while the photo is sent and analysed. On its first use the browser downloads the face detector, about 17 MB from YOU(th)'s own address, with a progress bar; later checkups use the browser's cache. After an error the checkup goes back to the camera for a new photo without saying what happened, so your page tells the person; only a missing camera, or a key without the selfie, keeps its message on the checkup's screen. A selfie error carries a `reason` as well as its `code`: see [Errors](/docs/sdks/web/reference#errors). Tell the person before they start: - **The photo leaves the device.** The face check stays in the browser, but the photo they submit is sent for analysis. The checkup keeps it in memory only. [Data and privacy](/docs/sdks/privacy#what-the-sdks-send) says what is sent and kept. - **A connection** is needed from the moment they submit the photo until the results arrive. - **Even light** makes the photo clear: facing a window or a soft light, without glasses, make-up or hair over the face. The checkup is counted once the person submits the photo, whatever happens next: a new photo after an error is a new checkup. ## Body composition Send `checkupType: "bodyComposition"` to measure the person's body composition from a short video of their whole body, taken as they turn around in front of the camera. It needs the person's profile, every field of it: ```json { "apiKey": "your test key", "checkupType": "bodyComposition", "user": { "age": 42, "gender": "female", "height": 168, "weight": 61.5 } } ``` | Field | Value | | -------- | -------------------------------------------- | | `age` | Years, up to 126 (a year of birth from 1900) | | `gender` | `female` or `male` | | `height` | Centimetres, from 50 to 250 | | `weight` | Kilograms, from 20 to 500 | A profile that lacks one of them, says `unspecified`, or holds a value outside these ranges ends the checkup at once with `INVALID_USER_DATA`, before anything leaves the device. The analysis is told the year of birth, worked out from the age, not the age itself. The checkup shows its own screens: what to do, then the camera, which guides the person into the frame and through the turn, with spoken hints. Then it sends the video and waits for the analysis, which takes **one to two minutes**: the checkup says `processing` and its `progress` counts that time. It then shows the results and hands them to `onResult`: six biomarkers, see [Results](/docs/sdks/results#the-body-composition-checkup). If something fails, it shows what, offers to try again when a new try can help, and `onError` receives the code: see [Errors](/docs/sdks/web/reference#errors). Beside the results, the checkup shows the person's body in 3D, which they can turn, or a picture of it where the browser can't draw 3D. Under the results it offers **Future Me**: the same body at a lower weight the person picks, under their own and no lower than a healthy body mass index (18.5) allows. A checkup can make three, each in a minute or so, and they are not counted. The 3D model and Future Me stay on the checkup's screen while its session lasts: `onResult` receives the biomarkers alone, and the page's messages don't change. Tell the person before they start: - **A phone gives the best results.** The analysis is made for a phone's camera, set down upright at waist height, so offer the checkup on the person's phone rather than a laptop or a kiosk. Its results on the web are less accurate than in an app. - **The whole body must be in the frame**, head to feet, and only one person in it. - **The results take one to two minutes** after the video, while the page stays open. On an iPhone or iPad the checkup needs iOS 18.4 or later, and Safari 18.4 or later on a Mac: see [What your page needs](#what-your-page-needs). The video and the profile leave the device for analysis: tell the person so before they start. [Data and privacy](/docs/sdks/privacy#where-the-web-sdk-differs) says what is sent. The checkup is counted once its video is sent, not when it starts. ## YOU(th)'s scores Each checkup can also hand your page YOU(th)'s scores of its result: the scores every YOU(th) product shows, worked out by YOU(th)'s service for the person's age and sex. Your organization gets them always with the YOU(th) app; otherwise ask your YOU(th) contact. Pass `onScores`, and `onScoresError` to hear why a result came without them: ```typescript startCheckup(iframe, "https://sdk.youth-platform.io/embed.html", settings, { onResult: (biomarkers) => save(biomarkers), onScores: (scores) => showScores(scores), onScoresError: (code) => showNoScores(code), onError: (code, detail) => console.error(code, detail?.message), }); ``` - **The result comes first**, as without scores. Then `onScores` gets the scores, or `onScoresError` says why there are none. The result stays valid either way. - **Passing `onScores` asks for them.** Without it nothing is asked, none of the result's values leave the checkup for scoring, and no result waits. - **The person needs an `age`** from 18 to 120 and a `gender` of `female` or `male` in `user`. Without them, `onScoresError` gets `PROFILE_INCOMPLETE` and nothing is asked: the checkup never assumes an age or a sex. Each `nextCheckup` scores its own person. - **No connection**, no answer within 8 seconds, or a refusal of YOU(th)'s service is `SCORES_UNAVAILABLE`. The result waits that long at most. - **Without scores for your organization**, neither callback is called. A page that speaks the messages itself sends `scores: true` in `init`, and finds `scores` or `scoresError` on each `result`. The [reference](/docs/sdks/web/reference#scores) lists what the scores hold. A biomarker YOU(th) does not score, such as heart age, has none. YOU(th) keeps neither the scores nor the person's profile. ## Make it yours Start the checkup with your key alone, and it takes [your organization's settings](/docs/sdks#your-organizations-settings) from the YOU(th) console. A field you pass when you start it wins over the saved one: - **Language.** `locale` takes English, German, Italian or Spanish (`en`, `de`, `it`, `es`); a region such as `de-CH` counts as its language, and any other gives way to your organization's saved language, or English. - **Look.** `theme` sets the footer's and the record button's colours, and the texts' colour, size, weight and font. A font must be installed on the person's device. - **Words.** `messages` replaces the checkup's texts, by key. - **Layout.** `orientation` is `portrait`, the default, or `landscape`, for a screen wider than tall. `mediaShare`, which only your page sets, gives the picture a share of the iframe, for a large screen: see [On a kiosk](#on-a-kiosk). - **Error reports.** `diagnostics: false` turns the checkup's [error reports](/docs/sdks/privacy#what-the-sdks-send) off. The [reference](/docs/sdks/web/reference#settings) lists each one. ## On a kiosk The checkup fills its iframe. In `portrait` the picture is on top and a panel with the texts and the button is under it; in `landscape` the panel is on the right. The panel is only as large as its content, about 260 pixels tall with texts of 14 to 18 pixels, and the picture takes the rest. On a phone that is right. On a tall kiosk screen it leaves the picture nearly the whole screen and the instructions small at the bottom edge. `mediaShare` sets the share of the iframe the picture takes: a number from `0.2` to `0.9`, of the height in `portrait` and of the width in `landscape`. The panel gets the rest, and its texts, its button and the space between them are drawn larger together to fill it: ```json { "apiKey": "your test key", "orientation": "portrait", "mediaShare": 0.6 } ``` On a 1080 by 1920 screen, `0.6` gives the picture the top 1152 pixels and draws the panel's content about 2.3 times larger: texts of 32 to 41 pixels and a button of about 175. Half the screen draws half of everything, so one share suits a screen at any size. A screen too small for the share keeps the panel whole and gives the picture what is left: the panel is never smaller than its content, and in `landscape` never narrower than it is without a share, 300 to 400 pixels. A high share stops there. A value the checkup cannot read leaves the layout as it is without one. Choose the share with the camera in mind. Face video model 1 fills its area with the camera's picture and crops what does not fit, so a picture wider than the area, as a 16:9 camera's is on a portrait screen, shows the face larger the taller the area is. In a 1080 × 1920 iframe, a 16:9 picture shows the face about 1.9 times larger at `0.6` than it would be with the whole picture across the width, and only a little larger at `0.35`; in a shorter iframe, less. Model 2 shows its picture whole, with bars where the area has another shape. Sizes you set in `theme` are sizes before the drawing grows. Leave a minute or two between face video checkups on the same kiosk when you can: model 1's measurement works the device hard. The voice checkups use the same layout and take the same share, with their animation in place of the picture. You can also give the checkup a smaller iframe and use the rest of the screen yourself: the same rules apply inside whatever size it gets. ## Test your integration Before you swap in your live key, run through these with your test key, on the devices and screens your customers will use. Test checkups are never billed, but each counts against your test key's [monthly limits](/docs/sdks#monthly-limits). - **Your origins.** Open the page from each origin it runs on. Once your organization lists origins, a page from any other origin receives `ORIGIN_NOT_ALLOWED`. - **The camera.** Allow it when the browser asks. Refuse it once too: `onError` receives `CAMERA_UNAVAILABLE`. The checkup does not tell the person, so your page does. - **A whole face video checkup.** Press record and hold still in even light for about a minute: `onResult` receives the biomarkers. - **A voice checkup**, if you offer one. Run one to its result, and refuse the microphone once: `onError` receives `MICROPHONE_UNAVAILABLE`, with the `reason` `permissionDenied`. - **A selfie checkup**, if you offer one. Run one to its result in even light, and start one in a dim room once: the checkup asks for more light before it takes the photo. - **A body composition checkup**, if you offer one. On a phone, run one to its result, which takes a couple of minutes after the video. Send a profile without `gender` once: `onError` receives `INVALID_USER_DATA` before the camera opens. - **The next person.** Start another checkup with `nextCheckup` and another profile: it starts without loading the iframe again. If your page lets the person cancel, cancel during a measurement: `nextCheckup` drops the measurement under way, and `stop()` unloads the checkup. - **On a kiosk**, choose `mediaShare` on the real screen, with the camera where it is mounted: see [On a kiosk](#on-a-kiosk). ## Without the script A page that does not load the script speaks the [messages](/docs/sdks/web/reference#messages) itself. The checkup says `ready` once, as soon as it has loaded, so listen before you load it. Your page answers `ready` with `init`, sent to the checkup's exact origin, never to `"*"`, because it carries your key. Listen only to the iframe's own window and origin. A checkup that cannot load never says `ready`, so stop waiting after a while. The iframe needs `allow="camera; microphone; cross-origin-isolated"`. ```typescript /** A blood pressure, in mmHg. */ export type BloodPressure = { systolic: number; diastolic: number }; export type Biomarker = { type: string; name: string; value: number | string | BloodPressure; unit: string; model: string; modelVersion: string; }; /** Which recording of a voice checkup a `progress` is about. */ export type Recording = { step: number; steps: number }; /** What the checkup adds to an error: a voice error's `reason`, and a `message` for your logs. */ export type ErrorDetail = { reason?: string; message?: string }; export type CheckupEvents = { onProgress?: (state: string, progress: number, recording?: Recording) => void; onResult: (biomarkers: Biomarker[]) => void; onError: (code: string, detail?: ErrorDetail) => void; }; /** How long the checkup may take to load before `onError("LOAD_TIMEOUT")`. */ const LOAD_TIMEOUT_MS = 30_000; /** * Loads the checkup at `address` into `iframe` and runs it with `settings`. Returns a function * that stops listening. */ export function startCheckup( iframe: HTMLIFrameElement, address: string, settings: Record, events: CheckupEvents, ): () => void { const origin = new URL(address).origin; function onMessage(event: MessageEvent) { // Only the checkup in this iframe, from its own origin. if (event.source !== iframe.contentWindow || event.origin !== origin) return; const message = event.data; // Not a message of the checkup's at all: a script on its page may post to yours too. if (typeof message?.v !== "number") return; // Messages of another version are not understood here: say so once rather than wait. if (message.v !== 2) { stop(); events.onError("UNSUPPORTED_VERSION"); return; } if (message.type === "ready") { clearTimeout(loading); // To the checkup's origin only: the settings carry your key. iframe.contentWindow?.postMessage({ v: 2, type: "init", payload: settings }, origin); } else if (message.type === "progress") { const { state, progress, step, steps } = message.payload; events.onProgress?.(state, progress, step === undefined ? undefined : { step, steps }); } else if (message.type === "result") { events.onResult(message.payload.biomarkers); } else if (message.type === "error") { const { code, reason, message: text } = message.payload; events.onError(code, { reason, message: text }); } } function stop() { clearTimeout(loading); window.removeEventListener("message", onMessage); } // Listen first: `ready` comes once, as soon as the checkup has loaded. window.addEventListener("message", onMessage); // A checkup that loads after this is ignored. const loading = setTimeout(() => { stop(); events.onError("LOAD_TIMEOUT"); }, LOAD_TIMEOUT_MS); iframe.src = address; return stop; } ``` To start again with [the next person](#the-next-person), send `checkup` to the checkup's origin: ```json { "v": 2, "type": "checkup", "payload": { "user": { "age": 35, "height": 180, "weight": 78, "gender": "male" } } } ``` ## Moving from the earlier Web SDK A page built on the earlier Web SDK, at the address your YOU(th) contact gave you before, moves with a few changes: - **A new address and new keys.** Load the checkup from `https://sdk.youth-platform.io/embed.html`, and start it with a key issued in the console, not your earlier one. - **No `environment`.** The key decides whether a checkup is a test, so leave `environment` out. A page that still sends it keeps working: the checkup ignores it. - **`model` replaces `selectedProvider`.** `selectedProvider` keeps working when you send no `model`. A checkup that names neither runs model 1, or model 2 when your key offers only that, where the person's profile chose before: send `model: "auto"` to keep that. See [Choose the face video model](#choose-the-face-video-model). - **Version 2 of the messages.** The [messages](/docs/sdks/web/reference#messages) are the earlier ones, with the same types and fields, but their `v` is `2`, and each biomarker in a `result` takes YOU(th)'s catalog's code and value: see the [changelog](/docs/changelog). A page that answers `ready` with `init` and listens to `progress`, `result` and `error` keeps working once it sends and reads version 2. They have also gained fields: `ready` carries the checkup's `version`, and each biomarker its `model` and `modelVersion`. Keep your own code, or load YOU(th)'s script instead: see [Start a checkup](#start-a-checkup). - **New biomarker codes and values.** Biomarkers take the codes of YOU(th)'s catalog, such as `hrv_mean_rri` for `hrv_rri`, blood pressure is one biomarker with both numbers, and a level is its word, such as `low`, not its number. See [Results](/docs/sdks/results) and the [changelog](/docs/changelog). - **New refusals.** A page from an origin your organization does not list gets a new code, `ORIGIN_NOT_ALLOWED`. A checkup past its [monthly limit](/docs/sdks#monthly-limits) gets `SERVICE_UNAVAILABLE`. Until YOU(th) has set your limits, your key opens no checkup: a face video checkup ends with `NO_PROVIDER_AVAILABLE`, and a voice checkup with `NETWORK`. `INVALID_API_KEY`, `ORIGIN_NOT_ALLOWED` and `SERVICE_UNAVAILABLE` can also come after `initialized`: the [errors](/docs/sdks/web/reference#errors) say when. - **More time for a slow measurement.** A face video measurement that needs longer than its minute gets up to two minutes more, where it got 30 seconds. The minute starts once the face is in place, up to 90 seconds after the person presses the button, so a result can come up to four and a half minutes after the press. Leave that room in your page's own timeouts. - **Safari 18.** On a Mac the checkup now needs Safari 18 or later, as on an iPhone or iPad. # 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. | # Flutter SDK > Run the face video and voice checkups in your Flutter app: add the packages, set up Android and iOS, show a checkup. The Flutter SDK runs YOU(th)'s checkups inside your Flutter app, on Android and iOS. It comes as one Dart package per checkup, each with a ready-made screen, or the parts to build your own: your app adds the packages of the checkups it runs, and carries nothing of the others. | Package | Checkups | | ---------------------------- | ------------------------------------------------------------------------------ | | `youth_sdk_face_video` | The face video checkup on both models, which YOU(th) or your app picks between | | `youth_sdk_face_video_1` | The face video checkup on model 1 only | | `youth_sdk_face_video_2` | The face video checkup on model 2 only | | `youth_sdk_voice` | The two voice checkups, respiratory and mental fitness | | `youth_sdk_face_selfie` | The [selfie checkup](/docs/sdks/flutter/selfie) | | `youth_sdk_body_composition` | The [body composition checkup](#run-a-body-composition-checkup) | These pages describe the SDK at 0.6.0, tagged `v0.6.0`. ## What your app needs - **A key**, and checkups in an app switched on for your organization: tell your YOU(th) contact that you use the Flutter SDK. [Keys](/docs/sdks#what-you-need) says how keys work. - **Access to the packages.** They come from a private Git repository: your YOU(th) contact gives you its address and a read-only SSH key. [Add it to your app](#add-it-to-your-app) says how to use the key. - **Flutter 3.47.5 or later.** With it, the face selfie's face detection (OpenCV) targets iOS 15, which Xcode 27 requires. From April 2027, App Store Connect takes only builds made with Xcode 27. - **A real device.** The checkups measure from a live camera and microphone, so they do not run on emulators or simulators. - **A connection** when the SDK starts and when a measurement starts, and for the whole of a voice or body composition checkup. - **Portrait.** The checkup screens are laid out for a phone held upright. Lock the screen to portrait while one shows, with `SystemChrome.setPreferredOrientations`, unless your whole app is portrait. - **A plan for store review.** Reviewers look closely at apps that run a checkup: see [App Store and Google Play](/docs/sdks/app-stores). - **The wellness statement.** The results are [not for medical use](/docs/sdks#not-for-medical-use): tell the person so. ## Add it to your app On every machine that builds your app, CI included, save the SSH key your YOU(th) contact gave you, for example as `~/.ssh/youth_sdk`, keep it to yourself with `chmod 600 ~/.ssh/youth_sdk`, and give it a host name of its own in `~/.ssh/config`: ```text Host github-youth HostName github.com User git IdentityFile ~/.ssh/youth_sdk IdentitiesOnly yes ``` The name matters: without it, SSH offers GitHub your own key first, and access is refused. Use it in the packages' address, as `git@github-youth:…`. Then add the packages of your checkups to `pubspec.yaml`, each from the same address and release, by its own `path`. For example, the face video checkup with the voice checkups: ```yaml dependencies: youth_sdk_face_video: git: url: ref: v0.6.0 path: packages/youth_sdk_face_video youth_sdk_voice: git: url: ref: v0.6.0 path: packages/youth_sdk_voice ``` Check the key with `ssh -T git@github-youth`: when it works, the answer names the SDK's repository and says that shell access is not provided. Then run `flutter pub get`. The packages share the SDK's core, which each brings with it, so they are released together: give every one the same `ref`, or `flutter pub get` refuses them. Don't list `youth_sdk` itself: the packages bring it. To upgrade, change `ref` everywhere and run it again. Adding a checkup later is adding its package. The packages depend on `sentry` 9 or 10, and the face video packages on `uuid` 3 or 4: if your app uses either, take a version in that range. The SDK's error reports use a client of their own and leave your app's own error reporting untouched. ### Android - Set `minSdk` to 28 or higher in `android/app/build.gradle.kts` (`build.gradle` in older projects). The SDK runs on Android 9 (API 28) or later, on 64-bit ARM devices (`arm64-v8a`). - The packages carry every library they use, so your build needs no account, key or registry of its own. Their other dependencies are public libraries from Google's Maven repository, Maven Central and JitPack, which the SDK declares for your build. If your app declares its repositories only in `settings.gradle` (`dependencyResolutionManagement` with `FAIL_ON_PROJECT_REPOS`), list those three there. - With face video model 2 (`youth_sdk_face_video` or `youth_sdk_face_video_2`) and Android Gradle Plugin 9, which new Flutter projects use, build every library of your app against Android 36, in `android/build.gradle.kts`, before the line `project.evaluationDependsOn(":app")`. Model 2's engine builds against Android 35, and under AGP 9 a library it uses asks for 36. Apps on AGP 8 don't need it: ```kotlin subprojects { afterEvaluate { extensions.findByType(com.android.build.gradle.LibraryExtension::class.java)?.compileSdk = 36 } } ``` - With the body composition package and Android Gradle Plugin 9, add `android.uniquePackageNames=false` to `android/gradle.properties`. - With the selfie package, every machine that builds your app needs CMake and Ninja, and on a Mac with Apple silicon, Rosetta: the selfie's face detection builds native code with them. - Declare the internet, the camera (face video, selfie, body composition) and the microphone (voice) in `android/app/src/main/AndroidManifest.xml`. A new Flutter app declares the internet only in its debug and profile builds, and some packages bring none of these lines: without the internet line, a release build with face video model 2, the selfie or voice cannot reach YOU(th). ```xml ``` ### Android permissions The libraries inside the packages declare permissions of their own, which Android merges into your app's manifest. Each package adds these to what a new Flutter app declares: | Package | Permissions it adds | | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `youth_sdk_face_video_1` | `INTERNET`, `CAMERA`, `ACCESS_NETWORK_STATE` and `READ_PHONE_STATE`, from model 1's library | | `youth_sdk_face_video_2` | None | | `youth_sdk_face_video` | Those of `youth_sdk_face_video_1` | | `youth_sdk_voice` | `RECORD_AUDIO`, from its recording library | | `youth_sdk_face_selfie` | `CAMERA`, `RECORD_AUDIO`, `ACCESS_NETWORK_STATE` and `WRITE_EXTERNAL_STORAGE` (up to Android 9), from its camera library, and `READ_EXTERNAL_STORAGE`, which Android's build adds beside the write permission | | `youth_sdk_body_composition` | `CAMERA`; `INTERNET`, `ACCESS_NETWORK_STATE`, `WAKE_LOCK`, `FOREGROUND_SERVICE` and `RECEIVE_BOOT_COMPLETED`, from body composition's library and the Google libraries it uses | No package adds a Bluetooth or location permission on Android. The person is asked only for the camera and the microphone: your app asks for the camera ([Ask for the camera](#ask-for-the-camera)), and a voice checkup asks for the microphone itself. Android grants the others when the app is installed, except `READ_PHONE_STATE` and the two storage permissions, which it grants only when an app asks for them, and nothing in the SDK does. The packages also tell Google Play which devices can install your app: model 1 needs a camera and a front camera, model 2 needs OpenGL ES 3.1, and the microphone and camera permissions make Google Play expect a microphone and a camera. To remove a permission your app doesn't want, mark it in your manifest with `tools:node="remove"`, and check your merged manifest (`build/app/outputs/logs/manifest-merger-release-report.txt` in your app's build) after the next build: ```xml ``` These are safe to remove: - **`READ_PHONE_STATE`**, with face video model 1. Nothing in the SDK or its libraries asks for it or reads the phone's state, so Android never grants it, and removing it takes nothing from a checkup. - **`RECORD_AUDIO`, `WRITE_EXTERNAL_STORAGE` and `READ_EXTERNAL_STORAGE`**, with the selfie, unless your app runs a voice checkup, which needs `RECORD_AUDIO`. The selfie opens the camera without sound and takes one photo, which its camera library keeps in your app's cache: that needs neither the microphone nor storage, and the camera library asks for the microphone only when sound is on. Keep the rest. The camera, the microphone and the internet run the checkups, and the libraries declare the others for what they do: YOU(th) has not verified a checkup without them. ### iOS - Set the deployment target to iOS 15.6 or later (`platform :ios, '15.6'` in `ios/Podfile`). - Say why your app uses the camera (face video, selfie, body composition), the microphone (voice) and Bluetooth (face video model 1), in `ios/Runner/Info.plist`. Without the microphone's line, iOS closes your app when a voice checkup starts recording. The Bluetooth line is needed because model 1's iOS framework links Apple's Bluetooth framework: without it, App Store Connect flags your upload (ITMS-90683). The SDK's own code does not use Bluetooth. ```xml NSCameraUsageDescription The camera measures your heart rate and more from a short video of your face. NSMicrophoneUsageDescription The microphone records short voice samples for the voice checkups. NSBluetoothAlwaysUsageDescription This app doesn't use Bluetooth. Its face video checkup includes a component that supports Bluetooth devices. ``` ## Start it Start the SDK once, when your app starts, with your key. Import the library of each package you added: any one of them gives you `YouthSdk` and the rest of the SDK's core. ```dart import 'package:youth_sdk_face_video/youth_sdk_face_video.dart'; final state = await YouthSdk().init(apiKey: 'your test key'); if (state != YouthInitState.success) { // Show the person that the checkup is not available, and offer to try again. } ``` Show a checkup only once `init` has returned `success`. The [reference](/docs/sdks/flutter/reference#start) lists what else `init` takes: the language, the biomarkers you want, and the error reports. A key in your app suits test keys and prototypes. For an app in production, YOU(th) strongly recommends [keeping the key on your backend](#keep-your-key-on-your-backend). ## Keep your key on your backend Your key names your organization, but it is not a secret: anything shipped inside an app can be read from it. YOU(th) checks every checkup when it starts: that the key is active, that the checkup is on for it, and that its [monthly limit](/docs/sdks#monthly-limits) is not reached. Test and live keys are separate, and your admins can revoke a key and issue a new one in the console, so a copied key cannot run past the limits set for it. [Keys](/docs/sdks#what-you-need) says more. With `initWithSessionProvider`, the key stays on your backend and never ships in your app: 1. Your app asks your backend for a session, sending the body `YouthSdk().sessionRequest` gives, for example `{"delivery": "native", "platform": "ios", "sdk_version": "0.6.0"}`. 2. Your backend sends `POST https://sdk.youth-platform.io/sdk/v1/sessions` with that body and the headers `X-Api-Key: ` and `Content-Type: application/json`. YOU(th) answers `201` with a session. 3. Your backend returns the answer to your app unchanged, a refusal as well as a session, and your app gives it to the SDK. In your app: ```dart import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:youth_sdk_face_video/youth_sdk_face_video.dart'; final state = await YouthSdk().initWithSessionProvider(() async { final response = await http.post( Uri.parse('https://api.example.com/youth-session'), // your backend headers: {'Content-Type': 'application/json'}, body: jsonEncode(YouthSdk().sessionRequest), ); // A session, or YOU(th)'s refusal, which the SDK reads. An answer of your backend's own // (a user not signed in, say) is no session either. final answer = jsonDecode(response.body); if (answer is! Map) throw Exception('No YOU(th) session'); return answer; }); ``` On your backend, for example with Node.js: ```typescript // Read once at startup, so a missing key stops the server rather than every session. const youthSdkKey = process.env.YOUTH_SDK_KEY; if (!youthSdkKey) throw new Error("YOUTH_SDK_KEY is not set"); app.post("/youth-session", requireSignedInUser, async (req, res) => { const answer = await fetch("https://sdk.youth-platform.io/sdk/v1/sessions", { method: "POST", headers: { "X-Api-Key": youthSdkKey, "Content-Type": "application/json" }, body: JSON.stringify(req.body), }); res .status(answer.status) .type("application/json") .send(await answer.text()); }); ``` - **A new session each time.** The SDK calls your provider when it starts, and again whenever a session's hour is over: return a new session each time, never a stored one. - **Protect the endpoint** as you protect the rest of your API, for example for signed-in users only. Open to anyone, it hands out sessions as freely as a key in the app. - **When it fails**, YOU(th)'s refusal of your key, handed on unchanged, makes `failInvalidApiKey`, as with `init`. A provider that throws, or gives nothing within 45 seconds, makes `failConnectionError`, and any other answer that is not a session `failUnknown`. `locale`, `biomarkerScope` and `diagnostics` work as with `init`. - **Before production**, use a live key of its own, with a monthly limit close to the checkups you expect, and if a key leaks, revoke it and issue a new one. ## Ask for the camera On Android and iOS, ask the person for the camera before you show the face video checkup: without it, the checkup ends with error `1005`. For example, with the [`permission_handler`](https://pub.dev/packages/permission_handler) plugin, which needs setup of its own in your iOS `Podfile`: its page says what. ```dart import 'package:permission_handler/permission_handler.dart'; Future ensureCameraPermission() async { final status = await Permission.camera.request(); if (status.isPermanentlyDenied) { await openAppSettings(); // let the person allow it in the settings } return status.isGranted; } ``` A voice checkup asks for the microphone itself the first time the person records, unless your app has asked already, and the body composition checkup asks for the camera itself. ## Show the checkup `YouthVideoFrame` is the whole checkup screen: the camera, the guidance, the record button and the progress. Give it the person and your callbacks: ```dart YouthVideoFrame( userInfo: const UserScanInformation( age: 42, gender: Gender.female, height: 168, // centimetres weight: 61.5, // kilograms smokingState: SmokingState.nonSmoker, ), theme: const YouthVideoFrameTheme(), onState: (state) {}, onFinalResults: (biomarkers) => showResults(biomarkers), // your results screen onError: (error) => showError(error.message), ) ``` Run your app on a phone, press record and hold still in even light for about a minute. Your `showResults` then gets one `YouthDataPoint` per biomarker, such as `heart_rate` at 64 bpm. Show them on your own screens rather than printing them: they are the person's health data, and a print can end up in device logs. [Results](/docs/sdks/results) says what they hold, and [Flutter SDK examples](/docs/sdks/flutter/examples) shows whole lists and errors. The measurement is better with the person's whole profile, and some biomarkers need it: the reference says what [the person](/docs/sdks/flutter/reference#the-person) holds, and when to show a new [checkup screen](/docs/sdks/flutter/reference#the-checkup-screen). If the first run fails, check these: - `init` returns `failInvalidApiKey` until YOU(th) has switched on checkups in an app for your organization. - Error `2032` means the checkup is not on for your key, most often because no monthly limit is set yet. A face video model your key doesn't run, or whose package your app doesn't install, also ends with `2032`. - Error `1005` means your app has not [asked for the camera](#ask-for-the-camera). ## Choose the face video model The face video checkup measures with a YOU(th) model. There are two, `faceVideo1` and `faceVideo2`, and YOU(th) sets which of them your key may run, separately for your test and live keys. Name one with `model`, on `YouthVideoFrame` or `YouthVideoController`: ```dart YouthVideoFrame( userInfo: userInfo, model: YouthFaceVideoModel.faceVideo1, theme: const YouthVideoFrameTheme(), onState: (_) {}, onFinalResults: (_) {}, ) ``` | `model` | Which model runs | | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | | Left out | Model 1 when your key offers it and your app carries it, otherwise model 2 | | `YouthFaceVideoModel.faceVideo1` | Model 1 | | `YouthFaceVideoModel.faceVideo2` | Model 2 | | `YouthFaceVideoModel.auto` | The model the person's profile suits, among those your key offers: see the [rules](/docs/sdks/flutter/reference#the-face-video-model) | The person's profile chooses the model only with `auto`. A model your key does not offer is refused before the camera starts, with error `2032`, and so is a model whose package your app does not carry: `youth_sdk_face_video` carries both, `youth_sdk_face_video_1` and `youth_sdk_face_video_2` one each. `auto` chooses only among the models your key offers and your app carries. Model 2's library sends data of its own: [Data and privacy](/docs/sdks/privacy) says what. Name a model when your product relies on a biomarker only one model returns, or when results must stay comparable across a person's measurements. Every result names the model and the version that produced it: see [results](/docs/sdks/flutter/reference#results). ## Run a voice checkup `YouthVoiceFrame` is the whole voice checkup screen: the guidance, a waveform and the record button. Give it the person, which checkup to run, and your callbacks: ```dart YouthVoiceFrame( type: VoiceScanType.mental, // respiratory when left out user: const UserScanInformation(age: 42, gender: Gender.female), theme: const YouthVideoFrameTheme(), onFinalResults: (biomarkers) => save(biomarkers), onError: (error) => showError(error.message), ) ``` - **Respiratory.** The person says a long "Aahh" for six seconds, twice, each time after tapping the record button. `onFinalResults` receives one biomarker, `respiratory_symptoms_score`. - **Mental.** The person taps the record button once and describes their day for 30 seconds. `onFinalResults` receives eight biomarkers: see [Results](/docs/sdks/results#the-voice-checkups). Then the checkup uploads the recordings, checks that they are clear enough, and returns the results. - **The person.** A voice checkup uses their age and gender only. Give both: without an age, it counts the person as 35, and without a gender, as male. - **Their voice leaves the device.** The recordings are sent for analysis, with the person's year of birth and gender. Tell the person so before they record. - **When it fails**, `onError` says why, in a message for the person, and they record from the first sample again: see the [reference](/docs/sdks/flutter/reference#the-voice-checkups). - **A quiet room** makes the recordings clear: no television, music or other voices, and nothing covering the microphone. Closing the screen stops the voice checkup and releases the microphone. ## Run a body composition checkup The body composition checkup measures the person's body composition from a short video of their whole body, taken as they turn around in front of the camera. `YouthBodyCompositionFrame` shows the whole checkup: the camera, which guides the person into the frame and through the turn with spoken hints, then the upload and the wait for the analysis. A `YouthBodyCompositionController` drives it: create it when the screen opens and dispose it when it closes. ```dart final controller = YouthBodyCompositionController( consentAccepted: true, // once the person accepted your consent screen user: const UserScanInformation(age: 42, gender: Gender.female, height: 168, weight: 61.5), onFinalResults: (biomarkers) => save(biomarkers), onError: (error) => showError(error.message), onClose: () => Navigator.of(context).pop(), ); YouthBodyCompositionFrame(controller: controller) ``` Then it makes the checkup, uploads the video, and waits for the analysis, which takes **one to two minutes**: `onFinalResults` receives six biomarkers, or those of them your `biomarkerScope` keeps: see [Results](/docs/sdks/results#the-body-composition-checkup). - **The person.** It needs every one of these: `age` (whole years, for a year of birth from 1900), `gender` (`female` or `male`), `height` (50 to 250 centimetres) and `weight` (20 to 500 kilograms). A profile that lacks one, says `unspecified`, or holds a value outside these ranges ends the checkup at once with `userDataRequired`, before the camera opens and before anything leaves the device. The analysis is told the year of birth, worked out from the age, not the age itself. - **Consent first.** Show your own consent screen before the checkup and pass `consentAccepted: true` only once the person accepted; with `false` the checkup ends at once with `consentRequired`. The SDK does not record the consent. - **Their video leaves the device.** The video and the profile are sent for analysis: tell the person so before they start. [Data and privacy](/docs/sdks/privacy) says what is sent. - **When it fails**, `onError` says why, in a message for the person, and the screen offers to send the video again or take a new one when that can help: see the [reference](/docs/sdks/flutter/reference#the-body-composition-checkup). - **The whole body must be in the frame**, head to feet, and only one person in it, with the phone set down upright at waist height. The checkup is counted once its video is uploaded, against a [monthly limit](/docs/sdks#monthly-limits) of its own: ask your YOU(th) contact to set it. Until then your key does not offer the checkup, and it ends with `checkupCreateFailed` before the camera opens. ## YOU(th)'s scores Each checkup can also hand your app YOU(th)'s scores of its results: the scores every YOU(th) product shows, worked out by YOU(th)'s service for the person's age and sex. Your organization gets them always with the YOU(th) app; otherwise ask your YOU(th) contact. Give the checkup `onFinalScores` and `onScoresError`: `YouthVideoFrame`, `YouthVoiceFrame`, `YouthFaceSelfieFrame` and the four controllers take them. ```dart YouthVideoFrame( userInfo: const UserScanInformation(age: 42, gender: Gender.female), theme: const YouthVideoFrameTheme(), onState: (state) {}, onFinalResults: (biomarkers) => save(biomarkers), onFinalScores: (scores) => showScores(scores), onScoresError: (error) => showNoScores(error.code), ) ``` - **The results come first**, as without scores. Then `onFinalScores` gets the scores, or `onScoresError` says why there are none. The results stay valid either way. - **The person needs an `age`** from 18 to 120 and a `gender` of `female` or `male`. Without them, `onScoresError` gets `profileIncomplete` and nothing is asked: the SDK never assumes an age or a sex. The selfie's frame and controller take the person, `user`, for this alone. - **No connection**, no answer in time, or a refusal of YOU(th)'s service is `scoresUnavailable`. - **Without scores for your organization**, or without `onFinalScores` in your app, nothing is asked and neither callback is called. - **After the screen closed.** The scores can come once the checkup's screen is gone, as when your app moves to its results page in `onFinalResults`: check `mounted` before a `setState`. - **One checkup after another.** Each checkup's scores come after its own results, so a later checkup's results can come before an earlier one's scores. A checkup's results and scores go to the callbacks its screen had when it started. The [reference](/docs/sdks/flutter/reference#scores) lists what the scores hold. A biomarker YOU(th) does not score, such as heart age, has none. YOU(th) keeps neither the scores nor the person's profile. ## Build your own screen To lay out the face video screen yourself, drive a `YouthVideoController` and show its camera with `YouthVideoCameraView`: ```dart final controller = YouthVideoController( user: const UserScanInformation(age: 42, gender: Gender.female), onFinalResults: (biomarkers) => save(biomarkers), onError: (error) => showError(error.code), ); await controller.init(); // In your screen: YouthVideoCameraView(controller: controller); // When the person is ready, and `controller.canStart` is true: await controller.start(); // When the screen closes: controller.dispose(); ``` `state`, `warning`, `pulse` and `progress` on the controller change as the measurement runs, for your own guidance and progress. A voice screen of your own drives a `YouthVoiceController`. The reference lists both: [your own screen](/docs/sdks/flutter/reference#your-own-screen) and [your own voice screen](/docs/sdks/flutter/reference#your-own-voice-screen). ### Draw your own face guide On face video model 1 the SDK draws a frame around the face: white while it is placed well, red while it isn't. Your organization's admins can switch it off in the YOU(th) console (Look and feel, then SDK), and your app draws its own from `controller.face`, laid over the camera view at the same size: ```dart LayoutBuilder( builder: (context, constraints) => Stack( fit: StackFit.expand, children: [ YouthVideoCameraView(controller: controller), ValueListenableBuilder( valueListenable: controller.face, builder: (context, face, _) { if (face == null) return const SizedBox.shrink(); return Positioned.fromRect( rect: face.boxIn(constraints.biggest), child: MyFaceGuide(isPlaced: face.isValid), ); }, ), ], ), ) ``` `face` is null while no face is in view, and always on model 2, which draws its own face mask. While the SDK's frame is off, the person sees only your guide: keep one on screen, or they lose the cue to place their face, and a measurement that ends without results still counts once it has started. ## Make it yours Every checkup takes a `YouthVideoFrameTheme`, which sets the footer's and the record button's colours and the style of each text: see the [reference](/docs/sdks/flutter/reference#theme). What you leave out takes [your organization's settings](/docs/sdks#your-organizations-settings) from the YOU(th) console, which also give the checkups their texts and their language, and can switch off the SDK's face guide so your app [draws its own](#draw-your-own-face-guide). The ready-made screens, and `YouthVideoCameraView`, show "Powered by YOU(th)" themselves, so do not add your own. # Flutter SDK reference > Every class, state, warning and error the Flutter SDK offers your app, and its theme. What your app uses from the Flutter SDK's packages, at 0.6.0. Each package's library holds its checkup's classes and the SDK's core: `YouthSdk`, the person, results, theme and errors. The face video checkup's classes come from `package:youth_sdk_face_video/youth_sdk_face_video.dart`, the voice checkups' from `package:youth_sdk_voice/youth_sdk_voice.dart`. ## Start ```dart Future YouthSdk().init({ required String apiKey, Locale? locale, // en, de, it or es YouthBiomarkerScope? biomarkerScope, // every biomarker when left out bool? diagnostics, // false turns the SDK's error reports off }); Future YouthSdk().initWithSessionProvider( YouthSessionProvider sessionProvider, { Locale? locale, YouthBiomarkerScope? biomarkerScope, bool? diagnostics, }); typedef YouthSessionProvider = Future> Function(); Map YouthSdk().sessionRequest; // the body your backend sends void YouthSdk().setLocale(Locale locale); const YouthBiomarkerScope(List biomarkers); ``` - **`apiKey`** decides whether checkups are tests or live: see [Keys](/docs/sdks#what-you-need). `init` still accepts `env`, which is deprecated and ignored: leave it out. - **`initWithSessionProvider`** starts the SDK with sessions your backend opens with your key, so the key never ships in your app. `sessionRequest` is the JSON body your backend sends with its request: see [Keep your key on your backend](/docs/sdks/flutter#keep-your-key-on-your-backend). - **`locale`** is the language of the checkups' texts. Without it, the checkups use the language [your organization saved](/docs/sdks#your-organizations-settings), then English; a language the SDK does not have is English too. `setLocale` changes it later. - **`biomarkerScope`** limits what every checkup's `onFinalResults` receives to the biomarkers it lists. A checkup that measures none of them ends with an empty list. `onRealtimeResults` is not filtered. - **`diagnostics`** turns the [error reports](/docs/sdks/privacy#what-the-sdks-send) off when `false`. Left out, your organization's setting decides, and they are on unless it turns them off. | `YouthInitState` | What happened | | --------------------- | ---------------------------------------------------------------------------------------- | | `success` | The key was accepted: the checkups can run. | | `failInvalidApiKey` | The key was refused. Check it, and that checkups in an app are on for your organization. | | `failConnectionError` | The SDK could not reach YOU(th). Check the connection. | | `failUnknown` | Anything else. Try again later. | `YouthSdk()` is one instance for the whole app. Call `init` again to try again, or to change the key. ## The person ```dart const UserScanInformation({ int? age, // years double? weight, // kilograms double? height, // centimetres Gender gender = Gender.unspecified, // female, male, unspecified SmokingState smokingState = SmokingState.unspecified, // smoker, nonSmoker, unspecified Ethnicity ethnicity = Ethnicity.unspecified, }); ``` `Ethnicity` is `asian`, `black`, `white`, `africanAmerican`, `hispanicLatino`, `nativeAmerican` or `unspecified`. It is used only to choose the model, and only with [`model: YouthFaceVideoModel.auto`](#the-face-video-model). `ascvd_risk`, `ascvd_risk_level` and `heart_age` come together, and only when all of these hold: `gender` and `smokingState` are set, not `unspecified`; `age`, `weight` and `height` are given; the age is 18 to 80 and the BMI from weight and height 15 to 50; and the measurement gave a blood pressure, systolic 90 to 200 mmHg, and an HbA1c risk. When one is missing, all three are. The voice checkups use only `age` and `gender`, and count a person without an age as 35 and without a gender as male. The body composition checkup needs `age`, `gender`, `height` and `weight`, in [its own ranges](#the-body-composition-checkup). The checkup is for adults, 18 and over. Keep `age` from 18 to 110, `weight` from 40 to 200 kilograms and `height` from 130 to 230 centimetres. A value outside fails the face video measurement before it starts, with [error](#errors) `7008` (age), `7007` (weight) or `7012` (height), whose message names the accepted range. Check the values before you open the camera, and leave out what you do not know. ## The checkup screen ```dart const YouthVideoFrame({ required UserScanInformation userInfo, required YouthVideoFrameTheme theme, YouthFaceVideoModel? model, // see the face video model required Function(YouthVideoState) onState, required Function(List) onFinalResults, Function(YouthDataPoint)? onRealtimeResults, // values as they are measured Function(YouthVideoWarningData?)? onWarning, // null once nothing is wrong Function(YouthVideoErrorData)? onError, void Function(YouthScores)? onFinalScores, // see scores void Function(YouthScoresError)? onScoresError, }); ``` The screen reads `model` once, when it is built: for another model, or to try again after an error while it loads, show a new `YouthVideoFrame` with a new `key`. Given another `userInfo`, it starts over for that person, and a measurement under way for the person before ends without results. A measurement's results and scores go to the callbacks the screen had when it started. After `onFinalResults`, or an error during the measurement, the screen is ready for the next measurement. ## Your own screen ```dart YouthVideoController({ required UserScanInformation user, YouthFaceVideoModel? model, // see the face video model void Function(YouthVideoState)? onState, void Function(YouthVideoWarningData?)? onWarning, void Function(YouthDataPoint)? onRealtimeResults, void Function(List)? onFinalResults, void Function(YouthVideoErrorData)? onError, void Function(YouthScores)? onFinalScores, // see scores void Function(YouthScoresError)? onScoresError, }); ``` | Member | What it does | | ----------- | -------------------------------------------------------------------------------------------- | | `init()` | Loads the measurement. Call once, before `start`; after a load error, make a new controller. | | `canStart` | Whether `start` can begin a measurement now. | | `start()` | Starts a measurement. | | `stop()` | Stops the measurement under way. | | `dispose()` | Releases the camera. Call when the screen closes. | | `state` | The `YouthVideoState`, as a `ValueListenable`. | | `warning` | The current `YouthVideoWarningData`, or null. | | `pulse` | The heart rate measured so far, in beats per minute. | | `progress` | From 0 to 1 while it measures, otherwise null. | | `face` | Where the face is in the camera's image, as a `YouthFace`, or null while no face is found. | `YouthVideoCameraView(controller: controller)` shows the controller's camera. | `YouthFace` | What it holds | | ------------- | -------------------------------------------------------------------------------------------------------- | | `box` | The face's box in the camera's image, each side from 0 to 1 of the image. | | `isValid` | Whether the face is placed well enough to measure. When it isn't, `warning` says why. | | `imageSize` | The camera image's size in pixels. | | `boxIn(size)` | The box in a preview of `size`, cut as `YouthVideoCameraView` cuts the camera's image to fill its space. | `face` is null on face video model 2, which draws its own face mask. See [draw your own face guide](/docs/sdks/flutter#draw-your-own-face-guide). | `YouthVideoState` | What it means | | ----------------- | ------------------------------------------------------------------- | | `initialization` | The measurement is loading. | | `initialized` | It is ready: the person can start. | | `process` | It measures. This begins when the measurement does, not at the tap. | | `stopped` | The measurement was stopped. | | `complete` | It ended; the results follow. | `YouthVideoState` also has `disposed`, which the SDK never sends: after `dispose`, no callback arrives. ## The face video model `model` on `YouthVideoFrame` and `YouthVideoController` names the face video model to run. YOU(th) sets which models your key may run, separately for your test and live keys. | `YouthFaceVideoModel` | Which model runs | | --------------------- | -------------------------------------------------------------------------- | | Left out | Model 1 when your key offers it and your app carries it, otherwise model 2 | | `faceVideo1` | Model 1 | | `faceVideo2` | Model 2 | | `auto` | The model the person's profile suits, among those your key offers | A model your key does not offer, or whose package your app does not carry, is refused before the camera starts, with error `2032`. `auto` chooses only among the models your key offers and your app carries. 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` | `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` on `YouthVideoFrame` and `provider` on `YouthVideoController`, with `FaceVideoScanProvider`, are deprecated and stay in 0.6.0: use `model`. `provider1` stands for `faceVideo1` and `provider2` for `faceVideo2`. ## Warnings While it measures, `YouthVideoWarningData` tells the person what to change: its `state`, and a `message` in their language. | `FaceVideoWarningState` | What the person should do | | -------------------------- | ------------------------------- | | `deviceNotAligned` | Hold the phone straight. | | `faceNotCentered` | Centre their face in the frame. | | `faceTooFar` | Come closer. | | `invalidDeviceOrientation` | Hold the phone upright. | | `invalidRecognise` | Face the camera. | | `tiltedHead` | Keep their head level. | | `unevenLight` | Find even light. | `FaceVideoWarningState` has other values, which this version never sends. ## Errors `YouthVideoErrorData` carries a `code` and a `message`. The message is in the person's language and written for them, so you can show it. The code tells your app what happened and what to do. | `code` | What happened, and what to do | | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `1` | No face was in the frame for seven seconds before the measurement began. The person can start again. | | `1501` | The measurement did not start or finish in time. The person can start again. | | `3003`, `3004`, `3008`, `3009` | The measurement did not hold: the face moved or was lost, or the phone was too busy or too warm. The person can start again. | | `1001`, `1002`, `1005` | The camera cannot film at 640×480 and 30 frames a second, failed, or your app may not use it. Ask for the camera permission; otherwise try another device. | | `4`, `14` | Low Power Mode is on, or the battery is low. Ask the person to charge the phone. | | `2003` | Your organization has reached the face video's [monthly limit](/docs/sdks#monthly-limits). The checkup works again once the limit is raised, or next month. | | `2018` | The monthly limit for this key was taken away while your app ran. Ask your YOU(th) contact to set it. | | `2010` | The key was revoked. Issue another. | | `2032` | The checkup is not available for this key: no monthly limit is set, it is switched off, it is not on for apps, it is not served now, or the face video model you named is not offered for it or not in your app. Tell your YOU(th) contact. | | `17`, `2004`, `2016`, `2024`, `2025`, `2036`, `2037`, `2038`, `2042`, `3006` | The connection failed, YOU(th) could not answer, or the phone's date and time are wrong. Check both, then try again. | | `7007`, `7008`, `7012` | The profile's weight, age or height is outside what the measurement accepts, and the measurement does not start. The message names the accepted range. Correct the value, or leave it out. See [the person](#the-person). | | `8`, `7006` | The phone's system version is too old, or the device is not supported. Try another device. | | `7009` | An earlier measurement would not close, even after three tries. Offer to try again. | | `2039` | The SDK release is too old. Upgrade to the current release. | | `2002`, `2007`, `2017`, `2034` | The measurement was not authorized. Tell your YOU(th) contact the code. | | Any other, `0` included | The measurement could not load, start or finish. Offer to try again; if it keeps failing, tell your YOU(th) contact the code. | An error ends the measurement, and no result follows it. `0` arrives with the generic message, "Unknown error, try again later." [Flutter SDK examples](/docs/sdks/flutter/examples) shows errors as your app receives them. ## The voice checkups ```dart const YouthVoiceFrame({ required UserScanInformation user, required YouthVideoFrameTheme theme, VoiceScanType type = VoiceScanType.respiratory, void Function(YouthVoiceState)? onState, void Function(List)? onFinalResults, void Function(YouthVoiceErrorData)? onError, void Function(YouthScores)? onFinalScores, // see scores void Function(YouthScoresError)? onScoresError, }); ``` `VoiceScanType` is `respiratory` or `mental`: see [Run a voice checkup](/docs/sdks/flutter#run-a-voice-checkup). Given another `user`, the screen's next checkup is for that person. A checkup under way keeps the person and the callbacks its first recording started with, for its results and its scores. Of the theme, the voice checkups use the footer's and the record button's colours, `headerTextStyle` and `secondaryTextStyle`. The animation while the person records takes `progressBarColor`, and stays orange when neither your code nor your organization's settings set it: ```dart const YouthVideoFrameTheme(progressBarColor: Color(0xFF2E7D32)) ``` | `YouthVoiceState` | What it means | | ------------------ | ------------------------------------------------------------------------ | | `idle` | Ready for the first recording, and again after a result or an error. | | `recording` | It records one sample: six seconds for respiratory, 30 for mental. | | `needSecondRecord` | Respiratory only. The first sample is in: the person records the second. | | `uploading` | It uploads the recordings. | | `processing` | It checks that the recordings are clear enough. | | `waitForResults` | It waits for the results. | | `failed` | It failed; `onError` says why. | `YouthVoiceState` also has `stopped`, `success` and `disposed`, which the SDK never sends. `YouthVoiceErrorData` carries a `code`, a `YouthVoiceErrorCode`, and a `message` for the person, in their language. After any error the recordings are discarded and the person starts again from the first one. | `code` | What happened, and what to do | | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `permissionDenied` | The person has not allowed the microphone. Ask them to allow it in Settings. | | `interrupted` | A call, another app or the app going to the background stopped the recording, or something unexpected failed. | | `tooQuiet` | The voice was too quiet. Ask the person to speak louder. | | `tooShort` | The recording ended early. | | `alreadyRecording` | A recording was started while one was under way. | | `invalidFormat` | The device recorded audio the checkup cannot use. If it keeps happening, tell your YOU(th) contact. | | `failed` | The recording failed for another reason, or the microphone did not start or stop within 10 seconds. | | `checkupCreateFailed` | The checkup could not start: the connection failed, or YOU(th) refused it. A refusal means the [monthly limit](/docs/sdks#monthly-limits) is reached or not set, the key was revoked, or the voice checkups are off for this key. | | `uploadFailed` | The recordings could not be uploaded. Check the connection. | | `validationFailed` | The recordings were not clear enough: a quiet room, one long "Aahh" or 30 seconds of speech. The checkup still counts against the monthly limit, and recording again counts again. | | `resultsUnavailable` | The results did not arrive within two minutes, or YOU(th) refused to give them. Try again later. | `YouthVoiceErrorCode` also has `cancelled`, which the SDK never sends. ## Your own voice screen ```dart YouthVoiceController.respiratory({ required UserScanInformation user, void Function(YouthVoiceState)? onState, void Function(Duration elapsed, Duration total)? onProgress, // while it records void Function(List)? onFinalResults, void Function(YouthVoiceErrorData)? onError, void Function(YouthScores)? onFinalScores, // see scores void Function(YouthScoresError)? onScoresError, }); YouthVoiceController.mental({ /* the same parameters */ }); ``` In `onProgress`, `total` is six seconds for respiratory and 30 for mental, and `elapsed` starts from zero for each sample. | Member | What it does | | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | `canStartRecording` | Whether `startRecording` can record now: in `idle` and `needSecondRecord`. | | `startRecording()` | Records the next sample. After the last (the second for respiratory, the only one for mental), the upload and the analysis follow alone. | | `stopRecording()` | Stops the recording under way and discards this checkup's recordings. | | `isRecording` | Whether a sample is being recorded. | | `state` | The current `YouthVoiceState`. | | `init()` | Prepares the microphone. Optional: `startRecording` calls it. | | `dispose()` | Releases the microphone and stops the checkup. Call when the screen closes. | After `dispose`, no callback arrives and the controller cannot be used again. ## Results ```dart class YouthDataPoint { final String code; // the biomarker's code in YOU(th)'s catalog, such as "heart_rate" final String type; // deprecated: an older code for 14 biomarkers, until 1.0 final String name; // a name to show, in English final dynamic value; // an int or a double; for a status a String such as "low" final YouthBioUnitType unit; final String model; // the id of the model, such as face_video_1 or voice_1 final String modelVersion; // such as 2026.11; unknown when the model did not say final YouthConfidence? confidence; // low, medium or high; null when the value has none } ``` - **`model`** is the YOU(th) model that produced the value: `face_video_1`, `face_video_2`, `voice_1`, `face_selfie_1` or `body_composition_1`. A model's id never changes meaning. - **`modelVersion`** is a date, `YYYY.MM`, with `.2` for a second change in one month. It changes whenever anything that can move a value changes: the engine behind the model, how its output is mapped, or units. A face video model runs on the device, so its version is fixed by the SDK release you ship and changes only when you upgrade; the release notes list every change. Voice, face selfie and body composition run on YOU(th)'s service: a change is announced at least 30 days before it takes effect, and the version in the results changes on that day. The service names the version in each result; a result it did not name carries `unknown`. `YouthSdk().sdkVersion` gives the SDK's own version. - **`confidence`** is how sure the model is of the value. Face video model 1 gives one for five measurements: pulse rate (`heart_rate`), respiration rate (`breathing_rate`), SDNN (`hrv_sdnn`), mean RRI (`hrv_mean_rri`) and PRQ (`pulse_respiration_quotient`). Every other value has none, which says nothing about the measurement's quality: the [warnings](#warnings) during the measurement tell when it was taken in poor conditions. Face video model 1 delivers only the biomarkers the SDK knows, in `onFinalResults` and in `onRealtimeResults`. The raw beat-to-beat intervals are not delivered; their mean arrives as `hrv_mean_rri`. Match on `code`. `type` is the same but for 14 biomarkers, which it names by older codes until 1.0, such as `diabetes_risk` for `high_hba1c_risk`: the [changelog](/docs/changelog) lists them. Face video model 1 also sends its HbA1c estimate as `hba1c`, beside `hba1c_estimate`, and its hemoglobin in g/dL as `hemoglobin`, beside its band, `hemoglobin_index`, until 1.0: show `hba1c_estimate` and `hemoglobin_index`. `YouthBioType` lists the biomarkers, each with its `code` and its `key`, the value of `type`. The 14 take the catalog's names, such as `YouthBioType.highHba1cRisk`; their old names, such as `YouthBioType.diabetesRisk`, are the same values, and are deprecated. `YouthBioUnitType` lists the units, each with its label in `unit`, such as `bpm`. [Results](/docs/sdks/results) says what each one measures and how to read them. `onFinalResults` can receive an empty list. ```dart String show(YouthDataPoint point) => switch (point.unit) { YouthBioUnitType.status || YouthBioUnitType.num || YouthBioUnitType.unknown => '${point.value}', _ => '${point.value} ${point.unit.unit}', }; ``` ## Scores Where your organization gets YOU(th)'s scores, `onFinalScores` receives them after `onFinalResults`, or `onScoresError` says why there are none: see [YOU(th)'s scores](/docs/sdks/flutter#youths-scores). ```dart class YouthScores { final String version; // how the scores were made: it changes whenever a scoring rule does final List biomarkers; final List healthAreas; final YouthOverallScore? overall; // null when no health area that counts in it has a score } ``` | Class | What it holds | | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `YouthBiomarkerScore` | A biomarker's `code`, `blood_pressure` for both its sides; its `score`, from 0 to 1; its `band`, `strong`, `moderate` or `weak`; and its `ranges`, each band's values for this person | | `YouthScoreRange` | A band's values: from `lower`, included, to `upper`, left out, either one null where the band has no end; or its `category` for a status, such as `low`; for blood pressure, its `field`, `systolic` or `diastolic` | | `YouthHealthAreaScore` | A health area's `code`, such as `cardiovascular`, its `score` and its `band` | | `YouthOverallScore` | The overall `score` and `band`, of the health areas that count in it | A biomarker the scoring does not take, such as `heart_age`, has no score. Hemoglobin is scored as `hemoglobin_index` and HbA1c as `hba1c_estimate`. | `YouthScoresError.code` | What happened | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- | | `profileIncomplete` | The person has no `age` from 18 to 120, or no `gender` of `female` or `male`. Nothing was asked: give both for the next checkup. | | `scoresUnavailable` | No connection, no answer in time, or YOU(th)'s service refused or failed. The results stay valid. | ## Theme ```dart const YouthVideoFrameTheme({ Color? footerBgColor, Color? recordBtnColor, Color? recordBtnBorderColor, Color? progressBarColor, // the record button's progress ring, the voice recording animation TextStyle? headerTextStyle, TextStyle? headerErrorTextStyle, TextStyle? primaryTextStyle, TextStyle? secondaryTextStyle, TextStyle? warningTextStyle, }); ``` What you leave out takes [your organization's settings](/docs/sdks#your-organizations-settings), then the checkup's own look. The theme has more fields, for the [selfie checkup](/docs/sdks/flutter/selfie). ## The body composition checkup ```dart YouthBodyCompositionController({ required bool consentAccepted, // true once the person accepted your consent screen UserScanInformation user = const UserScanInformation(), // age, gender, height and weight: see below bool customUploadView = false, // true: nothing on screen after the capture, draw your own void Function(YouthBodyCompositionState)? onState, void Function(String step)? onCaptureStatus, // the capture's own steps, such as recording void Function(List)? onFinalResults, void Function(YouthBodyCompositionErrorData)? onError, void Function()? onClose, // the person left the capture, or close() was called void Function(YouthScores)? onFinalScores, // see scores void Function(YouthScoresError)? onScoresError, }); const YouthBodyCompositionFrame({ required YouthBodyCompositionController controller, YouthBodyCompositionTheme? theme, bool userReview = true, // the person reviews the video before it is sent bool skipIntroSteps = true, // Android only: starts at positioning }); ``` | `user` field | What the checkup takes | | ------------ | -------------------------------------------------- | | `age` | Whole years, from 0, for a year of birth from 1900 | | `gender` | `Gender.female` or `Gender.male` | | `height` | Centimetres, from 50 to 250 | | `weight` | Kilograms, from 20 to 500 | A profile outside these ends the checkup at once with `userDataRequired`, and so does a missing field: the checkup never guesses one. `userId` is not used. | `YouthBodyCompositionState` | What it means | | --------------------------- | --------------------------------------------------------------- | | `capturing` | The camera is on screen: the first state. | | `creatingCheckup` | It makes the checkup. | | `uploading` | It uploads the video. | | `waitForResults` | The video is uploaded and counted: the analysis measures it. | | `success` | `onFinalResults` received the results. | | `failed` | It failed; `onError` says why, and `controller.error` holds it. | | `idle` | The checkup was closed. | `YouthBodyCompositionErrorData` carries a `code`, a `YouthBodyCompositionErrorCode`, and a `message` for the person, in their language. | `code` | What happened, and what to do | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `consentRequired` | The controller was made with `consentAccepted: false`. Nothing was captured: show your consent screen, then make a new controller. | | `userDataRequired` | The profile lacks a field or holds a value outside its range. Nothing was captured: make a new controller with the profile. | | `captureFailed` | The camera screen could not record, or the video is larger than YOU(th) takes (32 MB). Take a new video. | | `checkupCreateFailed` | The checkup could not start: the connection failed, or YOU(th) refused it. A refusal means the [monthly limit](/docs/sdks#monthly-limits) is reached, or the key was revoked. A key without the checkup, its limit not set or the checkup off, ends it before the camera opens. | | `uploadFailed` | The video could not be uploaded: the connection failed, or the monthly limit is reached. The video is kept, and can be sent again. | | `analysisFailed` | The analysis could not measure the video. The checkup still counts against the monthly limit: take a new video. | | `resultsUnavailable` | The results did not arrive within four minutes, or YOU(th) refused to give them. Take a new video later. | | `failed` | Something unexpected failed. | | Member | What it does | | ------------- | ---------------------------------------------------------------------------------------------------------------------------- | | `state` | The current `YouthBodyCompositionState`, as a `ValueListenable`. | | `error` | The last error, while `failed`. | | `canReupload` | Whether the video is kept to send again: after making the checkup or the upload failed, before it was counted. | | `isUploading` | Whether the checkup is past the camera and still running: in `creatingCheckup`, `uploading` or `waitForResults`. | | `reupload()` | Sends the kept video again, to the same checkup, which is counted once; to a new one when YOU(th) no longer knows the first. | | `reset()` | Drops the video and opens the camera again. Does nothing after `consentRequired` or `userDataRequired`. | | `close()` | Ends the checkup and calls `onClose`. | | `dispose()` | Stops an upload or a wait, and deletes the video. Call when the screen closes; no callback arrives afterwards. | Without `customUploadView`, the frame's own screen shows the steps, the results' arrival, and the error with the actions that can help. `YouthBodyCompositionTheme` sets its colours and the camera screen's, as `YouthVideoFrameTheme` does for face video. # Flutter SDK examples > What a Flutter app receives from made-up checkups: whole and partial results, a scope, and errors. What a Flutter app receives from a face video checkup, with the package `youth_sdk_face_video` 0.6.0. The people and their values are made up: they show the shape of a result, not what is healthy, and no value here is a reference. `onFinalResults` receives a `List`, not JSON. Each list below writes those objects as JSON with their `code`, `name`, `value` and `unit`: `unit` is the `YouthBioUnitType`'s `unit` label. A number can arrive as an `int` or a `double`, so read it as `num`, never `int`; a `status` value is a `String`. The list comes in no set order. [Results](/docs/sdks/results) says what each field holds and how to read it. Every point also carries the fields the lists leave out: `type`, deprecated, which is its `code` but for a few older codes; `model`, `face_video_1`, the id of face video model 1; and `modelVersion`, `2026.11` in this release. Up to five of them, `heart_rate`, `breathing_rate`, `hrv_sdnn`, `hrv_mean_rri` and `pulse_respiration_quotient`, also carry a `confidence`, `low`, `medium` or `high`; the others carry none. See [results](/docs/sdks/flutter/reference#results). ## A whole profile The person: ```dart const person = UserScanInformation( age: 46, weight: 72.5, height: 178.0, gender: Gender.male, smokingState: SmokingState.nonSmoker, ethnicity: Ethnicity.white, ); ``` After a whole measurement, `onFinalResults` receives 35 biomarkers: ```json [ { "code": "heart_rate", "name": "Heart Rate", "value": 64, "unit": "bpm" }, { "code": "blood_pressure_systolic", "name": "Blood Pressure - Systolic", "value": 118, "unit": "mmHg" }, { "code": "blood_pressure_diastolic", "name": "Blood Pressure - Diastolic", "value": 76, "unit": "mmHg" }, { "code": "pulse_pressure", "name": "Pulse Pressure", "value": 42, "unit": "num" }, { "code": "mean_arterial_pressure", "name": "Mean Arterial Pressure", "value": 90, "unit": "num" }, { "code": "breathing_rate", "name": "Breathing rate", "value": 15, "unit": "bpm" }, { "code": "oxygen_saturation", "name": "Oxygen saturation", "value": 97, "unit": "%" }, { "code": "pulse_respiration_quotient", "name": "Pulse Respiratory Quotient (PRQ)", "value": 4.3, "unit": "num" }, { "code": "hrv_sdnn", "name": "HRV SDNN", "value": 48, "unit": "ms" }, { "code": "hrv_rmssd", "name": "RMSSD", "value": 36, "unit": "ms" }, { "code": "hrv_mean_rri", "name": "Mean RRi", "value": 938, "unit": "ms" }, { "code": "hrv_sd1", "name": "SD1", "value": 25, "unit": "ms" }, { "code": "hrv_sd2", "name": "SD2", "value": 63, "unit": "ms" }, { "code": "hrv_lf_hf", "name": "LF/HF", "value": 2.418, "unit": "num" }, { "code": "stress_index", "name": "Stress Index", "value": 96, "unit": "num" }, { "code": "normalized_stress_index", "name": "Normalized Stress Index", "value": 19, "unit": "%" }, { "code": "stress_level", "name": "Stress Level", "value": "normal", "unit": "status" }, { "code": "stress_response", "name": "Stress response", "value": "low", "unit": "status" }, { "code": "recovery_ability", "name": "Recovery Ability / Energy", "value": "medium", "unit": "status" }, { "code": "sns_index", "name": "SNS Index", "value": -0.4, "unit": "num" }, { "code": "pns_index", "name": "PNS index", "value": 0.3, "unit": "num" }, { "code": "hemoglobin", "name": "Hemoglobin", "value": 14.6, "unit": "g/dL" }, { "code": "hemoglobin_index", "name": "Hemoglobin Index", "value": "normal", "unit": "status" }, { "code": "hba1c", "name": "Average glucose index", "value": 5.21, "unit": "%" }, { "code": "hba1c_estimate", "name": "HbA1c Estimate", "value": 5.21, "unit": "%" }, { "code": "high_hba1c_risk", "name": "Metabolic index", "value": "low", "unit": "status" }, { "code": "high_fasting_glucose_risk", "name": "High Fasting Glucose Risk", "value": "low", "unit": "status" }, { "code": "high_total_cholesterol_risk", "name": "High Total Cholesterol Risk", "value": "medium", "unit": "status" }, { "code": "low_hemoglobin_risk", "name": "Low Hemoglobin Risk", "value": "low", "unit": "status" }, { "code": "hypertension_risk", "name": "Hypertension Risk", "value": "low", "unit": "status" }, { "code": "cardiorespiratory_wellness", "name": "Wellness Index", "value": 8, "unit": "num" }, { "code": "cardiorespiratory_wellness_level", "name": "Wellness Level", "value": "high", "unit": "status" }, { "code": "ascvd_risk", "name": "ASCVD Risk", "value": 4.0, "unit": "%" }, { "code": "ascvd_risk_level", "name": "Ascvd Risk Level", "value": "low", "unit": "status" }, { "code": "heart_age", "name": "Heart Age", "value": 44, "unit": "year" } ] ``` ## Only the biomarkers you use Started with a scope, the same measurement gives only what the scope lists: ```dart await YouthSdk().init( apiKey: apiKey, biomarkerScope: const YouthBiomarkerScope([ YouthBioType.hba1cEstimate, YouthBioType.highTotalCholesterolRisk, ]), ); ``` ```json [ { "code": "hba1c_estimate", "name": "HbA1c Estimate", "value": 5.21, "unit": "%" }, { "code": "high_total_cholesterol_risk", "name": "High Total Cholesterol Risk", "value": "medium", "unit": "status" } ] ``` A biomarker in the scope that the measurement did not give is missing from the list, as without a scope. ## Part of a profile `ascvd_risk`, `ascvd_risk_level` and `heart_age` are worked out from the profile as well as the measurement. Send the whole profile, `age`, `weight`, `height`, `gender` and `smokingState`, to get them. This person has no smoking state: ```dart const person = UserScanInformation( age: 34, weight: 58.0, height: 165.0, gender: Gender.female, ethnicity: Ethnicity.asian, ); ``` `onFinalResults` receives 32 biomarkers, without those three: ```json [ { "code": "heart_rate", "name": "Heart Rate", "value": 72, "unit": "bpm" }, { "code": "blood_pressure_systolic", "name": "Blood Pressure - Systolic", "value": 111, "unit": "mmHg" }, { "code": "blood_pressure_diastolic", "name": "Blood Pressure - Diastolic", "value": 72, "unit": "mmHg" }, { "code": "pulse_pressure", "name": "Pulse Pressure", "value": 39, "unit": "num" }, { "code": "mean_arterial_pressure", "name": "Mean Arterial Pressure", "value": 85, "unit": "num" }, { "code": "breathing_rate", "name": "Breathing rate", "value": 16, "unit": "bpm" }, { "code": "oxygen_saturation", "name": "Oxygen saturation", "value": 98, "unit": "%" }, { "code": "pulse_respiration_quotient", "name": "Pulse Respiratory Quotient (PRQ)", "value": 4.5, "unit": "num" }, { "code": "hrv_sdnn", "name": "HRV SDNN", "value": 52, "unit": "ms" }, { "code": "hrv_rmssd", "name": "RMSSD", "value": 42, "unit": "ms" }, { "code": "hrv_mean_rri", "name": "Mean RRi", "value": 833, "unit": "ms" }, { "code": "hrv_sd1", "name": "SD1", "value": 30, "unit": "ms" }, { "code": "hrv_sd2", "name": "SD2", "value": 67, "unit": "ms" }, { "code": "hrv_lf_hf", "name": "LF/HF", "value": 1.62, "unit": "num" }, { "code": "stress_index", "name": "Stress Index", "value": 85, "unit": "num" }, { "code": "normalized_stress_index", "name": "Normalized Stress Index", "value": 17, "unit": "%" }, { "code": "stress_level", "name": "Stress Level", "value": "normal", "unit": "status" }, { "code": "stress_response", "name": "Stress response", "value": "low", "unit": "status" }, { "code": "recovery_ability", "name": "Recovery Ability / Energy", "value": "high", "unit": "status" }, { "code": "sns_index", "name": "SNS Index", "value": -0.6, "unit": "num" }, { "code": "pns_index", "name": "PNS index", "value": 0.8, "unit": "num" }, { "code": "hemoglobin", "name": "Hemoglobin", "value": 13.1, "unit": "g/dL" }, { "code": "hemoglobin_index", "name": "Hemoglobin Index", "value": "normal", "unit": "status" }, { "code": "hba1c", "name": "Average glucose index", "value": 5.3, "unit": "%" }, { "code": "hba1c_estimate", "name": "HbA1c Estimate", "value": 5.3, "unit": "%" }, { "code": "high_hba1c_risk", "name": "Metabolic index", "value": "low", "unit": "status" }, { "code": "high_fasting_glucose_risk", "name": "High Fasting Glucose Risk", "value": "low", "unit": "status" }, { "code": "high_total_cholesterol_risk", "name": "High Total Cholesterol Risk", "value": "low", "unit": "status" }, { "code": "low_hemoglobin_risk", "name": "Low Hemoglobin Risk", "value": "low", "unit": "status" }, { "code": "hypertension_risk", "name": "Hypertension Risk", "value": "low", "unit": "status" }, { "code": "cardiorespiratory_wellness", "name": "Wellness Index", "value": 9, "unit": "num" }, { "code": "cardiorespiratory_wellness_level", "name": "Wellness Level", "value": "high", "unit": "status" } ] ``` ## A measurement that gave less When a measurement cannot work out some biomarkers, they are missing from the list, and the rest arrive as usual, with no error. Which ones go missing changes from one measurement to the next. Blood pressure, for example, can fail to work out while the rest succeeds: the list then has no `blood_pressure_systolic` and no `blood_pressure_diastolic`. Show what arrived. ## A measurement that failed A measurement that fails sends no result: `onFinalResults` is not called, and `onError` receives a `YouthVideoErrorData`. Here no face was in the frame for seven seconds before the measurement began: ```dart YouthVideoErrorData( code: 1, message: 'Your face was not detected for the minimum time required to start measuring. Please try again', ) ``` And here the person moved during the measurement: ```dart YouthVideoErrorData( code: 3003, message: 'Keep your face still during the measurement and follow the instructions on the screen for an accurate result.', ) ``` The `message` is in the person's language, and you can show it to them. The screen is then ready for the next measurement. ## At the monthly limit The screen loads as usual. When the person presses record, the measurement is refused: ```dart YouthVideoErrorData( code: 2003, message: "This checkup isn't available right now. Try again later or contact the app's support.", ) ``` ## A measurement that cannot load These stop the checkup before the person can start. The person did not allow the camera: ```dart YouthVideoErrorData( code: 1005, message: 'You should access the device settings and grant the application permission to use the camera.', ) ``` The phone is in Low Power Mode: ```dart YouthVideoErrorData( code: 4, message: "You should open the device settings and turn off 'Low Power Mode' or charge your device until the 'Low Power Mode' turns off.", ) ``` The measurement could not be activated: no connection, a wrong clock, or a full phone: ```dart YouthVideoErrorData( code: 2004, message: 'You should take the following actions: Check the internet connection. Set the device time correctly. Verify that the device has sufficient storage.', ) ``` ## A profile the measurement cannot accept The checkup is for adults: check the age in your app before you show it. Here the first person above was sent with an `age` of 16, and the measurement failed before it started: ```dart YouthVideoErrorData( code: 7008, message: 'The age must be between 18 and 110. Correct it, or leave it empty.', ) ``` The [reference](/docs/sdks/flutter/reference#the-person) gives the ranges, and its [errors](/docs/sdks/flutter/reference#errors) what each code means. # Flutter SDK selfie checkup > One photo of the person's face, ten skin biomarkers: show the selfie checkup in your Flutter app. The selfie checkup takes one photo of the person's face and returns up to ten skin biomarkers, such as redness, hydration, lines and perceived age. The [Flutter SDK](/docs/sdks/flutter) page says how to add and start the SDK. ## Show the checkup `YouthFaceSelfieFrame` is the whole selfie screen: the camera, a face outline that guides the person, the countdown, the photo to check, and the Retake and Submit buttons. Give it your callbacks. The selfie takes nothing of the person; give it `user`, with their age and gender, only for [YOU(th)'s scores](/docs/sdks/flutter#youths-scores): ```dart YouthFaceSelfieFrame( theme: const YouthVideoFrameTheme(), onFinalResults: (biomarkers) => save(biomarkers), onError: (error) => showError(error.message), ) ``` The camera fills the height the screen gives it, so place it where its height is bounded, such as the body of a `Scaffold`. Ask the person for the camera before you show it. 1. **The person places their face.** The SDK checks on the device that one face is in the frame, close enough, centred, looking straight ahead and in good light, and says what to change. 2. **A countdown** of three seconds starts once all is right, and the photo is taken. 3. **The person checks the photo**, and taps Submit, or Retake for a new one. 4. **The photo is analysed**, usually in 5 to 15 seconds, and `onFinalResults` receives the biomarkers. After the results, or an error, the screen is ready for a new photo. Given another `user`, it drops a photo not yet sent, so that one person's photo is never sent as another's. A photo's results and scores go to the callbacks the screen had when it was sent. - **The photo leaves the device.** The face check while the person positions themselves stays on the device, but the photo they submit is sent for analysis. Tell the person so before they take it. The SDK keeps the photo in memory only, never in a file. - **A connection** is needed from the moment the person submits the photo until the results arrive. - **Even light** makes the photo clear: facing a window or a soft light, without glasses, make-up or hair over the face. ## Results Up to ten biomarkers, each a number: eight scores from 0 to 100, higher always better, and two ages in years. [Results](/docs/sdks/results#the-selfie-checkup) lists them, as the Web SDK returns them too. ## Errors `onError` receives a `YouthFaceSelfieErrorData`: a `code`, and a `message` for the person, in their language. After any error the photo is discarded and the person takes a new one. | `code` | What happened, and what to do | | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `cameraUnavailable` | The camera could not open or take the photo. Ask for the camera permission, then open the screen again. | | `checkupCreateFailed` | The checkup could not start: the connection failed, or YOU(th) refused it. A refusal means the selfie is not on for this key, a monthly limit, or a revoked key. | | `uploadFailed` | The photo could not be uploaded. Check the connection. | | `analysisFailed` | The photo could not be analysed. Take a new one in even light. | | `resultsUnavailable` | The results did not arrive within two minutes, held no biomarker, or YOU(th) refused to give them. Try again later. | | `failed` | Anything else. Try again. | ## Your own screen To lay out the screen yourself, show a `YouthFaceSelfieDetectionFrame`, which guides the person and takes the photo, and send the photo with a `YouthFaceSelfieController`. `YouthVideoFrameTheme` has fields for the selfie's buttons and warnings. The package's own documentation lists them. # iOS > Run the checkup in a native iOS app, by loading the checkup's page in a WKWebView: not verified on devices yet. > > Preview: proposed, may change. There is no native iOS SDK. A native iOS app runs the checkup by loading YOU(th)'s checkup page in a `WKWebView`: your app sends it your key when it says `ready`, and receives the result as a message. There is no page of your own and no iframe, so the script of the [Web SDK](/docs/sdks/web) is not used: your app speaks the [messages](/docs/sdks/web/reference#messages) itself. > **Not verified yet:** YOU(th) has not verified this setup on devices. Its steps and its error > code `DELIVERY_NOT_ALLOWED` may change. Tell your YOU(th) contact before you ship it. ## What it needs - **A key and the checkup's address**, as for the [Web SDK](/docs/sdks/web#what-your-page-needs). - **Web views switched on for your organization.** Ask your YOU(th) contact: without it, the checkup ends with `DELIVERY_NOT_ALLOWED`. In a web view the checkup cannot see which app shows it, so your organization's list of origins does not limit who uses your key there. Your monthly limits and revoking the key do. - **iOS 18 or later.** A web view runs the Safari of its iOS version, and the checkup needs Safari 18. On an older iOS, do not offer the checkup. - **`NSCameraUsageDescription`** in your app's `Info.plist`, and `NSMicrophoneUsageDescription` if you run a voice checkup. - **A plan for App Review**, which looks closely at apps that run a checkup: see [App Store and Google Play](/docs/sdks/app-stores). ## Show the checkup Register a message handler named `youth` before the page loads: the checkup finds it by that name, and never says `ready` without it. Load the checkup's address with `load(_:)`, never an HTML string, because the checkup needs the headers its address sends. Your key goes in `init`, never in the address. ```swift import UIKit import WebKit final class CheckupViewController: UIViewController, WKScriptMessageHandler, WKUIDelegate { private static let checkupHost = "sdk.youth-platform.io" /// Your key, fetched from your server before this screen opens. var apiKey = "" private var webView: WKWebView! override func viewDidLoad() { super.viewDidLoad() let configuration = WKWebViewConfiguration() configuration.allowsInlineMediaPlayback = true configuration.mediaTypesRequiringUserActionForPlayback = [] configuration.userContentController.add(self, name: "youth") webView = WKWebView(frame: view.bounds, configuration: configuration) webView.autoresizingMask = [.flexibleWidth, .flexibleHeight] webView.uiDelegate = self view.addSubview(webView) webView.load(URLRequest(url: URL(string: "https://\(Self.checkupHost)/embed.html")!)) } // Messages from the checkup: only from its own page. func userContentController( _ userContentController: WKUserContentController, didReceive message: WKScriptMessage ) { guard message.frameInfo.isMainFrame, message.frameInfo.securityOrigin.host == Self.checkupHost, let body = message.body as? [String: Any], let type = body["type"] as? String else { return } let payload = body["payload"] as? [String: Any] switch type { case "ready": send(type: "init", payload: ["apiKey": apiKey]) case "result": let biomarkers = payload?["biomarkers"] as? [[String: Any]] ?? [] save(biomarkers) case "error": showError(payload?["code"] as? String) default: break // `initialized`, `progress`, and types added later. } } // Messages to the checkup. private func send(type: String, payload: [String: Any]) { let message: [String: Any] = ["v": 2, "type": type, "payload": payload] guard let data = try? JSONSerialization.data(withJSONObject: message), let json = String(data: data, encoding: .utf8) else { return } webView.evaluateJavaScript("window.postMessage(\(json), '*')") } // The camera and the microphone: only for the checkup's page. func webView( _ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void ) { decisionHandler(origin.host == Self.checkupHost ? .grant : .deny) } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) if isBeingDismissed || isMovingFromParent { webView.configuration.userContentController.removeScriptMessageHandler(forName: "youth") } } } ``` - **The settings** in `init` are the Web SDK's: the [person](/docs/sdks/web#tell-it-about-the-person), the language, the checkup. For another measurement, send `checkup` with the new settings. - **The results** arrive in `result`, as [Results](/docs/sdks/results) describes them. - **Errors.** The checkup does not show them: tell the person yourself. The [reference](/docs/sdks/web/reference#errors) lists the codes. After an error during a measurement the person can start again; if `init` fails, close the screen. - **A Close button** is yours to add: the checkup has none. ## Keep it safe - Anything built into an app can be read out of it, and no origin limits a key in a web view. Fetch the key from your server rather than building it in. - The results are health data: do not log them. - Check the host in the message handler and in the permission callback, as above. # Android > Run the checkup in a native Android app, by opening the checkup's page in a Custom Tab: not verified on devices yet. > > Preview: proposed, may change. There is no native Android SDK. A native Android app runs the checkup by opening YOU(th)'s checkup page in a Chrome Custom Tab. A Custom Tab cannot talk to your app, so the checkup hands over one message at its end, encrypted for your app, when the person taps "Return to the app". The settings, results and errors are those of the [Web SDK](/docs/sdks/web). > **Not verified yet:** YOU(th) has not verified this setup on devices. Its steps and its error > codes `DELIVERY_NOT_ALLOWED`, `RETURN_TARGET_NOT_ALLOWED` and `CANCELED` may change. Tell your > YOU(th) contact before you ship it. Do not run the checkup in a `WebView` inside your app: it cannot run there. ## What it needs - **A key and the checkup's address**, as for the [Web SDK](/docs/sdks/web#what-your-page-needs). - **The return to your app switched on for your organization, and your app's package listed.** Ask your YOU(th) contact, and give them your `applicationId`, and the exact address of any fallback your return address names. In a Custom Tab the checkup cannot see which app opened it, so your organization's list of origins does not limit who uses your key there. Your monthly limits and revoking the key do. - **Chrome 113 or later.** The browser asks the person for the camera and the microphone itself, so your app needs neither permission. - **The `androidx.browser` library.** - **A plan for Google Play review**, which looks closely at apps that run a checkup: see [App Store and Google Play](/docs/sdks/app-stores). ## Set it up Give the activity that receives the result an address of its own, in `AndroidManifest.xml`. `singleTask` closes the Custom Tab when the result comes back: ```xml ``` ## Start the checkup Make an RSA key pair for each checkup, and open the checkup with three values in the address's fragment, after `#`, never in its query: a fragment is not sent to any server. | Value | What it is | | ------------ | --------------------------------------------------------------------------------------------- | | `init` | The [settings](/docs/sdks/web/reference#settings) as JSON, with your key | | `return_url` | Where the result goes: an `intent://` address for your package, at most 500 characters | | `pk` | The pair's public key, of 2048 bits or more: base64url of its X.509 SubjectPublicKeyInfo form | ```kotlin import android.content.Context import android.net.Uri import android.util.Base64 import androidx.browser.customtabs.CustomTabsClient import androidx.browser.customtabs.CustomTabsIntent import java.security.KeyPair import java.security.KeyPairGenerator import org.json.JSONObject object YouthCheckup { /** One pair per checkup, until the person comes back. */ var keyPair: KeyPair? = null /** False when the phone has no Chrome to open the checkup in: offer no checkup then. */ fun start(context: Context, apiKey: String): Boolean { val browser = CustomTabsClient.getPackageName(context, listOf("com.android.chrome"), true) ?: return false val pair = KeyPairGenerator.getInstance("RSA").apply { initialize(2048) }.generateKeyPair() keyPair = pair val pk = Base64.encodeToString( pair.public.encoded, Base64.URL_SAFE or Base64.NO_WRAP or Base64.NO_PADDING, ) val init = JSONObject().put("apiKey", apiKey) val returnUrl = "intent://checkup/done#Intent;scheme=yourapp;package=${context.packageName};end" val url = "https://sdk.youth-platform.io/embed.html" + "#init=" + Uri.encode(init.toString()) + "&return_url=" + Uri.encode(returnUrl) + "&pk=" + Uri.encode(pk) val tab = CustomTabsIntent.Builder().build() tab.intent.setPackage(browser) tab.launchUrl(context, Uri.parse(url)) return true } } ``` This sample keeps the pair in memory. Android can stop your app while the tab is open, and the result then cannot be read, although the checkup was counted. Keep the private key where it survives that, such as encrypted storage, and delete it once you have read the result. The return address must be `intent://…#Intent;scheme=…;package=…;end`, with a lower-case scheme, a package your organization has listed, and nothing else but an optional `https` `S.browser_fallback_url` that is listed too. A plain `yourapp://` address and an `https` link are refused. When the address is refused, the checkup shows an error and sends your app nothing. ## Receive the result Your activity is opened with `yourapp://checkup/done?message=…`. The message is a JSON envelope: | Field | What it holds | | ------------------- | ----------------------------------------------------------------------------- | | `algorithm` | Always `RSA-OAEP-SHA256+A256GCM`; refuse anything else | | `encrypted_key` | An AES-256 key, encrypted with your public key (RSA-OAEP, SHA-256); base64 | | `iv` | The AES-GCM nonce, 12 bytes; base64 | | `encrypted_payload` | The message, encrypted with that key, with the 16-byte tag at its end; base64 | ```kotlin import android.util.Base64 import java.security.PrivateKey import java.security.spec.MGF1ParameterSpec import javax.crypto.Cipher import javax.crypto.spec.GCMParameterSpec import javax.crypto.spec.OAEPParameterSpec import javax.crypto.spec.PSource import javax.crypto.spec.SecretKeySpec import org.json.JSONObject fun decryptMessage(envelope: String, privateKey: PrivateKey): JSONObject { val box = JSONObject(envelope) require(box.getString("algorithm") == "RSA-OAEP-SHA256+A256GCM") { "Unknown algorithm" } val decode = { name: String -> Base64.decode(box.getString(name), Base64.DEFAULT) } val rsa = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding") // Name MGF1's hash: Android's default there is SHA-1, and decryption would fail. rsa.init( Cipher.DECRYPT_MODE, privateKey, OAEPParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT), ) val aesKey = SecretKeySpec(rsa.doFinal(decode("encrypted_key")), "AES") val aes = Cipher.getInstance("AES/GCM/NoPadding") aes.init(Cipher.DECRYPT_MODE, aesKey, GCMParameterSpec(128, decode("iv"))) return JSONObject(String(aes.doFinal(decode("encrypted_payload")), Charsets.UTF_8)) } ``` Read `intent.data?.getQueryParameter("message")` in `onCreate` and `onNewIntent`, decrypt it with the pair's private key, and delete the pair. Treat a message that does not decrypt as no message. What comes out is one [message](/docs/sdks/web/reference#messages): the final `result`, with the [biomarkers](/docs/sdks/results), or the final `error`. No `progress` is sent, and each tab runs one checkup. - **The person closed the tab** when your activity resumes without a message: treat it as a cancel. - **An error during a measurement** lets the person try again in the tab; your app receives only how it ended. A reloaded page ends with `CANCELED`. - **Anyone can open your activity's address**, with any text: accept only a message that decrypts with the pair you made for this checkup. ## Keep it safe - Anything built into an app can be read out of it, and no origin limits a key in a Custom Tab. Fetch the key from your server rather than building it in, and never log the address you open. - The results are health data: do not log them. Use a new key pair for every checkup. # Versions > How the API, the webhook and the SDKs are versioned. ## Versions The API is versioned in its path: every route starts with `/v1`. Within a version, only routes and optional fields are added; a change that could break your system comes as a new version. A webhook's `resource_url` names the version your integration is set to, today `/v1`, and an event keeps the URL it was sent with. You can also build the URL from the event's ids, with the routes on [the read API](/docs/webhooks/catch-up#the-read-api), so an event you stored still reads once you have moved to a newer version. The webhook is versioned by its event types. An event type only gains optional fields. A change that could break your receiver comes as a new event type, sent beside the old one until you have moved to it; the old one stops only after the [changelog](/docs/changelog) has announced it. While both are sent, each fact comes twice, under two `event_id`s. Handle it once: skip an event whose fact you have already handled, whichever of the two types brought it. A fact is its id and what happened: the `checkup_id` of a completed checkup, the `patient_id` of a registered member. So that new fields never break you: - Ignore fields you do not know. - Keep codes you do not know, such as a new biomarker. - Answer `2xx` to a webhook event you do not handle. ## The SDKs Each SDK has its own version, and these pages say which one they describe: Web SDK 0.8.0 and the Flutter SDK's packages 0.6.0, tagged `v0.6.0`. The Web SDK's script is pinned to its version, but its checkup is always YOU(th)'s current release, which the checkup names in its `ready` message. The Web SDK's messages carry their own version, `v`, which changes only when a message changes in a way that could break your page. In both SDKs, each result names the model that produced it and that model's version: a face video model's version is fixed by the SDK release that measured, and the service names the version of a voice or a selfie result. See [What a biomarker holds](/docs/sdks/results#what-a-biomarker-holds). Before an SDK reaches 1.0, a release can rename or remove something; each such change is announced in the [changelog](/docs/changelog), with what to do. New biomarkers, fields and codes can arrive in any release, so read [results](/docs/sdks/results#write-for-what-can-change) as that page says. Pin the Flutter packages to a release, and upgrade on purpose. A few SDK pages are marked Preview: what such a page describes is not live yet, and a change can break it until it is. Each change is listed in the [changelog](/docs/changelog). # Changelog > What has changed in the webhook, the API and the SDKs, newest first. How each part is versioned, and what can change without a new version, is on [Versions](/docs/versions). ## December 2026 - **Changed on 4 January 2027: the selfie's eye area becomes the mean of dark circles and puffiness.** In the Web SDK and the Flutter SDK, `face_skin_eye_area_condition` from the selfie checkup reads puffiness under the eyes alone today. For selfie checkups started from 4 January 2027, 00:00 UTC, it is the mean of dark circles and puffiness, as the Health Hub and the kiosk give it from 18 December 2026, and its results name `face_selfie_1` version `2027.01` instead of `2026.11`. The code, name, unit and range stay the same, and no other selfie value changes. - Values from before 4 January keep the old definition: a result names the version it was made on, so compare a person's eye area only within one version, and keep the version with each value you store. - Nothing to change in your code unless it compares eye-area values across that date. See [What changes on 4 January 2027](/docs/sdks/results#what-changes-on-4-january-2027). - **On 18 December 2026, the face-skin values of the Health Hub, the kiosk and the earlier selfie page change.** They move to the skin analysis the selfie checkup of the Web SDK and the Flutter SDK already runs on. The codes, names, units and API versions stay the same and nothing breaks, but values from before 18 December and after it are not comparable: compare a person's face-skin results only within one side of that date. - Four meanings change: `face_skin_uniformness` measures how even the skin's colour is, no longer its texture; `face_skin_pores_health` weighs enlarged pores more heavily; `face_skin_acne_index` counts breakouts, broader than acne; `face_skin_eye_area_condition` becomes the mean of dark circles and puffiness. See [What changes on 18 December 2026](/docs/sdks/results#what-changes-on-18-december-2026). - The face-skin bands in [How YOU(th) bands a value](/docs/sdks/results#how-youth-bands-a-value) change on the same day, for every channel. The SDKs' selfie values do not change that day; its eye area becomes the same mean on 4 January 2027, with `modelVersion` `2027.01` (above). - **The selfie checkup is available**, in the Web SDK and the Flutter SDK. It takes one photo of the person's face and returns up to ten skin biomarkers, such as redness, hydration and perceived age. Ask your YOU(th) contact to set its monthly limit for your key. - Web SDK: send `checkupType: "faceSelfie"`, with the checkup you already embed. See [The selfie checkup](/docs/sdks/web#the-selfie-checkup). - Flutter SDK: add `youth_sdk_face_selfie` at `v0.6.0`. See [Selfie checkup](/docs/sdks/flutter/selfie). - [Results](/docs/sdks/results#the-selfie-checkup) lists its biomarkers, and [Data and privacy](/docs/sdks/privacy#what-the-sdks-send) what it sends and how the photo is deleted: YOU(th) asks for that once its results are ready, and retries hourly until it succeeds. - **Web SDK 0.8.0: YOU(th)'s scores with each result.** Nothing changes for a page that keeps 0.7.0: the checkup asks for scores only when your page does. See [YOU(th)'s scores](/docs/sdks/web#youths-scores). - Pass `onScores` to `startCheckup`, and `onScoresError` to hear why a result came without them: `PROFILE_INCOMPLETE` when `user` gives no age from 18 to 120 or no `female` or `male` gender, `SCORES_UNAVAILABLE` when they could not be made. `onResult` comes first, as before. - A page with its own code sends `scores: true` in `init`, and finds `scores` or `scoresError` on each `result`: [the reference](/docs/sdks/web/reference#scores). - Where your organization gets scores, a result whose page asked for them waits up to 8 seconds for them. [Data and privacy](/docs/sdks/privacy#where-the-web-sdk-differs) says what is sent: the person's age and sex and the result's values, which YOU(th) does not keep. - The checkup says `0.8.0` in its `ready` message. Copy the 0.8.0 script tag from [Start a checkup](/docs/sdks/web#start-a-checkup), or install 0.8.0 from npm. ## November 2026 - **Flutter SDK 0.6.0 is released, tagged `v0.6.0`. It needs Flutter 3.47.5 or later, and removes nothing an app on 0.5.0 uses:** move `ref` to `v0.6.0` in every package you use, update Flutter if yours is older, and check the two new biomarkers below. Each biomarker now also carries its code in YOU(th)'s catalog, face video model 1 returns two more biomarkers, and the checkups can hand your app YOU(th)'s scores. No value changes, so the models' versions stay `2026.11`. - **Breaking: Flutter 3.47.5 or later.** An older Flutter no longer resolves the SDK. With it, the face selfie package builds with Xcode 27 as it is: its face detection (OpenCV) now targets iOS 15, which Xcode 27 requires. If you patched `dartcv4` in your pubspec to build with Xcode 27, you can remove the patch. - **Font weights from the console are used as set**, such as 640, instead of the nearest hundred. - **`code`.** Every `YouthDataPoint` has a `code`: the biomarker's code in YOU(th)'s catalog, the one the kiosk and the Web SDK send. `type` keeps the values it had until 1.0, and is deprecated. The two differ for 14 biomarkers. For face video: `hrv_rri` is `hrv_mean_rri`, `diabetes_risk` is `high_hba1c_risk`, `prq` is `pulse_respiration_quotient`, `baevsky_stress_index` is `stress_index`, `wellness_index` is `cardiorespiratory_wellness` and `wellness_level` is `cardiorespiratory_wellness_level`. For the mental voice checkup, the features lose `mental`: `voice_smoothness`, `voice_control`, `voice_liveliness`, `voice_energy_range`, `voice_clarity`, `voice_crispness`, `speech_rate` and `pause_duration`. Blood pressure still comes as `blood_pressure_systolic` and `blood_pressure_diastolic`. - **New names in `YouthBioType`.** Those 14 take the catalog's names, such as `YouthBioType.highHba1cRisk`. The old names, such as `YouthBioType.diabetesRisk`, still work, as the same values, and are deprecated. A `biomarkerScope` takes either. - **Two new face video biomarkers**, from model 1. `hemoglobin_index` is the hemoglobin's band for the person's sex: `very_low`, `low`, `normal` or `high`. It comes only when `gender` is `female` or `male`. `hba1c_estimate` is the HbA1c estimate, the same value as `hba1c`: in YOU(th)'s catalog, `hba1c` is a lab's value. `hemoglobin` and `hba1c` still come as before, until 1.0. Two things to check: - Code that lists every `YouthBioType` value in a `switch` must add `hemoglobinIndex` and `hba1cEstimate`: Dart refuses a `switch` that misses one. - A backend that takes only the biomarkers it knows must take these two, or skip them. - **YOU(th)'s scores, if your app wants them.** `YouthVideoFrame`, `YouthVoiceFrame`, `YouthFaceSelfieFrame` and the four controllers take `onFinalScores` and `onScoresError`. See [YOU(th)'s scores](/docs/sdks/flutter#youths-scores). - Your organization gets scores always with the YOU(th) app; otherwise ask your YOU(th) contact. Without them, or without `onFinalScores` in your app, nothing is asked and nothing changes. - `onFinalResults` always comes first, as before. Then `onFinalScores` gets the scores, or `onScoresError` says why there are none: `profileIncomplete`, when the person has no `age` from 18 to 120 or no `gender` of `female` or `male`, and nothing was asked; or `scoresUnavailable`. - They can come after the screen closed: check `mounted` before a `setState`. - The selfie's frame and controller take the person, `user`, for the scores alone. - **A screen rebuilt for another person.** - `YouthVideoFrame` given a new `userInfo` starts over for that person: a measurement under way for the person before ends without results. 0.5.0 kept measuring with the first profile. - `YouthFaceSelfieFrame` given a new `user` drops a photo not yet sent. - A checkup's results and scores go to the callbacks the screen had when the checkup started. - A new `key` for a new person works as before. - `selectedProvider` on `YouthVideoFrame` and `provider` on `YouthVideoController` stay in this release, deprecated: use `model`. - **Moving to the new names**, which you can do at any time before 1.0 removes the old: - Read `code` where you read `type`. - Replace the deprecated `YouthBioType` names: your analyzer lists them. - Show `hemoglobin_index` rather than `hemoglobin`, whose g/dL the camera estimates too roughly to show, and read `hba1c_estimate` rather than `hba1c`. - At 1.0, `type`, the old names, `hemoglobin` and the estimate's `hba1c` go. - **One code per biomarker.** The [biomarker list](/docs/data/biomarkers) names each biomarker by one code, YOU(th)'s catalog's, for every channel: the API's webhooks (in preview), the kiosk and the SDKs, such as `cardiorespiratory_wellness` and the body skin codes, prefixed `body_skin_`. Two channels keep older names for now, which the list names beside each code: the Health Hub's current webhook, until its partners move to the API's, and the Flutter SDK, as its `type`, until its 1.0. - **Breaking: Web SDK 0.7.0's biomarkers take the codes of YOU(th)'s catalog.** The checkup, which says `0.7.0` in its `ready` message, names each biomarker by its code in YOU(th)'s catalog, the code the kiosk sends too, and gives each value the catalog's shape. Match on the new codes before you use the checkup. The Flutter SDK's `type` keeps its names until its 1.0; from 0.6.0 its `code` gives these codes. See [Results](/docs/sdks/results) and the [biomarker list](/docs/data/biomarkers). - Fourteen codes change. `hrv_rri` is `hrv_mean_rri`, `wellness_index` is `cardiorespiratory_wellness`, `wellness_level` is `cardiorespiratory_wellness_level`, `diabetes_risk` is `high_hba1c_risk`, `prq` is `pulse_respiration_quotient` and `baevsky_stress_index` is `stress_index`. The mental voice checkup's features lose `mental`: `voice_smoothness`, `voice_control`, `voice_liveliness`, `voice_energy_range`, `voice_clarity`, `voice_crispness`, `speech_rate` and `pause_duration`. - Blood pressure is one biomarker, `blood_pressure`, in place of `blood_pressure_systolic` and `blood_pressure_diastolic`. Its `value` holds both numbers in mmHg, `{ "systolic": 118, "diastolic": 76 }`, and it comes only when both were measured. - A level is its word, such as `low` or `mild`, not its number. A level the measurement could not tell, `0` before, leaves its biomarker out. See [Status levels](/docs/sdks/results#status-levels). - Four units are corrected: `pulse_pressure` and `mean_arterial_pressure` are `mmHg`, and `normalized_stress_index` and `respiratory_symptoms_score` are `num`. The Flutter SDK keeps its units. - So the models' versions move: `face_video_1`, `face_video_2` and `voice_1` are `2026.11.1`. The voice checkup's version comes from YOU(th)'s service, so the Flutter SDK's voice results carry it too, with nothing else changed for them. - The hemoglobin estimate is `hemoglobin_index`, its band for the person's sex (`very_low`, `low`, `normal` or `high`), as the kiosk sends it: the camera's estimate is too rough for g/dL. It needs `gender` in `init.user`, `female` or `male`, and is left out without one. The Flutter SDK sends it from 0.6.0, and keeps `hemoglobin` until 1.0. - The HbA1c estimate is `hba1c_estimate`; `hba1c` is a lab's value. - A vital sign YOU(th)'s catalog has no code for is left out, where 0.6.0 sent it as `unknown`. Every biomarker the checkup returns is in the [biomarker list](/docs/data/biomarkers). - The helper and its script tag are 0.7.0 too. Its `Biomarker` type's `value` is `number | string | BloodPressure`, and it hands these values over, where 0.6.0 drops a result that holds one. Copy the tag from [Start a checkup](/docs/sdks/web#start-a-checkup). - The [messages](/docs/sdks/web/reference#messages) are version 2: their types and fields are version 1's, and `v` is `2`. A page on the 0.6.0 script now ends at once with `UNSUPPORTED_VERSION`, rather than receive results it would drop; load the 0.7.0 script. A page with its own code sends `v: 2` and reads the new codes and values. - The kiosk sends its face scan's HbA1c estimate as `hba1c_estimate`; `hba1c` is a lab's value. Its checkups from before keep the estimate as `hba1c`. - **Flutter SDK 0.5.0 is released, tagged `v0.5.0`.** It is the release candidates' SDK, with three changes since `v0.5.0-rc.2`. On a release candidate, move `ref` to `v0.5.0` in every package you use; the API is unchanged but for body composition's, below. Coming from 0.4.0, the entry for the release candidates below says what changes for your app, and [Add it to your app](/docs/sdks/flutter#add-it-to-your-app) how to install the packages. - The body composition checkup runs again, on YOU(th)'s service. After the video, `onFinalResults` of `YouthBodyCompositionController` receives six biomarkers, or those your `biomarkerScope` keeps, from the model `body_composition_1`, one to two minutes later, the same as the Web SDK's. See [Run a body composition checkup](/docs/sdks/flutter#run-a-body-composition-checkup) and [Results](/docs/sdks/results#the-body-composition-checkup). - It needs the person's `age`, `gender` (`female` or `male`), `height` and `weight`. A profile that lacks one or holds a value outside its range ends the checkup at once with a new code, `userDataRequired`, before the camera opens; 0.4.0 measured with made-up values instead. - It waits for its results in a new state, `waitForResults`, and can end with two new codes, `analysisFailed` and `resultsUnavailable`. See [the reference](/docs/sdks/flutter/reference#the-body-composition-checkup). - It has a [monthly limit](/docs/sdks#monthly-limits) of its own, counted once the video is uploaded. Ask your YOU(th) contact to set it: until then your key does not offer the checkup. - [Data and privacy](/docs/sdks/privacy#what-the-sdks-send) says what it sends: the person's sex, year of birth, height and weight, then the video, analysed under an id made for that checkup alone. YOU(th) keeps neither. - **Breaking:** coming from 0.4.0, `YouthBodyComposition` is gone, and with it the scan history, Future Me, deleting scans and users, and recording consent: YOU(th) keeps no body composition user. So are `YouthBodyCompositionScan`, `YouthBodyCompositionFutureMe`, `YouthFutureMePrediction`, `YouthBodyCompositionSubmitData`, and the controller's `onSubmitted`, `scanId` and `userId`. Take the results from `onFinalResults`, and keep your own record of the person's consent. - The voice checkups' recording animation takes the theme's `progressBarColor`, or your organization's theme from the console; with neither, it stays orange. See [The voice checkups](/docs/sdks/flutter/reference#the-voice-checkups). - The SDK's error reports tell the error service not to work out the device's IP address, or where the device is from it. See [Error reports](/docs/sdks/privacy#error-reports). - **The Web SDK's body composition checkup shows the body in 3D, and Future Me.** Beside the results, the person turns their body's 3D model, or sees its picture where the browser can't draw 3D. Under them, Future Me shows the same body at a lower weight the person picks, down to a healthy body mass index: three per checkup, not counted. Both stay on the checkup's screen; `onResult` and the page's messages don't change. Its texts are new keys of [`messages`](/docs/sdks/web/reference#texts). See [Body composition](/docs/sdks/web#body-composition) and [Data and privacy](/docs/sdks/privacy#where-the-web-sdk-differs). - **Web SDK 0.6.0 adds the body composition checkup.** Send `checkupType: "bodyComposition"` with the person's `age`, `gender` (`female` or `male`), `height` and `weight`: the person turns around once in front of the camera, and one to two minutes later `onResult` receives six biomarkers, `body_fat_percentage`, `body_vat_percentage`, `body_appendicular_lean_mass_percentage`, `body_skeletal_muscle_mass_percentage`, `body_mass_index` and `body_metabolic_age`, from the model `body_composition_1`. See [Body composition](/docs/sdks/web#body-composition) and [Results](/docs/sdks/results#the-body-composition-checkup). - A phone's camera gives the best results; on the web they are less accurate than in an app. - It needs Safari 18.4 or later, so iOS 18.4 on an iPhone or iPad: see [What your page needs](/docs/sdks/web#what-your-page-needs). - A profile the checkup cannot measure with ends it at once with a new code, `INVALID_USER_DATA`. Its other errors carry a `reason`, and the checkup shows them and offers to try again when a new try can help: see [Errors](/docs/sdks/web/reference#errors). Its texts are new keys of `messages`. - It has a [monthly limit](/docs/sdks#monthly-limits) of its own, counted once the video is sent. Ask your YOU(th) contact to set it: until then your key does not offer the checkup. - The helper and its script tag are 0.6.0, with the same code and the same `integrity` as 0.5.1: copy the tag from [Start a checkup](/docs/sdks/web#start-a-checkup). Nothing else changes for the other checkups. - [Data and privacy](/docs/sdks/privacy#where-the-web-sdk-differs) says what the body composition checkup sends: the person's sex, year of birth, height and weight, then the video, analysed under an id made for that checkup alone. - [Data and privacy](/docs/sdks/privacy#what-the-sdks-send) lists every connection the SDKs make and, for each, what it sends and what it never sends: the session, a face video's scan and its status, the voice and selfie checkups, and the error reports, with where the Web SDK differs. - The Web SDK's helper 0.5.1 runs the same code as 0.5.0. Its npm README says how to start and stop the checkup in a React effect, and its script tag has a new address with the same `integrity`: copy it from [Start a checkup](/docs/sdks/web#start-a-checkup). The 0.5.0 tag keeps working. - The Web SDK's helper is on npm as `@youth-healthtech/web-sdk` 0.5.0, under the MIT licence, with the same code as the script tag of that version. See [Start a checkup](/docs/sdks/web#start-a-checkup). - The SDK pages correct a few facts: - In the Web SDK, a face video measurement that needs longer than its minute gets up to two minutes more before `MEASUREMENT_TIMEOUT`, not 30 seconds. See [The messages](/docs/sdks/web/reference#messages). - In the Web SDK, a voice checkup on a device with no microphone, or with one another app holds, ends with `MEASUREMENT_FAILED` and the `reason` `failed`. `MICROPHONE_UNAVAILABLE` means only that the microphone was not allowed. `PROVIDER_INIT_FAILED` can also come when the person presses the button, and `FACE_NOT_DETECTED` comes from face video model 1 only. See [Errors](/docs/sdks/web/reference#errors). - Each face video model has a [monthly limit](/docs/sdks#monthly-limits) of its own. - Face video model 1's library checks its licence online when a scan opens, as model 2's does. In the Web SDK, on a network that blocks its licence servers, that check goes through YOU(th). See [Data and privacy](/docs/sdks/privacy). - A Web SDK page on an origin your organization does not list gets `ORIGIN_NOT_ALLOWED`, where it got `INVALID_API_KEY`. `INVALID_API_KEY` now means only a key that is unknown or revoked, or a session YOU(th) refused or ended. The checkup itself sends it, so it applies whichever version of the script your page loads. See [Errors](/docs/sdks/web/reference#errors). - The Web SDK is no longer a preview. Its checkup runs at its production address, `https://sdk.youth-platform.io`: change the address in the script tag and wherever your page calls `startCheckup` or `nextCheckup`. The script is the same file, with the same `integrity`. See [Start a checkup](/docs/sdks/web#start-a-checkup). - You build and test with your test key, `pk_test_…`, and go live by swapping it for your live key, `pk_live_…`, on the same address. Your organization's admins issue both in the YOU(th) console, under SDK, Keys, and list your pages' origins under SDK, Access. Test checkups are never billed, and count against limits of their own. Keys for the preview address do not work at the production address. See [Keys](/docs/sdks#what-you-need). - A new section, [Test your integration](/docs/sdks/web#test-your-integration), lists what to try with your test key before you go live. - A new section, [Moving from the earlier Web SDK](/docs/sdks/web#moving-from-the-earlier-web-sdk), says what changes for a page built on it: the address, the keys, no `environment`, `model` in place of `selectedProvider`, the new refusals and more time for a slow measurement. The messages keep their version, `v: 1`. - The [iOS](/docs/sdks/ios) and [Android](/docs/sdks/android) pages use the production address too. Those setups stay previews. - The Web SDK pages describe Web SDK 0.5.0. See the [Web SDK](/docs/sdks/web). - Every biomarker of a result names the model that measured it and that model's version, in two new fields, `model` and `modelVersion`, as in the Flutter SDK. Nothing else in a result changes. See [What a biomarker holds](/docs/sdks/results#what-a-biomarker-holds). - `model` names the face video model, with the Flutter SDK's values: `faceVideo1`, `faceVideo2` and `auto`. **A checkup that names no model now runs model 1**, or model 2 when your key offers only that; until now the person's profile chose. Send `model: "auto"` to keep the profile's choice. `selectedProvider` keeps working. See [Choose the face video model](/docs/sdks/web#choose-the-face-video-model). - `mediaShare` gives the picture a share of the iframe, and the panel's texts and button are drawn larger to fill the rest: for a kiosk, where the picture took nearly the whole screen and the instructions were small at its bottom edge. A checkup that does not send it looks as it did. See [On a kiosk](/docs/sdks/web#on-a-kiosk). - The script has a new address and a new `integrity`: copy the tag from [Start a checkup](/docs/sdks/web#start-a-checkup). - [`AccessCode.redeemed`](/docs/webhooks#accesscoderedeemed) and [`Access.ended`](/docs/webhooks#accessended) are sent to the endpoints that take them: a redemption within seconds, rarely up to a day later, and the end of an access once the app has ended it. - [Manage your endpoints](/docs/webhooks/endpoints) is no longer a preview: create, read and disable your webhook endpoints with the scope `webhooks:write`. An endpoint takes [`AccessCode.redeemed`](/docs/webhooks#accesscoderedeemed) and [`Access.ended`](/docs/webhooks#accessended), and the API reference lists both events. - The API's credentials and authentication, access codes with their two events, webhook deliveries and the FHIR format are no longer previews: they describe what partners build against. Where an entry below says otherwise, this one replaces it. Three parts stay previews, and say so: [Manage your endpoints](/docs/webhooks/endpoints), the `Checkup.completed` and `Patient.registered` events, and [the read API](/docs/webhooks/catch-up) for checkups and members. - **Authentication is by key, and there is no client secret.** An integration proves itself with `private_key_jwt`: it signs a short JWT with its private key for each token request, and YOU(th) stores only the public key. Replace any `client_secret` in your code with a signed `client_assertion`. See [Authentication](/docs/authentication). - **Every token request sends `scope`.** A token asked for without one is refused by the API with `401` and `invalid_token`. - A new page, [Get API credentials](/docs/credentials): an organization's administrators create an integration in the console, with a key pair the console generates or a public key they upload, download its credentials file once, and replace a key within the same integration. A key is no longer changed by creating a second integration. - There are five scopes: `access_codes:read`, `access_codes:write`, `webhooks:write`, `checkups:read` and `patients:read`. Only one of your organization's Doctors gives the two that read health data, which cover the members who consented to share with your organization. - Lists page with `after` and `next`, in place of `cursor` and `next_cursor`. The codes' CSV is one file of every matching code, not paged. See [Read the codes](/docs/access-codes/order#read-the-codes). - `POST /v1/access-code-batches` requires an `Idempotency-Key`: without one it answers `400` and `idempotency_key_required`. A `503` can carry `Retry-After`, as a `429` can. See [Errors and rate limits](/docs/errors). - Ordering access codes has a daily limit: your organization's batches ordered in one day, from 00:00 UTC, hold at most 1,000 codes together, unless your YOU(th) contact had it raised. An order past it answers `422` and `count_over_limit`, and makes nothing. See [The daily limit](/docs/access-codes/order#the-daily-limit). - A new page, [Manage your endpoints](/docs/webhooks/endpoints): your backend creates, reads and disables its webhook endpoints with the API, and an endpoint's address is HTTPS on port 443. The `Ping.check` test delivery is no longer described. - The kiosk sends its face scan's hemoglobin estimate as `hemoglobin_index`, a category, as the Health Hub does. Its checkups from before keep their `hemoglobin` in g/dL. - The Flutter SDK pages describe the SDK at 0.5.0, a release candidate tagged `v0.5.0-rc.2`. It needs Flutter 3.38.1 and Dart 3.10 or later, Android `minSdk` 28 and iOS 15.6. See the [Flutter SDK](/docs/sdks/flutter). - Already on `v0.5.0-rc.1`? Move `ref` to `v0.5.0-rc.2`; the API is unchanged. What changed: the face video error messages are rewritten for the person (see [Errors](/docs/sdks/flutter/reference#errors)), errors `7007`, `7008` and `7012` say the value can be corrected or left empty, and the pages list the Android permissions each package adds. - The SDK comes as one package per checkup: `youth_sdk_face_video` (both face video models, or `youth_sdk_face_video_1` or `youth_sdk_face_video_2` for one), `youth_sdk_voice`, `youth_sdk_face_selfie` and `youth_sdk_body_composition`. Replace `youth_sdk` in your `pubspec.yaml` with the packages of the checkups you run, each at `ref: v0.5.0-rc.2` with its own `path`, and import each package's library instead of `youth_sdk_exports.dart`. Your app then carries nothing of the checkups it does not run. See [Add it to your app](/docs/sdks/flutter#add-it-to-your-app). - A new page, [Data and privacy](/docs/sdks/privacy): what a checkup sends off the device in both SDKs, and what the checkups' own libraries send, face video model 2's crash reports and diagnostics among them. Each Flutter package has its own iOS privacy manifest. - Face video model 2 runs, with `youth_sdk_face_video` or `youth_sdk_face_video_2`. A model your key does not offer, or whose package your app does not carry, ends with error `2032` before the camera starts. See [the face video model](/docs/sdks/flutter#choose-the-face-video-model). - Android builds need no GitHub account or token any more: the packages carry every library they use. - With the face selfie package and Xcode 27, Flutter 3.47.5 or later: the selfie's face detection uses OpenCV, and an older Flutter resolves a build of it that Xcode 27 refuses. From April 2027, App Store Connect takes only builds made with Xcode 27. See [What your app needs](/docs/sdks/flutter#what-your-app-needs). - An iOS app declares `NSBluetoothAlwaysUsageDescription` in its `Info.plist`: without it, App Store Connect flags the upload (ITMS-90683). The SDK's own code does not use Bluetooth. See [iOS](/docs/sdks/flutter#ios). - There is one kind of key for both SDKs: a test key, `pk_test_…`, and a live key, `pk_live_…`. The key decides whether a checkup is a test, so `env` in `init` is deprecated and ignored: leave it out. See [What you need](/docs/sdks#what-you-need). - Each measurement is counted when it begins, against your organization's [monthly limits](/docs/sdks#monthly-limits). A refused measurement ends through `onError`: `2003` at the limit, `2010` for a revoked key, and `2032` for a checkup the key cannot use, such as one with no limit set. A voice checkup that is refused ends with `checkupCreateFailed`. - Error `1` (no face for seven seconds) ends a measurement only before it begins, and a measurement that does not start or finish in time ends with `1501`. The `process` state begins when the measurement does, not at the tap. - The checkups take [your organization's settings](/docs/sdks#your-organizations-settings) from the YOU(th) console: its theme, texts and language fill what your code leaves out. `progressBarColor` in `YouthVideoFrameTheme`, ignored before, now colours the record button's progress ring. - The SDK reports its own errors to YOU(th), never the person, a result or your key. `init(diagnostics: false)` turns the reports off: see [What leaves the device](/docs/sdks#what-leaves-the-device). - **Breaking:** `showBrand` is gone from `YouthFaceSelfieDetectionFrame`. "Powered by YOU(th)" shows unless YOU(th) hides it for your organization. - Choose the face video model with `model` on `YouthVideoFrame` and `YouthVideoController`: `faceVideo1`, `faceVideo2`, or `auto`, the one the person's profile suits among those your key offers. With none named, model 1 runs, or model 2 when your key offers only that. `selectedProvider`, the controller's `provider` and `FaceVideoScanProvider` still work, as the model they name, and are removed in 0.6.0. See [Choose the face video model](/docs/sdks/flutter#choose-the-face-video-model). - Face video model 2 gets nothing about the person, so it returns no health-risk indicators. It keeps nothing on the device and records no video. - The body composition checkup of 0.4.0 is not available in the release candidates: it ends with `checkupCreateFailed` before the camera starts. 0.5.0 runs it again, with a new API: see the entry for `v0.5.0` above. - The selfie checkup has [its own page](/docs/sdks/flutter/selfie), and is not switched on yet. - Every result names the model that produced it and that model's version, in `YouthDataPoint.model` and `modelVersion`. A face video model's version is fixed by the SDK release; voice and selfie results carry `unknown` until the service names it. See [results](/docs/sdks/flutter/reference#results). - Face video model 1 gives a `confidence`, `low`, `medium` or `high`, for five measurements: `heart_rate`, `breathing_rate`, `hrv_sdnn`, `hrv_rri` and `prq`. Other values carry none. - Face video model 1 no longer delivers the raw beat-to-beat intervals, which arrived with the type `unknown`. Their mean stays, as `hrv_rri`. - `initWithSessionProvider` starts the SDK with sessions your backend opens, so your key never ships in your app. YOU(th) recommends it for apps in production; `init` with a key stays for test keys and prototypes. See [Keep your key on your backend](/docs/sdks/flutter#keep-your-key-on-your-backend). - Your organization can switch off the face guide the SDK draws over the camera, and `YouthVideoController.face` says where the face is and whether it is placed well, so your app can draw its own. See [Draw your own face guide](/docs/sdks/flutter#draw-your-own-face-guide). - `YouthSdk().sdkVersion` gives the SDK's version. - A new `init` keeps the current session until the new one is open: only a rejected key ends it. A controller made before `init` works, in English until `init` sets the language. - Errors `7007`, `7008` and `7012` (a weight, age or height the face video model does not take) say the range it takes, and that the value can be corrected or left empty. - Stopping a voice checkup stops what it was sending. A microphone that does not start or stop within ten seconds fails the recording, and a checkup still waiting for its results two minutes after sending them ends with `resultsUnavailable`, so the screen never stays loading. - Error texts are written for the person, in their language, and the SDK writes nothing to the device log. The face video error messages carry no licence, sales or setup jargon: a checkup your app can't run says it isn't available and points to your app's support. See [Errors](/docs/sdks/flutter/reference#errors). Hints and errors meet WCAG AA contrast. - Face video model 1 no longer brings a product analytics library into Android builds. - A new section, [Android permissions](/docs/sdks/flutter#android-permissions), lists the permissions each package adds to your app. Declare `INTERNET` in your app's manifest yourself: a new Flutter app declares it only in debug and profile builds, so a release build without it cannot reach YOU(th). Model 1's `READ_PHONE_STATE` can be removed with `tools:node="remove"`. - What your `pubspec.yaml` resolves changes: the SDK adds `sentry` (from 9.0.0, before 11.0.0), takes `uuid` 3 or 4, and `record` 6.2.1, or 7 on Flutter 3.44 and later. Face video model 2's engine is pinned to one version: an app that depends on it too takes the same one. - The SDK pages are shorter, and most are no longer previews: the [overview](/docs/sdks), [Results](/docs/sdks/results), [App Store and Google Play](/docs/sdks/app-stores), the Flutter SDK's pages and the [Web SDK reference](/docs/sdks/web/reference). The [Web SDK](/docs/sdks/web) stays a preview until its production address opens, and so do the selfie checkup and the [iOS](/docs/sdks/ios) and [Android](/docs/sdks/android) setups. - The [SDK quickstart](/docs/sdks/quickstart) is shorter: the steps from a key to a first result, and links for the rest. - The overview holds what both SDKs share: keys, monthly limits, your organization's settings, what leaves the device, and the wellness statement. - [Results](/docs/sdks/results#the-biomarkers) lists every biomarker the SDKs return. `parasympathetic_activity` and `stress_index_scaled` come from the Web SDK only. - The [iOS](/docs/sdks/ios) and [Android](/docs/sdks/android) pages describe new setups, which replace a page of your own in a web view or a Custom Tab. An iOS app loads the checkup's page in a `WKWebView` and exchanges messages with it. An Android app opens it in a Custom Tab and receives one encrypted message when the person returns. YOU(th) switches each on for your organization, and has not verified them on devices yet. - The API and its tokens have their hosts: `api.youth-platform.io` and `https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token`, in place of the `example.com` placeholders. The signed example on [Verify a delivery](/docs/webhooks/verify#try-it) has a new signature, since its body names the host. - Access codes are described, as a preview: [order a batch](/docs/access-codes/order), hand a code to each customer, and [end an access](/docs/access-codes/end-access) with one call. Two events come with them, `AccessCode.redeemed` and `Access.ended`; they name a code and never a person. See [Sell access with codes](/docs/access-codes). - A [sandbox](/docs/sandbox) is described: a second organization of yours, on the same hosts, for your own testers. - Your administrators create integrations themselves in the console, and an integration has [scopes](/docs/credentials#scopes). - A refusal's body is a Problem document with a stable `code`, and a `POST` that creates something takes an `Idempotency-Key`: see [Errors and rate limits](/docs/errors). - An endpoint that keeps answering `404` or `410` is paused: see [When an address is gone](/docs/webhooks/retries#when-an-address-is-gone). - [Use the docs with AI](/docs/ai#prompts-to-start-from) has prompts for selling access with codes, for reconciling, for a sandbox test and for a review of your integration. - The Web SDK pages start the checkup with your key alone. Your organization's settings saved in YOU(th)'s console give it the rest, and each change saved there reaches your pages; a field you set in `init` wins over them. See [Make it yours](/docs/sdks/web#make-it-yours). - The new Web SDK takes no `environment`, and ignores it if sent. Its keys are `pk_test_…` (test: never billed, with its own limits) and `pk_live_…` (live: billed on production). Today the page serves test keys; when the production address opens, you get a new pair of keys and its address, and going live is swapping `pk_test_` for `pk_live_`. The Web SDK pages now cover the new SDK only. Partners on the address their YOU(th) contact gave them before keep their current setup until we move them. - The Flutter SDK pages describe `youth_sdk` 0.3.2. To upgrade, change `ref` to `v0.3.2`; it needs Flutter 3.38.1 and Dart 3.10 or later. - 0.3.1 adds the selfie checkup: `YouthFaceSelfieFrame`, or `YouthFaceSelfieDetectionFrame` with `YouthFaceSelfieController` for your own screen. The person takes one photo of their face, which is sent for analysis, and it returns up to ten `face_skin_*` biomarkers: see the [selfie checkup](/docs/sdks/flutter/selfie). It uses the camera your app already asks for. - `YouthVideoFrameTheme` gains `primaryBtnColor`, `secondaryBtnColor`, `primaryBtnTextStyle`, `secondaryBtnTextStyle` and `selfieWarningTextStyle`, for the selfie's screen. They are optional, so nothing changes for the other checkups. - The biomarker list names the Flutter SDK among the channels that send the ten `face_skin_*` biomarkers. - The [Flutter SDK reference](/docs/sdks/flutter/reference#errors) corrects what `1501`, `7005` and `7009` mean, and adds `0` and `2016`. A failed measurement can also end with an empty list and no error. Android merges more permissions into your app than the [Flutter SDK](/docs/sdks/flutter#android) page said. - The Web SDK pages start with YOU(th)'s script tag, `web-sdk` 0.4.0, pinned to its integrity: it defines `YouthSDK.startCheckup` and `YouthSDK.nextCheckup`. The function to copy stays, for pages that speak the messages themselves. - The Web SDK pages describe Web SDK 0.4.0, at its preview address, for test keys. Once your organization has a list of origins, the checkup refuses any other origin with `INVALID_API_KEY`, so tell your YOU(th) contact your pages' origins. It adds: - The voice checkups: `checkupType: "voice"` and `voiceType`. The iframe must also allow the microphone: see [The voice checkups](/docs/sdks/web#the-voice-checkups). - `diagnostics: false` turns the checkup's error reports off. - It needs Safari 18 or later, so iOS 18 or later on an iPhone or iPad, or Chrome or Edge 113 or later: see [What your page needs](/docs/sdks/web#what-your-page-needs). The [iOS](/docs/sdks/ios) page asked for iOS 15.2 before. - `ready` carries the checkup's `version`, and `error` a `message` for your logs. - A face video measurement that needs longer than its minute says so with the progress state `extraTime`, for up to 30 seconds, before `MEASUREMENT_TIMEOUT`; its text is the new key `basicVideoExtraTime`. If your page switches over the states, handle it. - Each checkup has a [monthly limit](/docs/sdks#monthly-limits); past it, the checkup sends `SERVICE_UNAVAILABLE`. - A new page, [Flutter SDK examples](/docs/sdks/flutter/examples), shows what an app receives from made-up checkups, including a partial result and errors. - [Results](/docs/sdks/results#status-levels) names the levels a `status` biomarker takes. The Web SDK sends them too, as the level's number, with `0` for unknown: if your page dropped status biomarkers or showed the number, read it as a level. Results also gives the bands YOU(th) puts values in. - The [Flutter SDK reference](/docs/sdks/flutter/reference#errors) groups the face video error codes by what to do, and gives the ages, weights and heights the measurement accepts. - A new page, [App Store and Google Play](/docs/sdks/app-stores), says what to prepare for store review. - The SDK pages no longer say the results are not to discuss with a doctor. Remind the person to consult a healthcare professional instead, as both stores ask. If your app shows the old words, change them: see [Say what your app is](/docs/sdks/app-stores#say-what-your-app-is). ## October 2026 - The Flutter SDK pages describe `youth_sdk` 0.2.6. To upgrade, change `ref` to `v0.2.6`. - 0.2.4 adds the mental voice checkup: `YouthVoiceFrame(type: VoiceScanType.mental)`, or `YouthVoiceController.mental` for your own screen. The person speaks for 30 seconds, and the checkup returns eight biomarkers, in the new units `octaves`, `dB`, `kHz²`, `words/min` and `sec`: if your app switches on `YouthBioUnitType` or `YouthBioType`, give it a default. See [Results](/docs/sdks/results#the-voice-checkups). - 0.2.5 adds `biomarkerScope` to `YouthSdk().init`: a `YouthBiomarkerScope` of `YouthBioType`s that every checkup's final results are limited to. See [the reference](/docs/sdks/flutter/reference#start). - 0.2.6 renames two of the mental checkup's biomarkers, to `voice_speech_mental_rate` and `voice_pause_mental_duration`. - A webhook carries ids only: the setting for a delivery that carries the resource, and its `resource` field, are gone. Read the checkup's bundle or the member's `Patient` from `resource_url`. See [What a delivery carries](/docs/webhooks#what-a-delivery-carries). - `occurred_at` is when YOU(th) recorded the event, at once or a moment after what it reports: for `Checkup.completed`, the checkup's completion, which `completed_from` filters on and the `DiagnosticReport`'s `issued` holds; its `effectiveDateTime` is now when the member took the checkup, not when it was completed. Catch up from a little before the newest `occurred_at` you have. See [List what you missed](/docs/webhooks/catch-up#list-what-you-missed). - A webhook's `resource_url` names the read-API version your integration is set to, today `/v1`; you can also build it from the event's ids. While a new event type is sent beside the old one, handle each fact once, by its `checkup_id` or `patient_id` and what happened. See [Versions](/docs/versions). - YOU(th)'s code and identifier systems have their final names, under `https://api.youth-platform.io/fhir/codes/` and `https://api.youth-platform.io/fhir/identifiers/`, in place of the `example.com` placeholders. Every checkup bundle carries the `Patient`. See [Code and identifier systems](/docs/data/fhir#code-and-identifier-systems). - The webhook envelope has no `event_version`. An event type only gains optional fields; a change that could break your receiver comes as a new event type, sent beside the old one. See [Versions](/docs/versions). - The FHIR reads sit under the resource they read: `GET /v1/checkups/{checkup_id}/fhir` for a checkup's bundle and `GET /v1/patients/{patient_id}/fhir` for a member's `Patient`, in place of `/v1/fhir/checkups/…` and `/v1/fhir/Patient/…`. A webhook's `resource_url` names the new routes. See [the read API](/docs/webhooks/catch-up#the-read-api). - Webhook deliveries are signed as [Standard Webhooks](https://www.standardwebhooks.com/) describes, so its libraries verify them: the headers `webhook-id`, `webhook-timestamp` and `webhook-signature` replace the preview's `X-youth-*` headers, the signature is `v1,` over `..`, signing secrets start with `whsec_`, and the body is sent as `application/json`. Two unsigned headers, `youth-event-type` and `youth-delivery-attempt`, name the event and count the attempts. The body itself does not change. See [Verify a delivery](/docs/webhooks/verify). - The biomarker list names the channels that send each biomarker, and the code a channel uses where it differs: the kiosk sends 18 biomarkers under other codes for now, such as `hrv_mean_rri` for `hrv_rri`. It adds the biomarkers it left out: the Health Hub's `hemoglobin_index`, and those the kiosk and the SDKs send, such as `mean_arterial_pressure` and `pulse_pressure`. `blood_pressure_systolic` and `blood_pressure_diastolic`, which the SDKs send, are deprecated in favour of `blood_pressure`, one Observation with both sides. - The Flutter SDK pages describe `youth_sdk` 0.2.3. To upgrade, change `ref` to `v0.2.3`. - 0.2.2 added the voice checkup, which returns `respiratory_symptoms_score`. It needs Flutter 3.44 or later. It also adds the microphone permission to every app's Android manifest, even an app that never runs the voice checkup, and iOS apps need its `NSMicrophoneUsageDescription`: update your store privacy answers. - 0.2.3 delivers a `status` value as a `String`, such as `low`; 0.2.2 delivered a Dart enum. If your app read it with `toString()`, that still works; if it read the enum's `name`, read the value itself instead. - 0.2.3 names the blood pressure biomarkers as they should be shown, and exports `YouthVoiceController`, `YouthVoiceErrorData` and `YouthBioUnitType`. - The webhook, the read API and FHIR, as these docs describe them, are published as a preview. - The SDK pages describe the Web SDK 0.1.3 and the Flutter SDK 0.1.6: the face video checkup, its settings, errors and results. There is no native iOS or Android SDK yet: the iOS page and a new Android page describe an experimental setup with the Web SDK meanwhile. - Six biomarkers have clearer names: `baevsky_stress_index` is the Stress index, `pns_index` the Rest response, `sns_index` the Alert response, `hrv_rmssd` the Instant heart rate variability, `hrv_sdnn` the Total heart rate variability and `hrv_rri` the Average heartbeats interval. Their codes and values do not change. - The biomarker list takes the names and descriptions the YOU(th) app shows: for example, `face_skin_wrinkles_index` is the Lines index. Codes and values do not change. # Errors and rate limits > What a refused request answers, how to repeat one safely, and when to wait and try again. ## Errors A refused request answers one of these statuses: | Status | Means | | ------ | ------------------------------------------------------------------------------------------------- | | `400` | The request lacks something every such request needs, such as a required `Idempotency-Key` | | `401` | No token, or an expired or unknown one: get a new one, see [Authentication](/docs/authentication) | | `403` | The token is valid, but lacks the route's scope | | `404` | Nothing of yours at this address: an unknown id, or another organization's | | `409` | The request does not fit the resource's state, or repeats an `Idempotency-Key` with another body | | `422` | A field is missing or not valid | | `429` | Too many requests: wait for `Retry-After` seconds | | `500` | The API failed: quote the `request_id` when you ask for help | | `503` | Not now: wait for `Retry-After` seconds, then send the same request again | The body is a Problem document (RFC 9457), sent as `application/problem+json`: ```json { "type": "about:blank", "title": "Forbidden", "status": 403, "code": "insufficient_scope", "request_id": "0193b2f4-6c1d-7a3e-9b52-8f3c1d2e4b5a" } ``` | Field | Means | | ------------ | ------------------------------------------------------------------------------ | | `code` | What happened, in snake_case. Codes are stable: branch on them, not on `title` | | `request_id` | The request, as YOU(th)'s logs name it. Quote it when you ask for help | | `code` | Status | Means | | -------------------------- | ------ | --------------------------------------------------------------------- | | `idempotency_key_required` | `400` | The route requires an `Idempotency-Key`, and the request has none | | `idempotency_key_invalid` | `400` | The `Idempotency-Key` is empty, or longer than 255 characters | | `invalid_token` | `401` | No token, an expired or unknown one, or one asked for without `scope` | | `integration_revoked` | `401` | The integration was revoked: use another one's credentials | | `insufficient_scope` | `403` | The token lacks the route's scope | | `not_found` | `404` | Nothing of yours at this address | | `idempotency_conflict` | `409` | The `Idempotency-Key` was used with another body | | `idempotency_in_progress` | `409` | A request with the `Idempotency-Key` runs now: wait for `Retry-After` | | `internal_error` | `500` | The API failed | | `identity_unavailable` | `503` | The API cannot check the token now: wait for `Retry-After` | | `timed_out` | `503` | The API gave up on the request: wait for `Retry-After` | | `temporarily_unavailable` | `503` | The API can't finish the request now: wait for `Retry-After` | A route's own page lists the codes only it answers. New codes can appear: treat one you do not know by its status. ## Repeat a request safely Send an `Idempotency-Key` header of your own, a UUID for example, of at most 255 characters, with a `POST` that creates something. Within 24 hours of the latest attempt, the same key with the same body answers what the first request answered, and creates nothing new. Use it whenever you try again after a timeout. A request that was refused or failed keeps nothing: the same key and body try again, and go on with what it left half done. | Request | Answers | | --------------------------------------------------------------------- | ----------------------------------------------- | | The same key, the same body | What the first request did | | The same key, another body | `409`, `idempotency_conflict` | | The same key, while a request with it runs | `409`, `idempotency_in_progress`, `Retry-After` | | No key, on [`POST /v1/access-code-batches`](/docs/access-codes/order) | `400`, `idempotency_key_required` | Ordering a batch requires the key, because a repeat without one would order twice. Every other `POST` that creates something accepts it. ## Rate limits A client that sends too many requests gets `429`, and a request the API cannot serve now gets `503`. When the answer carries a `Retry-After` header, wait that many seconds, then try again; without one, wait a few seconds, and longer after each failure. Go by the status of a `429`, whatever its body. Ordering access codes also has a daily limit: your organization's batches ordered in one day, from 00:00 UTC, hold at most 1,000 codes together, unless your YOU(th) contact had it raised. An order past it answers `422` `count_over_limit` and makes nothing: see [The daily limit](/docs/access-codes/order#the-daily-limit). A CSV file of access codes holds at most 50,000. A list longer than that answers `422` `too_many_codes`: filter it by `batch_id` or a time range, or read it a page at a time as JSON. See [Read the codes](/docs/access-codes/order#read-the-codes). # Use the docs with AI > Hand a page or the whole docs to an assistant or a coding agent, with prompts to start from. These docs are written to be read by people and by assistants alike. Hand an assistant or a coding agent what it needs, and ask it to build your integration from there. ## One page Every page has the same row under its title: | Action | Does | | --------------- | --------------------------------------------------------------------------- | | Copy page | Puts the page on your clipboard as Markdown, to paste into any assistant | | Markdown | Opens the page as Markdown: its address is the page's with `.md` at the end | | Open in ChatGPT | Starts a chat that asks ChatGPT to read the page's Markdown | | Open in Claude | Starts a chat that asks Claude to read the page's Markdown | ## The whole docs | File | Holds | | ---------------------------------- | ---------------------------------------------------------------------- | | [`/llms.txt`](/llms.txt) | An index of every page's Markdown, by section, as llmstxt.org proposes | | [`/llms-full.txt`](/llms-full.txt) | Every page in one Markdown file | Give a coding agent `/llms-full.txt` for the whole picture. ## Prompts to start from In each prompt, put this site's address in place of ``, and your stack in place of the other placeholder. The prompts name the variables the docs' samples use: `YOUTH_CLIENT_ID`, `YOUTH_KEY_ID` and `YOUTH_PRIVATE_KEY` for your [integration](/docs/credentials), and `YOUTH_WEBHOOK_SECRET` for your endpoint's signing secret. ### Receive checkups > **Preview:** the checkup events and the read API are not available yet. ```text Read /llms-full.txt, the docs of the YOU(th) webhook and read API. Build a webhook receiver for my backend in that: - verifies each delivery's Standard Webhooks signature (webhook-id, webhook-timestamp, webhook-signature) with the secret in YOUTH_WEBHOOK_SECRET, over the raw body, and refuses one older than five minutes; - skips an event_id it has already handled, and answers 200 within ten seconds; - for Checkup.completed, reads the bundle at resource_url with an access token for the scope checkups:read, reusing the token until it expires; - gets that token as the Authentication page describes: OAuth2 client credentials with private_key_jwt, a client assertion signed for each token request with the key in YOUTH_PRIVATE_KEY (its id in YOUTH_KEY_ID, the client id in YOUTH_CLIENT_ID), and scope in every request. There is no client secret. Write tests for each of these, and keep every secret and key out of the code. ``` ### Sell access with codes ```text Read /llms-full.txt, the docs of the YOU(th) API and webhook. I sell YOU(th) access to my customers with access codes. In , build: 1. A webhook receiver that verifies each delivery's Standard Webhooks signature with the secret in YOUTH_WEBHOOK_SECRET, over the raw body, refuses one older than five minutes, skips an event_id it has already handled, and answers 200 within ten seconds. 2. For AccessCode.redeemed: store access_code_id and occurred_at as the activation my billing starts from. For Access.ended: mark that code as ended, with its reason. 3. A function endAccess(accessCodeId, endsAt) that calls PUT /v1/access-codes/{access_code_id}/access with an access token for the scope access_codes:write, reuses the token until it expires, and treats a repeated call as success. 4. The token client the Authentication page describes: OAuth2 client credentials with private_key_jwt, a client assertion signed for each token request with the key in YOUTH_PRIVATE_KEY (its id in YOUTH_KEY_ID, the client id in YOUTH_CLIENT_ID), and scope in every request. There is no client secret. Take nothing about a person from YOU(th): the code's id is the only key. Write tests for each of these, and keep every secret and key out of the code. ``` ### Reconcile and catch up ```text Read /docs/access-codes/reconcile.md and /docs/errors.md. In , write a job that runs once a day and: - lists GET /v1/access-codes with redeemed_from set to one hour before the newest activation I have stored, passing each page's next as after until a page has none; - stores every redeemed code I do not have yet, exactly as the webhook receiver would; - lists the same route with status=ended and ended_from set to the same time, and marks each code I still hold as active as ended; - reports each code that is cancelled in my system and redeemed at YOU(th) with no access.ends_at, and sends its end again; - waits for Retry-After on a 429 or a 503, and stops with the request_id on any other refusal. Write tests with a fake of the API. ``` ### Test in the sandbox ```text Read /docs/sandbox.md and /docs/access-codes/order.md. Write an end-to-end test for my integration that runs against my YOU(th) sandbox organization, with the sandbox integration in YOUTH_CLIENT_ID, YOUTH_KEY_ID and YOUTH_PRIVATE_KEY: - check that GET /v1/organization names the organization in YOUTH_SANDBOX_ORGANIZATION, and stop if it does not; - order a batch of 3 codes with an Idempotency-Key, and wait until it is ready; - print one code's redeem_url for a tester to redeem in the YOU(th) app, and wait until my receiver has stored AccessCode.redeemed for it; - end its access with ends_at left out, and wait for Access.ended. Never run it with live credentials. ``` ### Review what you built ```text Read /llms-full.txt. Review my YOU(th) integration in this repository against it, and list every place where it: parses the body before verifying the signature, handles an event twice, does work before answering the delivery, gets a token for every request, asks for a token without scope, reuses a client assertion, logs a secret, a private key, a token or an access code, or fails on a field, event type or error code it does not know. For each, name the file and the page of the docs it goes against. ``` Check an assistant's work against these pages, and against your [sandbox](/docs/sandbox).