> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.vlenseg.com/llms.txt.
> For full documentation content, see https://docs.vlenseg.com/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.vlenseg.com/_mcp/server.

# Compare two face images

POST https://api.vlenseg.com/v1/ocr/face/compare
Content-Type: application/json

Directly compare any two face images without requiring an ID transaction. Returns the same match result as Face Match.

Reference: https://docs.vlenseg.com/api-reference/vlens-api/ocr/face-compare

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: example-openapi
  version: 1.0.0
paths:
  /v1/ocr/face/compare:
    post:
      operationId: face-compare
      summary: Compare two face images
      description: >-
        Directly compare any two face images without requiring an ID
        transaction. Returns the same match result as Face Match.
      tags:
        - subpackage_ocr
      parameters:
        - name: ApiKey
          in: header
          description: >-
            Static API key issued to your tenant. Obtain from the Vlens
            dashboard.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Face comparison result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OCR_faceCompare_Response_200'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FaceCompareInput'
servers:
  - url: https://api.vlenseg.com
components:
  schemas:
    FaceCompareInput:
      type: object
      properties:
        face_image1:
          type: string
          description: Base64-encoded first face image.
        face_image2:
          type: string
          description: Base64-encoded second face image.
        liveness:
          type: string
          default: '2'
          description: Liveness mode flag.
        transaction_id:
          type:
            - string
            - 'null'
        client_transaction_id:
          type:
            - string
            - 'null'
        request_id:
          type:
            - string
            - 'null'
        country:
          type:
            - string
            - 'null'
          default: EGY
        getExtractedData:
          type: boolean
          default: false
      required:
        - face_image1
        - face_image2
      title: FaceCompareInput
    ErrorOutput:
      type: object
      properties:
        code:
          type: integer
        message:
          type:
            - string
            - 'null'
      title: ErrorOutput
    ValidationErrorOutput:
      type: object
      properties:
        field:
          type:
            - string
            - 'null'
        value:
          type:
            - string
            - 'null'
        errors:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ErrorOutput'
      title: ValidationErrorOutput
    ScanValidationOutput:
      type: object
      properties:
        validation_errors:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ValidationErrorOutput'
      title: ScanValidationOutput
    ScanSpoofingOutput:
      type: object
      properties:
        fake:
          type:
            - boolean
            - 'null'
          description: Whether the submitted document was detected as a photocopy or fake.
      title: ScanSpoofingOutput
    ScanClassificationOutput:
      type: object
      properties:
        doc_type:
          type:
            - string
            - 'null'
          description: Detected document type (e.g., `national_id`, `passport`).
      title: ScanClassificationOutput
    CriminalRecordData:
      type: object
      properties:
        caseNo:
          type:
            - string
            - 'null'
        caseYear:
          type:
            - integer
            - 'null'
        recordDate:
          type:
            - string
            - 'null'
          format: date-time
        fullName:
          type:
            - string
            - 'null'
        idNumber:
          type:
            - string
            - 'null'
        dateOfBirth:
          type:
            - string
            - 'null'
          format: date-time
        score:
          type:
            - string
            - 'null'
      title: CriminalRecordData
    CriminalRecordOutput:
      type: object
      properties:
        AML_matched:
          type: boolean
          description: Whether the user matches any AML watchlist records.
        data:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/CriminalRecordData'
      description: AML (Anti-Money Laundering) check result.
      title: CriminalRecordOutput
    FactorySourceOutput:
      type: object
      properties:
        isValid:
          type: boolean
        errorCode:
          type: integer
        errorKey:
          type:
            - string
            - 'null'
        errorMessage:
          type:
            - string
            - 'null'
      description: >-
        SRC (Source Registry Check) — validates the ID against the national
        registry.
      title: FactorySourceOutput
    ScanServicesOutput:
      type: object
      properties:
        validations:
          $ref: '#/components/schemas/ScanValidationOutput'
        spoofing:
          $ref: '#/components/schemas/ScanSpoofingOutput'
        classification:
          $ref: '#/components/schemas/ScanClassificationOutput'
        liveness:
          type:
            - boolean
            - 'null'
          description: Whether the liveness check passed.
        AML:
          $ref: '#/components/schemas/CriminalRecordOutput'
        SRC:
          $ref: '#/components/schemas/FactorySourceOutput'
      description: Results from the various backend verification services.
      title: ScanServicesOutput
    FaceMatchOutput:
      type: object
      properties:
        transaction_id:
          type: string
          format: uuid
        request_id:
          type: string
          format: uuid
        client_transaction_id:
          type:
            - string
            - 'null'
        isMatched:
          type: boolean
          description: Whether the face matches the ID photo.
        dissimilarity:
          type: number
          format: double
          description: Distance score — lower means more similar.
        threshold:
          type:
            - number
            - 'null'
          format: double
          description: Match threshold applied (default 2.4).
        score:
          type:
            - number
            - 'null'
          format: double
        detected_face_image:
          type: boolean
          description: Whether a face was detected in the submitted image.
        detected_id_face_image:
          type: boolean
          description: Whether a face was detected in the ID photo.
      description: Result of matching a face image against an ID photo.
      title: FaceMatchOutput
    OCR_faceCompare_Response_200:
      type: object
      properties:
        services:
          $ref: '#/components/schemas/ScanServicesOutput'
        data:
          $ref: '#/components/schemas/FaceMatchOutput'
        error_code:
          type:
            - integer
            - 'null'
        error_message:
          type:
            - string
            - 'null'
      title: OCR_faceCompare_Response_200
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: ApiKey
      description: Static API key issued to your tenant. Obtain from the Vlens dashboard.
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        Short-lived JWT. Obtain via:
        - `/api/credentials/Login` for admin / service tokens
        - `/api/DigitalIdentity/Register` or login for end-user tokens

```

## SDK Code Examples

```python OCR_faceCompare_example
import requests

url = "https://api.vlenseg.com/v1/ocr/face/compare"

payload = {
    "face_image1": "/9j/FACE1_BASE64...",
    "face_image2": "/9j/FACE2_BASE64..."
}
headers = {
    "ApiKey": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript OCR_faceCompare_example
const url = 'https://api.vlenseg.com/v1/ocr/face/compare';
const options = {
  method: 'POST',
  headers: {ApiKey: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"face_image1":"/9j/FACE1_BASE64...","face_image2":"/9j/FACE2_BASE64..."}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go OCR_faceCompare_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.vlenseg.com/v1/ocr/face/compare"

	payload := strings.NewReader("{\n  \"face_image1\": \"/9j/FACE1_BASE64...\",\n  \"face_image2\": \"/9j/FACE2_BASE64...\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("ApiKey", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby OCR_faceCompare_example
require 'uri'
require 'net/http'

url = URI("https://api.vlenseg.com/v1/ocr/face/compare")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["ApiKey"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"face_image1\": \"/9j/FACE1_BASE64...\",\n  \"face_image2\": \"/9j/FACE2_BASE64...\"\n}"

response = http.request(request)
puts response.read_body
```

```java OCR_faceCompare_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.vlenseg.com/v1/ocr/face/compare")
  .header("ApiKey", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"face_image1\": \"/9j/FACE1_BASE64...\",\n  \"face_image2\": \"/9j/FACE2_BASE64...\"\n}")
  .asString();
```

```php OCR_faceCompare_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.vlenseg.com/v1/ocr/face/compare', [
  'body' => '{
  "face_image1": "/9j/FACE1_BASE64...",
  "face_image2": "/9j/FACE2_BASE64..."
}',
  'headers' => [
    'ApiKey' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp OCR_faceCompare_example
using RestSharp;

var client = new RestClient("https://api.vlenseg.com/v1/ocr/face/compare");
var request = new RestRequest(Method.POST);
request.AddHeader("ApiKey", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"face_image1\": \"/9j/FACE1_BASE64...\",\n  \"face_image2\": \"/9j/FACE2_BASE64...\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift OCR_faceCompare_example
import Foundation

let headers = [
  "ApiKey": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "face_image1": "/9j/FACE1_BASE64...",
  "face_image2": "/9j/FACE2_BASE64..."
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.vlenseg.com/v1/ocr/face/compare")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```