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

# Extract national ID front

POST https://api.vlenseg.com/v1/ocr/id/front
Content-Type: application/json

Extract text and data from the front of an Egyptian national ID. Returns name (Arabic + English), ID number, date of birth, address, gender, and more.

Pass the returned `transaction_id` to `id/back` and `liveness/multi` to group the steps.


Reference: https://docs.vlenseg.com/api-reference/vlens-api/ocr/id-front

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: example-openapi
  version: 1.0.0
paths:
  /v1/ocr/id/front:
    post:
      operationId: id-front
      summary: Extract national ID front
      description: >
        Extract text and data from the front of an Egyptian national ID. Returns
        name (Arabic + English), ID number, date of birth, address, gender, and
        more.


        Pass the returned `transaction_id` to `id/back` and `liveness/multi` to
        group the steps.
      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: Extracted ID front data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OcrVerifyOutput'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScanTransactionInput'
servers:
  - url: https://api.vlenseg.com
components:
  schemas:
    ScanTransactionInput:
      type: object
      properties:
        image:
          type: string
          description: Base64-encoded JPEG/PNG image of the document side.
        name_check_value:
          type:
            - string
            - 'null'
          description: Optional name to cross-validate against OCR-extracted data.
        transaction_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Continue an existing transaction. Omit to start a new transaction;
            the ID is returned in the response.
        client_transaction_id:
          type:
            - string
            - 'null'
          description: Your own reference ID for this verification transaction.
        request_id:
          type:
            - string
            - 'null'
        country:
          type:
            - string
            - 'null'
          description: ISO 3166-1 alpha-2 country code. Defaults to `EG`.
        getExtractedData:
          type: boolean
          default: false
          description: Include OCR-extracted fields in the response.
      required:
        - image
      description: Input for ID document scanning (front or back).
      title: ScanTransactionInput
    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
    UserBasicInfo:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type:
            - string
            - 'null'
        surname:
          type:
            - string
            - 'null'
        fullName:
          type:
            - string
            - 'null'
        userName:
          type:
            - string
            - 'null'
        emailAddress:
          type:
            - string
            - 'null'
          format: email
        phoneNumber:
          type:
            - string
            - 'null'
        idNumber:
          type:
            - string
            - 'null'
          description: Egyptian national ID number.
        address:
          type:
            - string
            - 'null'
      description: Core profile information for a registered user.
      title: UserBasicInfo
    IdFrontStepApiOutput:
      type: object
      properties:
        first_name:
          type:
            - string
            - 'null'
        last_names:
          type:
            - string
            - 'null'
        name:
          type:
            - string
            - 'null'
          description: Full Arabic name (computed).
        first_name_english:
          type:
            - string
            - 'null'
        last_names_english:
          type:
            - string
            - 'null'
        name_english:
          type:
            - string
            - 'null'
        address:
          type:
            - string
            - 'null'
        address_1:
          type:
            - string
            - 'null'
        address_2:
          type:
            - string
            - 'null'
        address_english:
          type:
            - string
            - 'null'
        govern:
          type:
            - string
            - 'null'
          description: Governorate (Arabic).
        govern_english:
          type:
            - string
            - 'null'
        city:
          type:
            - string
            - 'null'
        district:
          type:
            - string
            - 'null'
        idNumber:
          type:
            - string
            - 'null'
        idKey:
          type:
            - string
            - 'null'
        dateOfBirth:
          type:
            - string
            - 'null'
          format: date-time
        gender:
          type:
            - string
            - 'null'
        transaction_id:
          type: string
          format: uuid
        request_id:
          type: string
          format: uuid
        client_transaction_id:
          type:
            - string
            - 'null'
      description: OCR-extracted data from the front of the national ID.
      title: IdFrontStepApiOutput
    IdBackStepApiOutput:
      type: object
      properties:
        maritalStatus:
          type:
            - string
            - 'null'
        marital_status_english:
          type:
            - string
            - 'null'
        job:
          type:
            - string
            - 'null'
        job_english:
          type:
            - string
            - 'null'
        jobTitle:
          type:
            - string
            - 'null'
        job_title_english:
          type:
            - string
            - 'null'
        religion:
          type:
            - string
            - 'null'
        religion_english:
          type:
            - string
            - 'null'
        husbandName:
          type:
            - string
            - 'null'
        husbandName_english:
          type:
            - string
            - 'null'
        releaseDate:
          type:
            - string
            - 'null'
          format: date-time
        idExpiry:
          type:
            - string
            - 'null'
          format: date-time
        idNumber:
          type:
            - string
            - 'null'
        gender:
          type:
            - string
            - 'null'
        gender_english:
          type:
            - string
            - 'null'
        transaction_id:
          type: string
          format: uuid
        request_id:
          type: string
          format: uuid
        client_transaction_id:
          type:
            - string
            - 'null'
      description: OCR-extracted data from the back of the national ID.
      title: IdBackStepApiOutput
    DigitalIdentityVerificationOutput:
      type: object
      properties:
        isVerificationProcessCompleted:
          type: boolean
          description: >-
            Whether all three steps (ID front, ID back, liveness) have been
            submitted.
        isDigitalIdentityVerified:
          type:
            - boolean
            - 'null'
          description: >-
            Whether the user is fully verified, including any required NTRA/CSO
            authority checks.
        deviceInfo:
          type:
            - string
            - 'null'
        user:
          $ref: '#/components/schemas/UserBasicInfo'
        idFrontData:
          $ref: '#/components/schemas/IdFrontStepApiOutput'
        idBackData:
          $ref: '#/components/schemas/IdBackStepApiOutput'
      description: Combined result of the Digital Identity verification process.
      title: DigitalIdentityVerificationOutput
    OcrVerifyOutput:
      type: object
      properties:
        services:
          $ref: '#/components/schemas/ScanServicesOutput'
        data:
          $ref: '#/components/schemas/DigitalIdentityVerificationOutput'
        error_code:
          type:
            - integer
            - 'null'
        error_message:
          type:
            - string
            - 'null'
        error_descriptions:
          oneOf:
            - description: Any type
            - type: 'null'
      description: Standard response wrapper for identity verification endpoints.
      title: OcrVerifyOutput
  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_idFront_example
import requests

url = "https://api.vlenseg.com/v1/ocr/id/front"

payload = {
    "image": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
    "getExtractedData": True
}
headers = {
    "ApiKey": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript OCR_idFront_example
const url = 'https://api.vlenseg.com/v1/ocr/id/front';
const options = {
  method: 'POST',
  headers: {ApiKey: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"image":"/9j/4AAQSkZJRgABAQAAAQABAAD...","getExtractedData":true}'
};

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

```go OCR_idFront_example
package main

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

func main() {

	url := "https://api.vlenseg.com/v1/ocr/id/front"

	payload := strings.NewReader("{\n  \"image\": \"/9j/4AAQSkZJRgABAQAAAQABAAD...\",\n  \"getExtractedData\": true\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_idFront_example
require 'uri'
require 'net/http'

url = URI("https://api.vlenseg.com/v1/ocr/id/front")

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\": \"/9j/4AAQSkZJRgABAQAAAQABAAD...\",\n  \"getExtractedData\": true\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.vlenseg.com/v1/ocr/id/front")
  .header("ApiKey", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"image\": \"/9j/4AAQSkZJRgABAQAAAQABAAD...\",\n  \"getExtractedData\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.vlenseg.com/v1/ocr/id/front', [
  'body' => '{
  "image": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
  "getExtractedData": true
}',
  'headers' => [
    'ApiKey' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp OCR_idFront_example
using RestSharp;

var client = new RestClient("https://api.vlenseg.com/v1/ocr/id/front");
var request = new RestRequest(Method.POST);
request.AddHeader("ApiKey", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"image\": \"/9j/4AAQSkZJRgABAQAAAQABAAD...\",\n  \"getExtractedData\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift OCR_idFront_example
import Foundation

let headers = [
  "ApiKey": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "image": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
  "getExtractedData": true
] as [String : Any]

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

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