Age estimation v2

Once you've set up your organisation account on the Yoti Hub, you’re ready to start integrating with the Age estimation and anti-spoofing API.

Before you start
Please have a read of our image requirements.

Face Capture

For optimal results, Yoti provides and recommends to use the Yoti Face Capture modules, which are designed to capture optimal images meeting the requirements of the API. This is available as a Native package, and Web implementation.

Strongly recommend
Get better results by using our Face capture module.

Integration

Install the SDK

After completing the Yoti onboarding, you will need to complete authentication for the API by using the Yoti SDK to simplify the process. The Yoti SDKs are available via popular dependency management systems.

Javascript
Java
PHP
Python
C#
Go
Ruby
Copy

Create a request

You can create three types of requests using the API:

EndpointDescription
https://api.yoti.com/ai/v1/ageUse Yoti's Age estimation service.
https://api.yoti.com/ai/v1/antispoofingUse Yoti's Anti-spoofing check.
https://api.yoti.com/ai/v1/age-antispoofingUse Yoti's Age estimation service and the Anti-spoofing check.

Once you have added the Yoti SDK dependency to your project, you can use it to build and send your request. See the code snippets below for examples.

Javascript
Java
PHP
Python
C#
Go
Ruby
Copy

The JSON string for the payload must be in the following format. This is sent with the withPayload method provided in the SDK.

JSON
Copy

img is the mandatory parameter that contains the captured image in Base64 Encoded format.

metadata is an optional parameter but is strongly recommended for better results. It is used to specify what type of device is being used. You can choose between mobile or laptop.

Retrieve the results

The endpoint will return the Anti-spoofing result alongside Age estimation.

JSON
Copy

If requesting age only, the response will look as follows:

JSON
Copy

If integrating into a non-browser client, we recommend contacting clientsupport@yoti.com for additional support.

Relaxed image requirements

When using the Age only endpoint, it is possible to lower the threshold for face detection and image validation on images. A reason for this might be that images are not being captured live through Yoti's Face Capture module, or you may want to age estimate images where there is no case to perform a liveness check.

This feature is utilised by setting the image validation level to low, as shown in the example payload.

Note that this may only be used with the age endpoint.

See this page for more details on the image requirements.

JSON
Copy

Terminal integrations

Good to know
This is not live yet but will be going live soon. Please contact us if this interests you.

Optionally, additional headers may be provided to the request to allow Yoti to track error responses coming from a particular machine. This would typically be used in a non-browser client scenario, such as an ePOS terminal where each individual machine must be registered by the business.

In order to do this, the following headers should be applied:

HeaderDescription
Terminal-IdUnique ID per machine. Mandatory for non-browser integrations.
Session-IdMay be provided to demonstrate multiple attempts are from a single user transaction.

Example responses

The response received from the API will be below, depending on the endpoint used.

/age-antispoofing
Copy
/age
Copy
/antispoofing
Copy
ResponseExplained
Prediction - realYoti has detected a real user.
Prediction - fakeYoti has detected a spoof attempt.
Age - ageThe age estimation of the user.
Age - st_devThe st_dev value is a confidence score. Yoti recommends rejecting any response with an uncertainty greater than 6.0. Typically this indicates a problem with image capture. This should only be treated as a quality score.

Error codes

In case of any failure, you will receive the following error responses:

Error codeErrorDescription
404APP_NOT_FOUNDApplication app_id not found.
401INVALID_X_YOTI_AUTH_ID
  • X-Yoti-Auth-Id__header not provided.
  • auth id is not a valid uuid.
400INVALID_APP_IDApplication id cannot be empty.
400INVALID_PUBLIC_KEYApplication public key cannot be empty.
403DISABLED_APP_STATEApplication must be enabled.
400INVALID_ORG_IDOrganisation id cannot be empty.
400INVALID_BILLING_SOURCE_IDApplication billing source id cannot be empty.
404ORG_NOT_FOUNDOrganisation org_id not found.
401INVALID_YOTI_AUTH_DIGEST
  • X-Yoti-Auth-Digest header is missing.
  • X-Yoti-Auth-Digest is not base64 encoded.
401INVALID_NONCE
  • Nonce is missing. nonce parameter is mandatory
  • Provided nonce is not a valid uuid.
401INVALID_TIMESTAMP
  • Timestamp is missing. timestamp parameter is mandatory.
  • Provided timestamp is not a valid unix timestamp.
401INVALID_PUBLIC_KEY_ENCODINGFailed to load public key. key is not der encoded.
401UNSUPPORTED_ALGORITHMSerialised key is of a type that is not supported by the backend.
401INVALID_SIGNATUREFailed to verify signature.
403INVALID_ORG_STATUSOrganisation has an invalid status.
404INVALID_METADATA_DEVICEInvalid device metadata provided.
400INVALID_BODY_ENCODINGRequest body should be a valid JSON.
404INVALID_ENDPOINTThe endpoint request is invalid.
413PAYLOAD_TOO_LARGEPayload too large.
400IMAGE_NOT_PROVIDEDImage has not been provided.
400INVALID_B64_IMAGE
  • Base64 image is incorrectly padded.
  • Cannot create image from base64 decoded bytes
400UNSUPPORTED_IMAGE_FORMATImage format not supported. Please use JPEGs (95 to 100 quality) and PNGs.
400IMAGE_SIZE_TOO_BIGImage size too big, the maximum size is 1.5MB.
400IMAGE_SIZE_TOO_SMALLImage size too small, the minimum size is 50KB.
400MIN_HEIGHTThe image height is incorrect. Image minimum height required is 300 pixels.
400MAX_HEIGHTThe image height is incorrect. Image maximum height required is 2000 pixels.
400MIN_WIDTHThe image width is incorrect. Image minimum width required is 300 pixels.
400MAX_WIDTHThe image width is incorrect. Image maximum width required is 2000 pixels.
400MIN_PIXELSTo process the image the minimum number of pixels required is 90,000 pixels.
400MAX_PIXELSTo process the image the maximum number of pixels required is 2,100,000 pixels.
400IMAGE_WRONG_CHANNELSMissing colour channel, the input image must be RGB or RGBA.
400IMAGE_GRAYSCALE_NOT_SUPPORTEDGrayscale images not supported.
503SERVICE_UNAVAILABLEThe service is temporarily unavailable.
400FACE_NOT_FOUNDFace not found.
400MULTIPLE_FACESMultiple faces in the image provided.
400FACE_BOX_TOO_SMALLThe face in the image provided is too small.
400FACE_TO_IMAGE_RATIO_TOO_LOWFace ratio is lower than the minimum ratio.
400FACE_TO_IMAGE_RATIO_TOO_HIGHFace ratio is bigger than the maximum ratio.
400INSUFFICIENT_AREA_AROUND_THE_FACEInsufficient area around the face in the image provided.
400IMAGE_TOO_BRIGHTImage too bright..
400IMAGE_TOO_DARKImage too dark.
400INVALID_LEVEL_OF_ASSURANCEInvalid antispoofing level of assurance provided.
400INVALID_REQUEST_BODYRequest body is invalid, '-' field is invalid.
400INVALID_IMG_VALIDATION_LEVELThe image validation level is invalid.
401UNAUTHORIZEDThe X-Yoti-Auth-Id provided isn't authorized to access this resource.
500FAIL_PREDICTION
  • Age distribution is empty.
  • Standard deviation is empty.
  • Cannot build model result.
  • Antispoofing prediction failed.
500UNSPECIFIED_ERRORAn internal server error occurred.
400SECURE_REQUEST_IS_EMPTYSecure request field is empty.
400SECURE_SESSION_NOT_FOUNDSecure session not found.
400SECURE_SIGNATURE_NOT_FOUNDSecure signature not found.
400SECURE_VERSION_NOT_FOUNDSecure version not found.
400INVALID_SECURE_SIGNATUREFailed to verify secure session signature.
400SECURE_VERIFICATION_NOT_FOUNDSecure verification not found.
400UNTRUSTED_SECURE_SESSIONUntrusted secure session
401INVALID_SECURE_SESSIONInvalid secure session token.
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard