> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/caf-api/core-api/transaction-details/services/global-doc-reader.md).

# Global Document Reader

The Global Document Reader service processes identity documents, identifying the country and type of document, as well as extracting the information contained within.

**Section**: `globalDocReader`

**Required parameter:** `documentCountry` and `files (any document images)`

## Fields and rules

Check out the examples, rules, and attributes for the service to function.

{% tabs %}
{% tab title="Schema" %}

| Attribute                                                 | Type                  | Description                                                                                                                                 |
| --------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| statusCode                                                | string                | Refers to the status of this specific query, not the entire transaction. [Check our status guide](/caf-api/core-api/transaction-details.md) |
| data                                                      | object                | Object containing the main data.                                                                                                            |
| data.files                                                | array                 | Files resulting from processing.                                                                                                            |
| data.files\[x].name                                       | [FileName](#filename) | File name.                                                                                                                                  |
| data.files\[x].url                                        | string                | File URL.                                                                                                                                   |
| data.documentType                                         | object                | Information about the document.                                                                                                             |
| data.documentType.isoAlpha2CountryCode                    | string                | Country issuing the document (ISO 3166-1 alpha 2).                                                                                          |
| data.documentType.isoAlpha3CountryCode                    | string                | Country issuing the document (ISO 3166-1 alpha 3).                                                                                          |
| data.documentType.type                                    | [DocType](#doctype)   | Type of document.                                                                                                                           |
| data.textFields                                           | object                | Information extracted from the document.                                                                                                    |
| data.textFields.fields                                    | object                | Fields of document. The list of fields can be viewed [here](#fields).                                                                       |
| data.textFields.fields.{fieldName}                        | object                | Field of document.                                                                                                                          |
| data.textFields.fields.{fieldName}.value                  | string                | Field value.                                                                                                                                |
| data.textFields.fields.{fieldName}.originalLanguage       | object                | (*Optional*) Information from the field in the document's original language.                                                                |
| data.textFields.fields.{fieldName}.originalLanguage.lang  | string                | Document language.                                                                                                                          |
| data.textFields.fields.{fieldName}.originalLanguage.value | string                | Value of the field in the original language of the document.                                                                                |
| {% endtab %}                                              |                       |                                                                                                                                             |

{% tab title="Example" %}

```json
{
    "statusCode": "01",
    "data": {
        "files": [
            {
                "name": "CROPPED_DOC_FRONT",
                "url": "https://..."
            },
            {
                "name": "CROPPED_DOC_BACK",
                "url": "https://..."
            }
        ],
        "documentType": {
            "isoAlpha2CountryCode": "AR",
            "isoAlpha3CountryCode": "ARG",
            "type": "IDENTITY_CARD"
        },
        "textFields": {
            "fields": {
                "personalNumber": {
                    "value": "00000000000"
                },
                "givenNames": {
                    "value": "JANE DOE",
                    "originalLanguage": {
                        "lang": "Spanish (Argentina)",
                        "value": "JANE DOE"
                    }
                },
                "surname": {
                    "value": "SILVA",
                    "originalLanguage": {
                        "lang": "Spanish (Argentina)",
                        "value": "SILVA"
                    }
                },
                "name": {
                    "value": "SILVA JANE DOE",
                    "originalLanguage": {
                        "lang": "Spanish (Argentina)",
                        "value": "SILVA JANE DOE"
                    }
                },
                "finalCheckDigit": {
                    "value": "0"
                },
                "expirationDateCheckDigit": {
                    "value": "4"
                },
                "expirationDate": {
                    "value": "2035-06-14"
                },
                "mrz": {
                    "value": "IDARG99999999<4<<<<<<<<<<<<<<<^8508085F3506144ARG<<<<<<<<<<<0^SILVA<<JANE<DOE<<"
                },
                "sex": {
                    "value": "F"
                },
                "birthDateCheckDigit": {
                    "value": "5"
                },
                "birthDate": {
                    "value": "1985-08-08"
                },
                "documentNumber": {
                    "value": "99999999"
                },
                "nationalityCode": {
                    "value": "ARG"
                },
                "documentNumberCheckDigit": {
                    "value": "4"
                },
                "controlNumber": {
                    "value": "00000000000"
                },
                "birthPlace": {
                    "value": "CIUDAD DE BUENOS AIRES",
                    "originalLanguage": {
                        "lang": "Spanish (Argentina)",
                        "value": "CIUDAD DE BUENOS AIRES"
                    }
                },
                "identityCardNumber": {
                    "value": "000000000000000"
                },
                "address": {
                    "originalLanguage": {
                        "lang": "Spanish (Argentina)",
                        "value": "EXAMPLE ADDRESS"
                    }
                },
                "issueDate": {
                    "value": "2020-02-20"
                }
            }
        }
    }
}
```

{% endtab %}

{% tab title="Validations Rules" %}

| Rule                                                                               | Description                                                                            |
| ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| The country on the document is the same as the country specified in the parameters | Checks if the country on the document matches the country specified in the parameters. |
| Document not expired                                                               | Check if the document is not expired or does not have an expiration date.              |
| Age ranges not accepted                                                            | Checks if the person is within the configured age range.                               |
| {% endtab %}                                                                       |                                                                                        |
| {% endtabs %}                                                                      |                                                                                        |

{% hint style="info" %}
The returned date format is `yyyy-mm-dd`.

* yyyy = four-digit year
* mm = two-digit month
* dd = two-digit day
  {% endhint %}

## Data types

### FileName

| Value               | Description                           |
| ------------------- | ------------------------------------- |
| `CROPPED_DOC_FRONT` | Front area of ​​the document cut out. |
| `CROPPED_DOC_BACK`  | Back area of ​​the document cut out.  |

### DocType

| Value              | Description                             |
| ------------------ | --------------------------------------- |
| `IDENTITY_CARD`    | Identity document.                      |
| `DRIVER_LICENSE`   | Driver's license or permit.             |
| `PASSPORT`         | Passport.                               |
| `RESIDENCE_PERMIT` | Identity card or permit for foreigners. |
| `VISA`             | Visa.                                   |
| `VOTER_CARD`       | Voter card or voting document.          |
| `UNKNOWN`          | Unknown document.                       |

### Fields

| Value                          | Description                                        |
| ------------------------------ | -------------------------------------------------- |
| `name`                         | Person's full name.                                |
| `givenNames`                   | Person's given names.                              |
| `surname`                      | Person's surname.                                  |
| `socialName`                   | Person's social name.                              |
| `sex`                          | Person's sex or gender.                            |
| `personalNumber`               | Personal identification number.                    |
| `birthDate`                    | Person's date of birth.                            |
| `birthPlace`                   | Place of birth.                                    |
| `nationalityCode`              | Nationality code.                                  |
| `nationality`                  | Person's nationality.                              |
| `address`                      | Person's address.                                  |
| `uniqueNumber`                 | Unique identification number.                      |
| `voterKey`                     | Voter registration key.                            |
| `fatherName`                   | Father's name.                                     |
| `motherName`                   | Mother's name.                                     |
| `documentNumber`               | Document identification number.                    |
| `documentClass`                | Document class or category.                        |
| `expirationDate`               | Document expiration date.                          |
| `issueDate`                    | Document issue date.                               |
| `issuingAuthority`             | Authority that issued the document.                |
| `issuePlace`                   | Place where the document was issued.               |
| `issuingCountryCode`           | Code of the issuing country.                       |
| `issuingStateCode`             | Code of the issuing state (federative unit).       |
| `mrz`                          | Machine Readable Zone (MRZ) data.                  |
| `controlNumber`                | Document control number.                           |
| `optionalData`                 | Optional data field.                               |
| `identityCardNumber`           | Identity card number.                              |
| `identityCardIssuingAuthority` | Authority that issued the identity card.           |
| `identityCardIssuingStateCode` | State code of the identity card issuer.            |
| `dlCategory`                   | Driver's license category.                         |
| `firstIssueDate`               | Date of first document issue.                      |
| `bookletNumber`                | Booklet number.                                    |
| `securityNumber`               | Security or verification number.                   |
| `renachNumber`                 | RENACH (Brazilian driver's license) number.        |
| `notes`                        | Additional notes or observations.                  |
| `entryDate`                    | Entry date or registration date.                   |
| `dlCategoryAccExpirationDate`  | Expiration date for driver's license category ACC. |
| `dlCategoryAExpirationDate`    | Expiration date for driver's license category A.   |
| `dlCategoryA1ExpirationDate`   | Expiration date for driver's license category A1.  |
| `dlCategoryBExpirationDate`    | Expiration date for driver's license category B.   |
| `dlCategoryB1ExpirationDate`   | Expiration date for driver's license category B1.  |
| `dlCategoryCExpirationDate`    | Expiration date for driver's license category C.   |
| `dlCategoryC1ExpirationDate`   | Expiration date for driver's license category C1.  |
| `dlCategoryDExpirationDate`    | Expiration date for driver's license category D.   |
| `dlCategoryD1ExpirationDate`   | Expiration date for driver's license category D1.  |
| `dlCategoryBeExpirationDate`   | Expiration date for driver's license category BE.  |
| `dlCategoryCeExpirationDate`   | Expiration date for driver's license category CE.  |
| `dlCategoryC1eExpirationDate`  | Expiration date for driver's license category C1E. |
| `dlCategoryDeExpirationDate`   | Expiration date for driver's license category DE.  |
| `dlCategoryD1eExpirationDate`  | Expiration date for driver's license category D1E. |
| `optionalDataCheckDigit`       | Check digit for optional data field.               |
| `finalCheckDigit`              | Final check digit for document validation.         |
| `expirationDateCheckDigit`     | Check digit for expiration date.                   |
| `documentNumberCheckDigit`     | Check digit for document number.                   |
| `birthDateCheckDigit`          | Check digit for birth date.                        |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-api/core-api/transaction-details/services/global-doc-reader.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
