Face Template Operations
The following endpoints allow extracting face templates from images, enrolling and removing templates, and matching a template against enrolled records. These are low-level operations for direct processing of facial biometric data.
Available on versions V6, V7 and V8.
Extract face template
Extracts a face template from an image file. The template can then be used for matching via face_template_match or for enrollment via face_template_enroll.
POST /face_template_extract.fcgi
Parameters
- Image file in binary format, sent as the request body (
application/octet-stream). The image must meet the following requirements:- Format: JPG or PNG
- Minimum size: 160×160 pixels
- Maximum size: 1920×1080 pixels
- Pixel depth: 32 bits
Response
- scores (JSON object) : Positioning and quality metrics for the received image. These are:
- bounds_width (int) : Face width.
- horizontal_center_offset (int) : Horizontal distance from the center of the face to the center of the image.
- vertical_center_offset (int) : Vertical distance from the center of the face to the center of the image.
- center_pose_quality (int) : Score for centering quality, indicating whether the face is facing the camera or is tilted.
- sharpness_quality (int) : Image sharpness.
- success (bool) : Indicates whether the registration was successful or not.
- errors (array of JSON objects) : List containing one or more errors explaining why the extraction failed. For each error:
- code (int) : Code corresponding to the reported error.
- message (string) : Message describing the error.
- face_template (string) : Base64-encoded face template
Possible errors with the image to be uploaded
As described in the topic Recommendations - Photos and Installation, there are certain photo quality criteria that must be followed for facial recognition to work correctly. If you attempt to upload an image file that does not meet the specified recommendations, error messages will appear explaining why the photo was not accepted. The following lists the error codes and corresponding messages that explain their causes:
- code 1: This corresponds to errors not related to file quality, but rather to an error in the request parameters. There are several types of messages that may appear with errors of this code, for example:
- message: “Invalid data (image file expected)”
- code 2: Occurs when a face cannot be identified in the uploaded image file.
- message: “Face not detected”
- code 4: Occurs when the horizontal and vertical distances from the center of the face to the center of the image are too significant. To understand quantitatively how this can be resolved, you must analyze the request response. In the JSON object score, you need to analyze the values of the horizontal_center_offset and vertical_center_offset parameters. The maximum allowed value for both is 1000. Therefore, when this value is exceeded, the following message is displayed:
- message: “Face not centered”
- code 5: Occurs when the width of the face in the image is too small (face far from the camera). To understand quantitatively how this can be resolved, you must analyze the request response. In the JSON object score, you need to analyze the value of the bounds_width parameter. The minimum allowed value is 60. Therefore, when this value is exceeded, the following message is displayed:
- message: “Face too distant”
- Code 6: This occurs when the width of the face in the image is too large (the face is too close to the camera). To understand quantitatively how this can be resolved, you must analyze the response to the request. In the JSON object score, you need to analyze the value of the bounds_width parameter. The maximum allowed value is 800. Therefore, when this value is exceeded, the following message is displayed:
- message: “Face too close”
- code 7: Occurs when the face is not properly centered, indicating that the face is tilted relative to the camera. To understand quantitatively how this can be resolved, you must analyze the request response. In the JSON object score, you need to analyze the value of the center_pose_quality parameter. The maximum allowed value is 400. Therefore, when this value is exceeded, the following message is displayed:
- message: “Face pose not centered”
- code 8: Occurs when the registered image is not sharp enough to ensure facial recognition. To understand quantitatively how this can be resolved, you must analyze the response to the request. In the JSON object score, you must analyze the value of the sharpness_quality parameter. The minimum allowed value is 450. Therefore, when this value is lower, the following message is displayed:
- message: "Low sharpness"
- code 9: Occurs when the face is too close to the edges of the image.
- message: “Face too close to image borders”
- code 11: Occurs when the provided image is black and white and the face_enroll_mode parameter is set to 1.
- message: “Face image is in grayscale”
- code 12: Occurs when there is more than one face in the image and the face_enroll_mode parameter is set to 1.
- message: “Multiple faces in image”
Request example
$.ajax({
url: "/face_template_extract.fcgi?session=" + session,
type: 'POST',
contentType: 'application/octet-stream',
data: [bytes of image file]
});
Response example (success)
{
"scores": {
"bounds_width": 113,
"horizontal_center_offset": -12,
"vertical_center_offset": -134,
"center_pose_quality": 901,
"sharpness_quality": 865
},
"face_template": "vRYFPUe+C76B1RY+azJD...",
"success": true
}
Response example (failure)
{
"success": false,
"errors": [{ ... }]
}
Extract face templates in batch NEW!
Extracts face templates from a list of images in a single call. Each image is identified by a caller-provided id, echoed back in the corresponding result so that responses can be matched to inputs regardless of processing order.
POST /face_template_extract_list.fcgi
Parameters
- face_images (array): Required. Each element is an object with:
- id (int64): Caller-defined identifier for this image, echoed back in the result.
- image (string): Base64-encoded image file. Same format/size/depth requirements as face_template_extract.
Response
- results (array): One entry per input image, in the same order, each containing:
- id (int64): The identifier provided in the request.
- success (bool):
trueif the template was extracted successfully. - face_template (string): Base64-encoded face template. Present only when
successistrue. - errors (array): List of error objects. Present only when
successisfalse.
Request example
$.ajax({
url: "/face_template_extract_list.fcgi?session=" + session,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
face_images: [
{ id: 1, image: "base64encodedimage..." },
{ id: 2, image: "base64encodedimage..." }
]
})
});
Response example
{
"results": [
{ "id": 1, "success": true, "face_template": "base64encodedtemplate..." },
{ "id": 2, "success": false, "errors": [{ ... }] }
]
}
Enroll face template NEW!
Enrolls one or more previously extracted face templates as biometric records of existing users, without going through the photo-capture/validation flow.
POST /face_template_enroll.fcgi
Parameters
- face_templates (array): Required. Each element is an object with:
- user_id (int64): Required. ID of an existing user to enroll the template for.
- face_template (string): Required. Base64-encoded face template, obtained from face_template_extract. The decoded template must be exactly 1024 bytes.
- timestamp (int): Timestamp associated with the source image, stored as the user's image timestamp.
- match (bool): Optional, default
true. Whentrue, the template is first matched against already-enrolled faces; if a match is found, the enrollment is rejected with a "Face exists" error instead of being saved. Set it tofalseto skip this check.
Response
- results (array): One entry per input template, each containing:
- user_id (int64): The user ID provided in the request.
- success (bool):
trueif the template was enrolled successfully. - errors (array): List of error objects. Present only when
successisfalse.
Request example
$.ajax({
url: "/face_template_enroll.fcgi?session=" + session,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
face_templates: [
{ user_id: 42, face_template: "base64encodedtemplate...", timestamp: 1700000000 }
],
match: true
})
});
Response example
{
"results": [
{ "user_id": 42, "success": true }
]
}
Remove face template NEW!
Removes enrolled face templates. Exactly one of all, user_ids or user_id must be provided.
POST /face_template_destroy.fcgi
Parameters
- all (bool): If
true, removes the face templates of every user on the device and resets their image timestamps. - user_ids (array of int64): Removes the face templates of the given users.
- user_id (int64): Removes the face template of a single, existing user.
Response
- This call has no return.
Request example
$.ajax({
url: "/face_template_destroy.fcgi?session=" + session,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
user_ids: [42, 43]
})
});
Count enrolled templates NEW!
Returns the number of distinct users that currently have at least one face template enrolled on the device.
GET /face_template_count_distinct.fcgi
Parameters
- This request has no parameters.
Response
- count (int): Number of distinct enrolled users.
Request example
$.ajax({
url: "/face_template_count_distinct.fcgi?session=" + session,
type: 'GET',
contentType: 'application/json'
});
Response example
{
"count": 128
}
Match face template
Compares a face template against templates enrolled in the device. Optionally restricts the search to a specific user.
POST /face_template_match.fcgi
Parameters
- face_template (string): Required. Base64-encoded face template to match, obtained from face_template_extract. The decoded template must be exactly 1024 bytes.
- user_id (int64): Optional. If provided, restricts matching to templates belonging to this user. If omitted or
0, matches against all enrolled users.
Response
- match (bool):
trueif a matching template was found. - info (object): Present only when
matchistrue. Contains:- match_user_id (int64): ID of the matched user.
- match_score (int): The matcher's primary confidence score, on a fixed 0-1000 scale. This is the main value used to decide whether the match is accepted, against the match_score_threshold configuration parameter (default
700). - match_similarity (int): A secondary similarity metric, used as an additional calibration signal alongside
match_score. It is computed on its own internal scale and multiplied by 1000 before being returned here, to match the match_similarity_threshold configuration parameter (default3.5, i.e.3500in this scaled response value).
match_score and match_similarity are two independent outputs of the facial matcher, not a raw/normalized pair of the same measurement — a high match_score does not guarantee a proportionally high match_similarity, and vice versa. When tuning acceptance sensitivity, adjust both thresholds together rather than relying on a single one.
Request example
$.ajax({
url: "/face_template_match.fcgi?session=" + session,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
face_template: "base64encodedtemplate...",
user_id: 42
})
});
Response example (match found)
{
"match": true,
"info": {
"match_user_id": 42,
"match_score": 850,
"match_similarity": 4120
}
}
Response example (no match)
{
"match": false
}