> ## Documentation Index
> Fetch the complete documentation index at: https://venator-06aff335.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Document OCR

Extract structured data from identity documents by submitting front and back images in base64 format. The service performs Optical Character Recognition (OCR) and returns parsed fields such as name, document number, and date of birth.

<div
  style={{
display: "inline-flex",
alignItems: "center",
background: "#fff",
borderRadius: "12px",
padding: "16px 24px",
border: "1px solid #e5e7eb",
boxShadow: "0 1px 3px rgba(0,0,0,0.05)",
fontFamily: "monospace",
gap: "16px"
}}
>
  <span
    style={{
color: "#2563eb",
fontWeight: "700",
fontSize: "18px",
letterSpacing: "0.5px"
}}
  >
    POST
  </span>

  <span
    style={{
fontSize: "14px",
color: "#4b5563"
}}
  >
    /api/gw/services/document\_ocr
  </span>
</div>

***

### Authorizations

***

### Body

<ResponseField name="frontImageBase64" type="string" required>
  Base64 encoded front image of the document.
</ResponseField>

<ResponseField name="backImageBase64" type="string">
  Base64 encoded back image of the document (if applicable).
</ResponseField>

<ResponseField name="documentType" type="string">
  Type of document (e.g., passport, id\_card, driver\_license).
</ResponseField>

<ResponseField name="documentCountry" type="string">
  Issuing country of the document (ISO3 format recommended).
</ResponseField>

***

### Response

<Tabs>
  <Tab title="200">
    <ResponseField name="success" type="boolean">
      Indicates whether the request was processed successfully.
    </ResponseField>

    <ResponseField name="requestId" type="string">
      Unique identifier for the API request.
    </ResponseField>

    <ResponseField name="correlationId" type="string">
      Identifier used for tracing the request across systems.
    </ResponseField>

    <ResponseField name="data" type="object">
      Contains extracted document details.
    </ResponseField>

    <ResponseField name="data.documentType" type="string">
      Detected document type (e.g., PASSPORT).
    </ResponseField>

    <ResponseField name="data.issuingCountry" type="string">
      Country that issued the document (ISO code).
    </ResponseField>

    <ResponseField name="data.documentNumber" type="string">
      Extracted document number.
    </ResponseField>

    <ResponseField name="data.firstName" type="string">
      Extracted first name.
    </ResponseField>

    <ResponseField name="data.lastName" type="string">
      Extracted last name.
    </ResponseField>

    <ResponseField name="data.dateOfBirth" type="string">
      Extracted date of birth (YYYY-MM-DD).
    </ResponseField>

    <ResponseField name="data.gender" type="string">
      Extracted gender (e.g., M/F).
    </ResponseField>

    <ResponseField name="data.nationality" type="string">
      Extracted nationality (ISO code).
    </ResponseField>

    <ResponseField name="data.issueDate" type="string">
      Document issue date (YYYY-MM-DD).
    </ResponseField>

    <ResponseField name="data.expiryDate" type="string">
      Document expiry date (YYYY-MM-DD).
    </ResponseField>

    <ResponseField name="data.isExpired" type="boolean">
      Indicates whether the document is expired.
    </ResponseField>

    <ResponseField name="data.mrzLine1" type="string">
      Machine-readable zone line 1.
    </ResponseField>

    <ResponseField name="data.mrzLine2" type="string">
      Machine-readable zone line 2.
    </ResponseField>

    <ResponseField name="data.mrzLine3" type="string">
      Machine-readable zone line 3 (if available).
    </ResponseField>

    <ResponseField name="data.confidenceScore" type="number">
      Confidence score for extracted data (0 to 1).
    </ResponseField>

    <ResponseField name="data.portraitImage" type="string">
      Extracted face image in base64 format (data URL).
    </ResponseField>

    <ResponseField name="error" type="object | null">
      Contains error details if the request fails; otherwise null.
    </ResponseField>

    <ResponseField name="durationMs" type="number">
      Time taken to process the request in milliseconds.
    </ResponseField>

    <ResponseField name="processedAt" type="string">
      Timestamp when the request was processed (ISO 8601 format).
    </ResponseField>
  </Tab>

  <Tab title="400">
    <ResponseField name="error" type="string">
      Error message returned when OCR processing fails.
    </ResponseField>
  </Tab>
</Tabs>

***

<RequestExample>
  ```bash Curl theme={null}
  curl -X POST "https://dev-idf-gw.cognetlabs.org/api/gw/services/document_ocr" \
    -H "Content-Type: application/json" \
    -d '{
      "frontImageBase64": "<base64-front>",
      "backImageBase64": "<base64-back>",
      "documentType": "passport",
      "documentCountry": "GBR"
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://dev-idf-gw.cognetlabs.org/api/gw/services/document_ocr"

  payload = {
      "frontImageBase64": "<base64-front>",
      "backImageBase64": "<base64-back>",
      "documentType": "passport",
      "documentCountry": "GBR"
  }

  res = requests.post(url, json=payload)
  print(res.json())
  ```

  ```javascript JavaScript theme={null}
  fetch("https://dev-idf-gw.cognetlabs.org/api/gw/services/document_ocr", {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      frontImageBase64: "<base64-front>",
      backImageBase64: "<base64-back>",
      documentType: "passport",
      documentCountry: "GBR"
    })
  })
  .then(res => res.json())
  .then(console.log);
  ```

  ```php PHP theme={null}
  <?php
  $url = "https://dev-idf-gw.cognetlabs.org/api/gw/services/document_ocr";

  $data = [
    "frontImageBase64" => "<base64-front>",
    "backImageBase64" => "<base64-back>",
    "documentType" => "passport",
    "documentCountry" => "GBR"
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
    "bytes"
    "net/http"
  )

  func main() {
    json := []byte(`{
      "frontImageBase64":"<base64-front>",
      "backImageBase64":"<base64-back>",
      "documentType":"passport",
      "documentCountry":"GBR"
    }`)

    http.Post(
      "https://dev-idf-gw.cognetlabs.org/api/gw/services/document_ocr",
      "application/json",
      bytes.NewBuffer(json),
    )
  }
  ```

  ```java Java theme={null}
  import okhttp3.*;

  public class Main {
    public static void main(String[] args) throws Exception {

      OkHttpClient client = new OkHttpClient();

      String json = "{\"frontImageBase64\":\"<base64-front>\", \"backImageBase64\":\"<base64-back>\", \"documentType\":\"passport\", \"documentCountry\":\"GBR\" }";

      RequestBody body = RequestBody.create(json, MediaType.parse("application/json"));

      Request request = new Request.Builder()
        .url("https://dev-idf-gw.cognetlabs.org/api/gw/services/document_ocr")
        .post(body)
        .build();

      Response response = client.newCall(request).execute();
      System.out.println(response.body().string());
    }
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'uri'
  require 'json'

  uri = URI("https://dev-idf-gw.cognetlabs.org/api/gw/services/document_ocr")

  payload = {
    frontImageBase64: "<base64-front>",
    backImageBase64: "<base64-back>",
    documentType: "passport",
    documentCountry: "GBR"
  }

  http = Net::HTTP.new(uri.host, uri.port)
  request = Net::HTTP::Post.new(uri, {'Content-Type': 'application/json'})
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
  "success":true,
  "requestId":"da0a115e519e",
  "correlationId":"58664e8f17d1452ea3b171e7a90e09bf",
  "data":{
  "documentType":"PASSPORT",
  "issuingCountry":"GBR",
  "documentNumber":"123456789",
  "firstName":"John",
  "lastName":"Doe",
  "dateOfBirth":"1992-05-11",
  "gender":"M",
  "nationality":"GBR",
  "issueDate":"2018-01-01",
  "expiryDate":"2028-01-01",
  "isExpired":false,
  "mrzLine1":"P<GBRDOE<<JOHN<<<<<<<<<<<<<<<<<<<<<<<",
  "mrzLine2":"1234567890GBR9205111M2801012<<<<<<<<<<<<<<",
  "mrzLine3":"",
  "confidenceScore":0.97,
  "portraitImage":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD..."
  },
  "error":null,
  "durationMs":303,
  "processedAt":"2026-04-29T13:59:35.9472104Z"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "FrontImageBase64 is required"
  }
  ```
</ResponseExample>
