> 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 AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.vlenseg.com/_mcp/server.

# Face match (face vs. ID photo)

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

Matches a face image against the ID front photo stored in a transaction. Complete the `id/front` step for the same `transaction_id` first.

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

## Authentication

- `ApiKey` header (required) — Static API key issued to your tenant. Required on every request.
- `Authorization` header (bearer token, required) — End-user JWT from registration or login. Required for verification, signing, and user-scoped operations.

## Servers

- `https://api.vlenseg.com` (Production, default)
- `https://api.vlens.co` (Staging)

## Request

### Body (application/json)

This endpoint expects an object.

- `image` (string, required) — Base64-encoded face image.
- `transaction_id` (string, required) — Transaction that already contains an `id/front` scan.
- `client_transaction_id` (string, optional)

## Response

### 200

- `services` (object, optional) — Per-service check results attached to every OCR response.
  - `validations` (object, optional, nullable)
    - `validation_errors` (list of object, optional)
      - `field` (string, optional)
      - `value` (string, optional)
      - `errors` (list of object, optional)
        - `code` (integer, optional)
        - `message` (string, optional)
  - `spoofing` (object, optional, nullable)
    - `fake` (boolean, optional)
  - `classification` (object, optional, nullable)
    - `doc_type` (string, optional) — Detected document type, e.g. `national_id`, `passport`, `driving_license`.
  - `liveness` (boolean, optional, nullable) — `true` when the submitted face frames are from a live person.
  - `AML` (object, optional, nullable)
  - `SRC` (object, optional, nullable)
- `data` (object, optional)
  - `isMatched` (string, optional) — Whether the face matches the ID photo.
  - `dissimilarity` (string, optional) — Distance score — lower means more similar.
  - `threshold` (string, optional) — Match threshold used. Default `2.4`.
  - `score` (string, optional) — Match confidence score.
  - `detected_face_image` (string, optional) — Whether a face was detected in the submitted image.
  - `detected_id_face_image` (string, optional) — Whether a face was detected in the ID photo.
  - `transaction_id` (string, optional) — Use in subsequent steps.
  - `request_id` (string, optional) — Identifier for this individual request.
  - `client_transaction_id` (string, optional) — Your own reference ID, echoed back.
- `error_code` (integer, optional, nullable)
- `error_message` (string, optional, nullable)

## Examples

**Request**

```json
{
  "image": "string",
  "transaction_id": "string"
}
```

**Response**

```json
{
  "services": {
    "validations": {
      "validation_errors": [
        {
          "field": "string",
          "value": "string",
          "errors": [
            {
              "code": 1,
              "message": "string"
            }
          ]
        }
      ]
    },
    "spoofing": {
      "fake": true
    },
    "classification": {
      "doc_type": "string"
    },
    "liveness": true,
    "AML": {},
    "SRC": {}
  },
  "data": {
    "isMatched": "string",
    "dissimilarity": "string",
    "threshold": "string",
    "score": "string",
    "detected_face_image": "string",
    "detected_id_face_image": "string",
    "transaction_id": "string",
    "request_id": "string",
    "client_transaction_id": "string"
  },
  "error_code": 1,
  "error_message": "string"
}
```

**SDK Code**

```python
import requests

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

payload = {
    "image": "string",
    "transaction_id": "string"
}
headers = {
    "ApiKey": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.vlenseg.com/v1/ocr/face/match';
const options = {
  method: 'POST',
  headers: {ApiKey: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"image":"string","transaction_id":"string"}'
};

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

```go
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"image\": \"string\",\n  \"transaction_id\": \"string\"\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
require 'uri'
require 'net/http'

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

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  \"image\": \"string\",\n  \"transaction_id\": \"string\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.vlenseg.com/v1/ocr/face/match")
  .header("ApiKey", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"image\": \"string\",\n  \"transaction_id\": \"string\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.vlenseg.com/v1/ocr/face/match', [
  'body' => '{
  "image": "string",
  "transaction_id": "string"
}',
  'headers' => [
    'ApiKey' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

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

```swift
import Foundation

let headers = [
  "ApiKey": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "image": "string",
  "transaction_id": "string"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.vlenseg.com/v1/ocr/face/match")! 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()
```