Create a Request

AI Tools

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.

Node.js
Java
PHP
Python
C#
Go
Ruby
Copy

You can create three types of requests using the API:

EndpointDescription
https://api.yoti.com/ai/v1/age?secure=trueUse Yoti's Age estimation service.
https://api.yoti.com/ai/v1/antispoofing?secure=trueUse Yoti's Anti-spoofing (liveness) check.
https://api.yoti.com/ai/v1/age-antispoofing?secure=trueUse Yoti's Age estimation service and the Anti-spoofing (liveness) 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.

Node.js
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. The face capture module will automatically return “img” and “secure” on success. Do not modify these fields manually.

JSON
Copy
ParameterExplained
imgIs the mandatory parameter that contains the captured image in Base64 Encoded format.
metadataIs 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.
secureIs a mandatory parameter that is returned by the face capture module.

Multiframe

If you're using Multiframe within the Face Capture Module - you must include the query parameter multiframe=true

The payload size will increase when using Multiframe

If there is a mismatch between the Face Capture's multiframe setting and the multiframe query parameter in the request, the response will always be UNTRUSTED_SECURE_SESSION

Terminal integrations

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.

Retrieve the results

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

JSON
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 quality score. Yoti advises rejecting any response with a value higher than 6.0, as this usually suggests an issue with image capture.

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.

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

JSON
Copy

If integrating into a non-browser client, we recommend contacting us here for additional support.

##

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard