REST API: working with faces

Search faces in person lists

Search for a face among the persons you stored.

Purpose

Use this call to look a face up in your person lists, for example to find a returning person or to check a blocklist. Each processed face is recorded as an action and attributed to a data source group and a data source. Persons can be created automatically by the new_person_* rules.

Request

POST <API_BASE_URL>/face/search. All calls are POST under your API address. Replace <API_BASE_URL> with the API address provided with your access.

Send a permanent API token in the token field of the body, or a user token in the token header. See authentication.

Content type: multipart/form-data. Send the fields as a multipart form.

FieldTypeRequiredDescription
tokenstringif no headerYour permanent API token. Required unless you send a user token in the token header.
imagefileyesThe image file. It can contain several faces; see multi.
group_idstring (uuid)noThe data source group the action is attributed to.
source_idstring (uuid)noThe data source the action is attributed to.
multibooleannoSearch every face found. When false, only the largest face is processed.
person_list_searcharray of string (uuid) or stringnoThe person list or lists to search. When left out, only the default list is searched.
person_list_addarray of string (uuid) or stringnoThe list or lists in which persons are created automatically. It is required for person creation.
new_person_thresholdvaluenoThe match threshold for creating a person. The value never creates no person; no_match uses the platform default.
resultsstring or numbernoHow many matching persons to return per face, sorted by distance.
thresholdstring or numbernoThe distance threshold of a match.
feature_checkarray of object or stringnoA feature name or an array of names to detect on each found face, for example age, gender, mood, glasses, mask or quality. The schema lists the full set of names.
drop_imagebooleannoDo not store the image in the actions history.
person_databooleannoInclude person data in the matches.

Response

HTTP 201. At least one face was found, recorded and searched.

FieldTypeDescription
statusstringAlways ok on this body.
faces_totalintegerHow many faces the detector found on the image.
spentintegerProcessing time in milliseconds.
resultsarray of objectOne entry per processed face.
results[].action_idstring (uuid)The identifier of the action this face was recorded as.
results[].matchesarray of objectThe hits of this face against the lists you searched, sorted by distance.
results[].personsarray of objectThe persons created from this face under the new_person_* rules. Null when nothing was created.
results[].group_idstring (uuid)The data source group the action was attributed to.
results[].source_idstring (uuid)The data source the action was attributed to.
results[].yawnumberHead rotation left or right, in degrees.
results[].pitchnumberHead tilt up or down, in degrees.

HTTP 200. No face was found on the image; results is empty.

Errors

  • 400: The body failed validation. The answer has status of error and a details list with one entry per offending field (path, expected, actual).
  • 401: The token is missing, expired or unknown.

A refusal can also come before the operation runs: an address outside your IP allowlist, a token bound to another address, or a body that is not valid JSON. See response format and errors.

Example

Request:

curl -X POST "<API_BASE_URL>/face/search" \
  -F "token=<your permanent API token>" \
  -F "image=@photo.jpg" \
  -F "person_list_search=<person list id>" \
  -F "multi=false"

Response:

{
  "status": "ok",
  "message": "<detail>",
  "faces_total": 1,
  "spent": 560,
  "results": [
    {
      "action_id": "<action id>",
      "group_id": "<group id>",
      "source_id": "<source id>",
      "matches": [],
      "persons": null,
      "yaw": 4,
      "pitch": -2
    }
  ]
}

Questions about the face API?

Write to us and we will help.

Talk to us