Knowledge base
This is your online library of information about Yoti Age Scan.
Antispoofing - Background Image
This anti-spoofing method is useful for fixed camera installations (for example at an electronic point-of-sale terminal). It captures the empty background view from the camera, which can then be compared against all subsequent captured images for age estimation requests. Yoti runs a check to confirm that the original background is still present in each subsequent capture, rejecting images where it does not.

Background image technical process
There are 2 steps required to perform background image checks:
- Submit a background image, this will be used in each age estimation request to ensure the backgrounds match.
- Submit the photo for age estimation, with the associated background ID.
Both of these steps can be achieved using the SDK, the following assumes you have already installed the SDK as per the steps detailed in the Get age estimation.
Get the background image
Please note the withEndpoint
should be set to /backgrounds.
const { RequestBuilder, Payload } = require('yoti');
const request = new RequestBuilder()
.withBaseUrl('https://api.yoti.com/api/v1/age-verification')
.withPemFilePath('<YOTI_KEY_FILE_PATH>')
.withEndpoint('/backgrounds')
.withPayload(new Payload(data))
.withMethod('POST')
.withHeader('X-Yoti-Auth-Id', '<YOTI_CLIENT_SDK_ID>')
.build();
//get Yoti response
const response = request.execute();
The request payload should be in the following format: This JSON string will be the data
parameter in the withPayload
above code snippet.
{
"data": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wAcHNXCKigjEaYH51Me1Zy1Za0P/Z....",
}
The response will be as follows:
{
"id": "4e08364e-a55a-4794-a93b-8f4d70d432ba"
}
Get Age Estimation with anti-spoofing
Please note the withEndpoint
should be set to /checks
const { RequestBuilder, Payload } = require('yoti');
const request = new RequestBuilder()
.withBaseUrl('https://api.yoti.com/api/v1/age-verification')
.withPemFilePath('<YOTI_KEY_FILE_PATH>')
.withEndpoint('/checks')
.withPayload(new Payload(data))
.withMethod('POST')
.withHeader('X-Yoti-Auth-Id', '<YOTI_CLIENT_SDK_ID>')
.build();
//get Yoti response
const response = request.execute();
The request payload should be in the following format: This JSON string will be the data
parameter in the withPayload
above code snippet. Notice the addition of the background_id
which would be obtained from step 1.
{
"data": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wAcHNXCKigjEaYH51Me1Zy1Za0P/Z....",
"background_id": "4e08364e-a55a-4794-a93b-8f4d70d432ba"
}
The response received from the API will be as follows:
{
"pred_age": 29.7475,
"uncertainty": 2.04677
}
For more details see the API references here.