Skip to content

Search Faces ​

Takes an image with a face and retrieves similar faces from a collection, each with a similarity score and its embedded metadata. This is the 1:N check for duplicate accounts and blocklist hits.

Endpoint ​

http
POST /v1/search_faces_sync
Content-Type: application/json
json
{
  "image": {
    "id": "de02a784-a7bc-43a7-96ba-226420b18960",
    "base64": "",
    "label": "portrait",
    "metadata": "{}"
  },
  "collection": "default"
}

Parameters:

ParamTypeRequiredDefaultDescription
imageImageDataYes—Image containing the face to search for.
collectionstringNodefault collectionCollection to search. Case-sensitive.

ImageData ​

ParamTypeRequiredDefaultDescription
idstringNo—ID of the image returned by Upload Image.
base64stringNo—Base64-encoded text of the image data.
labelstringNo—Label of the image, as described in Usage Recommendations.
metadatastring_jsonNo—Key/value JSON string. Example: {"id":"<ID>","type":1}

Sample Request ​

bash
curl --location '<BASE_URL>/v1/search_faces_sync' \
  --header 'Authorization: ATV <ACCESS_ID>:<SIGNATURE>' \
  --header 'X-TV-Timestamp: <TIMESTAMP>' \
  --header 'Content-Type: application/json' \
  --data '{
    "collection": "default",
    "image": {
      "id": "de02a784-a7bc-43a7-96ba-226420b18960",
      "base64": "",
      "label": "portrait",
      "metadata": "{}"
    }
  }'

Response ​

json
{
  "success": true,
  "code": 0,
  "message": "success",
  "data": {
    "request_id": "81a3cf2b-bdbb-4208-b304-3a234cf21b9c",
    "status": "success",
    "image": {
      "id": "de02a784-a7bc-43a7-96ba-226420b18960",
      "faces": [
        {
          "id": "73644de1-d727-4bce-9e8c-f5453658556a",
          "bounding_box": { "top": 154, "right": 408, "bottom": 335, "left": 173 }
        }
      ]
    },
    "faces": [
      [
        {
          "id": "452476f8-1a88-4082-a777-21250f3dbdf4",
          "image_id": "6b5b2984-a834-4c30-b6c0-c3c0720b51af",
          "score": 1
        }
      ]
    ]
  },
  "errors": []
}
FieldTypeDescription
data.request_idstringRequest ID; quote it to CAKE Support when checking logs.
data.statusstringsuccess or failure.
data.image.idstringID of the query image.
data.image.facesFace[]Faces detected in the query image, each with id and bounding_box.
data.facesSearchMatch[][]One array of matches per detected query face, in the same order as data.image.faces.

SearchMatch ​

FieldTypeDescription
idstringID of the matched face in the collection.
image_idstringID of the indexed image the matched face belongs to.
scorefloatSimilarity between the query face and the matched face, range 0–1.

data.faces is an array of arrays — index into it by query face, then read the matches for that face.

Errors ​

CodeMessage
2001010Access ID not found.
401100You are not authorized to perform the action.
4001000Input parameter violates a constraint.
4001001The X-TV-Timestamp header is expired, need a newer one.
5001000Some unexpected error occurs while processing the request.
CodeDescription
access_denied_exceptionYou are not authorized to perform the action.
invalid_parameter_exceptionInput parameter violates a constraint.
request_time_too_skewedThe X-TV-Timestamp header is expired, need a newer one.
image_not_found_exceptionThe image ID is not found in DB.
request_not_found_exceptionThe request ID is not found when polling result by id.
request_timeout_exceptionRequest takes too long to process.
rate_limit_exceptionThe number of requests exceeded your throughput limit.
internal_server_errorSome unexpected error occurs while processing the request.

Next Steps ​

  • Index Faces — populate the collection this API searches
  • Compare Faces — 1:1 comparison when you already know both images

Developers