> 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.

# OCR & Computer Vision

The OCR API (`/v1/ocr/`) is a standalone computer vision service for document extraction, face matching, liveness detection, and compliance checks. It operates independently from the [Digital Identity](/digital-identity) flow — you can use it without user registration.

Extract text and data from Egyptian national ID front and back

Extract passport machine-readable zone (MRZ) and biographical data

Extract vehicle license front (owner info) and back (vehicle specs)

Extract Egyptian driving license data

Match a face to an ID photo or compare two face images

Extract text from Egyptian vehicle license plates

***

## Base URL and authentication

The OCR API uses a different base path from the Digital Identity API:

```
https://api.vlenseg.com/v1/ocr/
```

Every request requires:

```http
ApiKey: YOUR_TENANT_API_KEY
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
```

***

## Common request format

All OCR endpoints accept a JSON body with `image` as a base64-encoded string, plus optional transaction and control fields:

```json
{
  "image": "BASE64_ENCODED_IMAGE",
  "transaction_id": "optional-uuid-to-group-steps",
  "client_transaction_id": "your-own-reference",
  "country": "EGY",
  "getExtractedData": true
}
```

| Field                   | Required | Description                                                         |
| ----------------------- | -------- | ------------------------------------------------------------------- |
| `image`                 | Yes      | Base64-encoded JPEG or PNG. Max 3 MB.                               |
| `transaction_id`        | No       | Group multiple steps into one transaction. Omit to start a new one. |
| `client_transaction_id` | No       | Your own reference ID.                                              |
| `country`               | No       | Defaults to `EGY`.                                                  |
| `getExtractedData`      | No       | Include full extracted fields in the response. Default `false`.     |

## Common response format

```json
{
  "services": {
    "validations": { "validation_errors": [] },
    "spoofing": { "fake": false },
    "classification": { "doc_type": "national_id" },
    "liveness": null,
    "AML": null,
    "SRC": null
  },
  "data": { ... },
  "error_code": null,
  "error_message": null
}
```

`data` contains document-specific extracted fields. All step outputs include `transaction_id`, `request_id`, and `client_transaction_id`.

***

## National ID

### Scan front

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/id/front \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "BASE64_ID_FRONT",
    "getExtractedData": true
  }'
```

**Response `data` fields:**

| Field                                       | Description             |
| ------------------------------------------- | ----------------------- |
| `first_name` / `last_names`                 | Arabic name components  |
| `first_name_english` / `last_names_english` | Transliterated name     |
| `idNumber`                                  | National ID number      |
| `dateOfBirth`                               | Date of birth           |
| `govern` / `city` / `district`              | Address                 |
| `gender`                                    | M / F                   |
| `transaction_id`                            | Use in subsequent steps |

### Scan back

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/id/back \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "BASE64_ID_BACK",
    "transaction_id": "TX_FROM_FRONT"
  }'
```

**Response `data` fields:** `maritalStatus`, `job`, `jobTitle`, `religion`, `husbandName`, `releaseDate`, `idExpiry`, `idNumber`, `gender`

***

## Passport

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/passport \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "BASE64_PASSPORT_IMAGE"
  }'
```

**Response `data` fields:**

| Field            | Description                           |
| ---------------- | ------------------------------------- |
| `passport_no`    | Passport number                       |
| `name`           | Full name                             |
| `nationality`    | Nationality                           |
| `country_code`   | Issuing country ISO code              |
| `gender`         | Gender                                |
| `Date_of_Birth`  | Date of birth                         |
| `Date_of_Expiry` | Expiry date                           |
| `doc_Type`       | Document type (e.g. `P` for passport) |

***

## Car license

### License front (owner information)

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/car/license/front \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"image": "BASE64_LICENSE_FRONT"}'
```

**Response `data` fields:** `license_number`, `license_type`, `name`, `nationality`, `address`, `expiry`, `issuance`, `traffic_unit`

### License back (vehicle information)

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/car/license/back \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"image": "BASE64_LICENSE_BACK"}'
```

**Response `data` fields:** `model_year`, `type`, `sub_type`, `chasis`, `volume`, `motor`, `color`, `fuel`, `cylinder`, `examination_dt`

***

## Driving license

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/driving_license \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"image": "BASE64_DRIVING_LICENSE"}'
```

**Response `data` fields:** `NameArabic`, `NameEnglish`, `NationalID`, `NationalityArabic`, `NationalityEnglish`, `LicenseType`, `Job`, `Address`, `ExpiryDate`, `IssuenceDate`, `TrafficUnit1`, `TrafficUnit2`

***

## Face recognition

### Face match (face vs. ID photo)

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

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/face/match \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "BASE64_FACE_IMAGE",
    "transaction_id": "TX_WITH_ID_FRONT"
  }'
```

**Response `data` fields:**

| Field                    | Description                                        |
| ------------------------ | -------------------------------------------------- |
| `isMatched`              | Whether the face matches the ID photo              |
| `dissimilarity`          | Distance score (lower = more similar)              |
| `threshold`              | Match threshold used (default `2.4`)               |
| `score`                  | Match confidence score                             |
| `detected_face_image`    | Whether a face was detected in the submitted image |
| `detected_id_face_image` | Whether a face was detected in the ID photo        |

### Face compare (two faces)

Compare any two face images directly, without requiring an ID transaction.

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/face/compare \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "face_image1": "BASE64_FACE_1",
    "face_image2": "BASE64_FACE_2",
    "liveness": "2"
  }'
```

**Response `data` fields:** same as Face Match — `isMatched`, `dissimilarity`, `threshold`, `score`

### Liveness detection

Verify that a face image is from a live person, using three frames captured in quick succession.

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/liveness/multi \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "face_1": "BASE64_FACE_1",
    "face_2": "BASE64_FACE_2",
    "face_3": "BASE64_FACE_3",
    "transaction_id": "TX_WITH_ID_FRONT"
  }'
```

All three images must be of the same person and captured within 0.5 seconds of each other. Compress each to under 500 KB.

***

## License plate recognition

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/license_plate \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"image": "BASE64_CAR_IMAGE"}'
```

**Response `data` fields:** `result` — the extracted plate text

***

## Document classification

Identify the type of document in an image before processing it with a specific endpoint.

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/classification \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"image": "BASE64_DOCUMENT"}'
```

**Response `services.classification.doc_type`** returns the detected type (e.g., `national_id`, `passport`, `driving_license`).

***

## File upload variants

Every endpoint has an equivalent `/file` variant that accepts a `multipart/form-data` upload instead of base64:

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/passport/file \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -F "file=@passport.jpg"
```

***

## AML validation

Check a name or ID number against criminal and AML records.

```bash
curl -X POST https://api.vlenseg.com/v1/ocr/aml/validate \
  -H "ApiKey: YOUR_API_KEY" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "idNumber": "29901234567890",
    "name": "Ahmed Mohamed"
  }'
```

***

## OCR vs. Digital Identity verify

|                                      | OCR API (`/v1/ocr/`) | Digital Identity (`/api/DigitalIdentity/verify/`) |
| ------------------------------------ | -------------------- | ------------------------------------------------- |
| Requires user registration           | No                   | Yes                                               |
| Links result to a user account       | No                   | Yes                                               |
| Sets `isDigitalIdentityVerified`     | No                   | Yes                                               |
| Suitable for standalone extraction   | Yes                  | No                                                |
| Includes NTRA / CSO authority checks | No                   | Yes (configurable)                                |

Use the OCR API when you need raw document extraction or biometric checks without tying the result to a Vlens user. Use the Digital Identity verify flow when you need the result to count toward a user's verification status.