Skip to main content

Compare Faces

faceCompare does a 1:1 comparison of two face images and tells you whether they are the same person, along with the raw confidence score. Unlike faceDetect, it doesn't touch the enrolled gallery — it only compares the two images you send.

API Endpoint

  • HTTP Method: POST
  • Endpoint: /api/v1/faces/faceCompare
  • Base URL (Cloud): https://customername.econnectcloud.com/identities
  • Base URL (On-prem): https://<server-host-or-ip>:5009

Authentication

Requires a JWT bearer token in the Authorization header. See Authentication.

Minimum Permission

The permission name and category below are what you'll see in the Identities web app under System → System settings → Roles.

PermissionCategory
Face DetectionFacial Recognition Services

Request Body

Content-Type: application/json. Both images are sent as base64-encoded strings.

FieldTypeRequiredDescription
image1byte[] (base64)YesThe first face image.
image2byte[] (base64)YesThe second face image to compare against the first.
timeoutMsintNo (default 5000)Fail-fast budget in milliseconds. Exceeding it returns 504 Gateway Timeout. Clamped to 25030000; zero or negative values fall back to the default. See below.

Fail-Fast Timeout

The whole call is bounded by timeoutMs (default 5000 ms). The budget starts once the request payload is on the server (upload time is excluded); if the comparison can't finish inside it, the call fails fast with 504 Gateway Timeout instead of blocking your integration. A 504 is safe to retry.

Images Without a Face

Each image must contain at least one detectable face. When one doesn't, the call returns 422 Unprocessable Entity with a problem detail naming the offending image — "First image could not find a face" or "Second image could not find a face". This is an input problem, not a server fault: retrying with the same images returns the same result. Fix the image (or pre-screen with faceDetect) before retrying.

How match Is Decided

The comparison always returns a raw confidence. match is derived server-side: it is true when confidence meets the server's configured minimum match threshold, and false otherwise.

Apply your own threshold if you need one

Because the raw confidence is always returned, you can ignore match and apply a stricter threshold of your own for high-assurance flows — e.g. only accept a match at confidence >= 0.95 even if the server would call a lower score a match.

Code Examples

API_URL="https://customername.econnectcloud.com/identities"
TOKEN="your_jwt" # from POST /api/v1/authenticate
IMG1_B64=$(base64 -w 0 face.jpg)
IMG2_B64=$(base64 -w 0 face2.jpg)

# Compare two faces (1:1). "match" is threshold-based; "confidence" is the raw score.
curl -sk -X POST "$API_URL/api/v1/faces/faceCompare" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"image1\": \"$IMG1_B64\", \"image2\": \"$IMG2_B64\"}" | jq

Raw Sample

Request

POST https://customername.econnectcloud.com/identities/api/v1/faces/faceCompare
Authorization: Bearer <your_jwt_token>
Content-Type: application/json
{
"image1": "base64_encoded_first_face",
"image2": "base64_encoded_second_face",
"timeoutMs": 5000
}

Response

200 OK — a FaceCompareResponse:

{ "match": true, "confidence": 0.97 }

Response Fields

FieldTypeDescription
matchbooltrue when confidence meets the server's minimum match threshold.
confidencefloatRaw similarity score, 0.01.0.

Response Codes

CodeMeaning
200 OKThe comparison ran; match and confidence are returned.
401 UnauthorizedMissing or invalid JWT.
403 ForbiddenThe user lacks the Face Detection permission.
422 Unprocessable EntityOne of the images has no detectable face. Not retryable with the same images.
500 Internal Server ErrorA server-side error occurred.
504 Gateway TimeoutThe comparison did not complete within the timeoutMs budget. Safe to retry.

Notes

  • match is threshold-based on the server's configured minimum; confidence is the raw score.
  • Keep the raw confidence if you want to apply a stricter, integration-specific threshold.
  • A 422 means an image has no detectable face — fix the input; a 504 means the timeoutMs budget was exceeded — retry, or raise the budget if your integration can tolerate the wait.
  • To match a face against the enrolled gallery rather than a single other image, use faceDetect.