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

# Scan national ID — front

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

Extracts the holder's name, ID number, date of birth, gender and address from the front of an Egyptian national ID. Save the returned `transaction_id` to chain the back scan, face match and liveness steps.

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

## 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 JPEG or PNG. Max 3 MB.
- `transaction_id` (string, optional) — Group multiple steps into one transaction. Omit to start a new one.
- `client_transaction_id` (string, optional) — Your own reference ID.
- `country` (string, optional, default: EGY) — ISO country code. Defaults to `EGY`.
- `getExtractedData` (boolean, optional, default: false) — Include the full extracted fields in the response.

## 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)
  - `name` (string, optional) — Full Arabic name.
  - `firstName` (string, optional) — Arabic first name.
  - `lastName` (string, optional) — Arabic last name.
  - `nameEnglish` (string, optional) — Transliterated full name.
  - `firstNameEnglish` (string, optional) — Transliterated first name.
  - `lastNamesEnglish` (string, optional) — Transliterated last name.
  - `idNumber` (string, optional) — National ID number.
  - `idKey` (string, optional) — ID key.
  - `dateOfBirth` (string, optional) — Date of birth.
  - `gender` (string, optional) — Gender.
  - `govern` (string, optional) — Governorate (Arabic).
  - `governEnglish` (string, optional) — Governorate (English).
  - `address` (string, optional) — Full address (Arabic).
  - `addressEnglish` (string, optional) — Full address (English).
  - `address1` (string, optional) — Address line 1.
  - `address2` (string, optional) — Address line 2.
  - `city` (string, optional) — City.
  - `district` (string, optional) — District.
  - `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": "<base64>",
  "getExtractedData": true
}
```

**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": {
    "name": "string",
    "firstName": "string",
    "lastName": "string",
    "nameEnglish": "string",
    "firstNameEnglish": "string",
    "lastNamesEnglish": "string",
    "idNumber": "string",
    "idKey": "string",
    "dateOfBirth": "string",
    "gender": "string",
    "govern": "string",
    "governEnglish": "string",
    "address": "string",
    "addressEnglish": "string",
    "address1": "string",
    "address2": "string",
    "city": "string",
    "district": "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/id/front"

payload = {
    "image": "<base64>",
    "getExtractedData": True
}
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/id/front';
const options = {
  method: 'POST',
  headers: {ApiKey: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"image":"<base64>","getExtractedData":true}'
};

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/id/front"

	payload := strings.NewReader("{\n  \"image\": \"<base64>\",\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
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\": \"<base64>\",\n  \"getExtractedData\": true\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/id/front")
  .header("ApiKey", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"image\": \"<base64>\",\n  \"getExtractedData\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp
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\": \"<base64>\",\n  \"getExtractedData\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "ApiKey": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "image": "<base64>",
  "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()
```