> ## Documentation Index
> Fetch the complete documentation index at: https://docs.go.gbgplc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Document Extraction

export const VersionWarningBanner = () => {
  const [latestUrl, setLatestUrl] = useState(null);
  useEffect(() => {
    if (typeof window === "undefined") return;
    const {pathname, hash, search} = window.location;
    if (!pathname.includes("/go-v1/")) return;
    setLatestUrl(`${pathname.replace("/go-v1/", "/go-v2/")}${search}${hash}`);
  }, []);
  if (!latestUrl) return null;
  return <div className="not-prose my-6 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-gray-800 dark:text-gray-100">
      ⚠️ You are viewing the <strong>GBG GO v1</strong> documentation.
      <a href={latestUrl} className="ml-2 font-medium underline text-amber-700 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-300">
        View the latest version (v2) →
      </a>
    </div>;
};

<VersionWarningBanner />

The **Document Extraction** module reads a previously classified identity document and extracts data fields from it, such as name, date of birth, document number, and expiry date.

The module allows you to configure which extracted fields are required, and the overall success of the extraction is determined by whether all required fields were successfully captured.

## Document Extraction

The Document Extraction module extracts all fields from the previously classified document. The module allows customers to specify what data is required. Success of the extraction process will be determined by the completion of all required extraction selections.

### Capabilities

The module returns four capabilities: an overall extraction result, the document's expiry status, a calculated age derived from the extracted date of birth, and the number of days since the document expired.

#### Document extraction result

This capability provides the overall outcome of the extraction process. The result is determined by whether all fields marked as required in the module configuration were successfully extracted from the document.

| Value                     | Description                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Extraction Successful`   | All required fields were successfully extracted from the document. The extracted data is available in the journey context for downstream modules to consume. Fields that were configured as optional may or may not have been extracted — this result only confirms that all required fields are present.                                                                                                                |
| `Extraction Unsuccessful` | One or more required fields could not be extracted. This may occur when the image quality is too poor for OCR to read certain regions, when a required field is not present on the document type (e.g. requesting a middle name from a document format that does not include one), or when the document's layout does not match any known template closely enough for field-level extraction. This is the default value. |

#### Document expiry status

Provides the document's Expiry status -  Has the document expired or is it still valid? If the Expiry Date is not extracted, "Undeterminable" will be returned.

| Value            | Description                                                                                                                                                                                                                                                                                                                                                          |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Expired`        | The document's expiry date has passed. The document is no longer valid according to its issuing authority's stated validity period. Depending on your policy, this may trigger rejection or a request for the user to submit a current document.                                                                                                                     |
| `Not Expired`    | The document's expiry date has not yet passed. The document is still within its valid period.                                                                                                                                                                                                                                                                        |
| `Undeterminable` | The document's expiry status could not be determined. This occurs when the expiry date field was not successfully extracted from the document, either because the image quality was insufficient to read it, or because the document type does not include an expiry date (e.g. some national ID cards are issued without an expiration). This is the default value. |

#### Calculated age

Provides a calculated Age (in years) based on date of birth and current date. If the Date of Birth is not extracted, 0 will be returned.

| Detail  | Description |
| ------- | ----------- |
| Type    | Integer     |
| Range   | 0–130       |
| Default | `0`         |

If the date of birth was successfully extracted, the module calculates the subject's current age in whole years. This value can be used in downstream evaluation rules, for example to enforce a minimum age threshold without requiring a separate Age Verification module.

If the date of birth could not be extracted, the value defaults to `0`. Evaluation rules that depend on this capability should account for the default value. A calculated age of `0` indicates a missing date of birth, not a subject aged zero.

#### Days since expiry

Provides the number of whole days since the document's Expiry Date. Returns 0 when the document has not expired, or when the Expiry Date could not be determined. Important: when authoring a threshold rule, always combine this with Document Expiry Status = Expired, because Not Expired and Undeterminable documents also return 0 — a rule on Days Since Expiry alone (for example, \<= 730) would match those too. Example: 'Document Expiry Status is Expired AND Days Since Expiry \<= 730' accepts only documents that expired within a 730-day / \~2-year grace period.

| Detail  | Description |
| ------- | ----------- |
| Type    | Integer     |
| Range   | 0–36500     |
| Default | `0`         |

Use this capability to set an expiry threshold in evaluation rules. You select an operator and a number of days to define how long after expiry a document remains acceptable. The supported operators are greater than, less than, greater than or equal to, less than or equal to, and equal to.

For example, some Australian anti-money laundering and counter-terrorism financing policies accept a passport for up to two years after it expires. To enforce this, set the rule to days since expiry less than or equal to `730`. If the expiry date is `730` days or fewer in the past, then the document passes. If it is more than `730` days in the past, then the document fails.

Always combine this capability with document expiry status set to `Expired` in your evaluation rules. Otherwise, the rule also matches documents that have not expired or whose expiry status is undeterminable, because both return a value of `0`.

#### Anchor image extracted

Indicates whether the anchor (portrait) image was successfully extracted from the document. When false, downstream facematch can be skipped as there is no anchor image to compare against.

| Detail  | Description |
| ------- | ----------- |
| Type    | Boolean     |
| Default | `isFalse`   |

### Default outcomes

The module is pre-configured with the following default outcomes, which can be used in evaluation and routing logic within the journey designer.

| Outcome                   | Condition                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                           |
| ------------------------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Extraction Successful`   | Extraction result is `Extraction Successful`   | All required fields were successfully extracted. The journey can proceed to downstream modules that consume the extracted data, such as [**Data Verification**](/docs/go-v1/platform/modules/data/data-verification), [**Document Authentication**](/docs/go-v1/platform/modules/documents/document-authentication), or [**Facematch Verification**](/docs/go-v1/platform/modules/biometrics/facematch-verification). |
| `Extraction Unsuccessful` | Extraction result is `Extraction Unsuccessful` | One or more required fields could not be extracted. The journey may route to a retry step (prompting the user to recapture the document), manual review, or rejection depending on the configured evaluation logic.                                                                                                                                                                                                   |
| `ERROR`                   | Default (no conditions matched)                | An unexpected error occurred during processing.                                                                                                                                                                                                                                                                                                                                                                       |

<Note>
  This module does not require its own input payload. It runs off of the document images already captured by the [**Document Classification**](/docs/go-v1/platform/modules/documents/document-classification) module earlier in the journey.
</Note>

### Sample response

The following is a sample response for an unsuccessful extraction where the document was expired and some required fields could not be extracted.

```json JSON theme={null}
{
  "response": {
    "advice": {
      "documentExpiryStatus": "Expired",
      "addressStringIsPresent": false,
      "expiryDateIsPresent": true,
      "documentNumberIsPresent": true,
      "dateOfBirthIsPresent": false,
      "issueDateIsPresent": true,
      "firstNameIsPresent": true,
      "lastNamesIsPresent": true,
      "extractionResult": "Extraction Unsuccessful"
    },
    "outcome": "Extraction Unsuccessful"
  }
}
```

### Input payload

The following is a sample payload used to submit data to the **Document extraction** module for processing.

```json JSON theme={null}
{
  "context": {
    "subject": {
      "documents": [],
      "identity": {}
    }
  }
}
```

| Field                            | Required | Description                                                     |
| -------------------------------- | -------- | --------------------------------------------------------------- |
| `PrimaryDocument/classification` | Yes      | The document type to classify the primary identity document as. |

## Document Extraction V2

### Capabilities

#### Document extraction result

Provides an extraction result based on the customer's required extraction data (as defined in configuration).

| Value                     | Description             |
| ------------------------- | ----------------------- |
| `Extraction Successful`   | Extraction Successful   |
| `Extraction Unsuccessful` | Extraction Unsuccessful |

#### Document expiry status

Provides the document's Expiry status -  Has the document expired or is it still valid? If the Expiry Date is not extracted, "Undeterminable" will be returned.

| Value            | Description                                     |
| ---------------- | ----------------------------------------------- |
| `Expired`        | Document has expired.                           |
| `Not Expired`    | Document has not expired.                       |
| `Undeterminable` | Document expiry status could not be determined. |

#### Calculated age

Provides a calculated Age (in years) based on date of birth and current date. If the Date of Birth is not extracted, 0 will be returned.

| Detail  | Description |
| ------- | ----------- |
| Type    | Integer     |
| Range   | 0–130       |
| Default | `0`         |

#### Days since expiry

Provides the number of whole days since the document's Expiry Date. Returns 0 when the document has not expired, or when the Expiry Date could not be determined. Important: when authoring a threshold rule, always combine this with Document Expiry Status = Expired, because Not Expired and Undeterminable documents also return 0 — a rule on Days Since Expiry alone (for example, \<= 730) would match those too. Example: 'Document Expiry Status is Expired AND Days Since Expiry \<= 730' accepts only documents that expired within a 730-day / \~2-year grace period.

| Detail  | Description |
| ------- | ----------- |
| Type    | Integer     |
| Range   | 0–36500     |
| Default | `0`         |

#### Anchor image extracted

Indicates whether the anchor (portrait) image was successfully extracted from the document. When false, downstream facematch can be skipped as there is no anchor image to compare against.

| Detail  | Description |
| ------- | ----------- |
| Type    | Boolean     |
| Default | `isFalse`   |

### Input payload

The following is a sample payload used to submit data to the **Document Extraction V2** module for processing.

```json JSON theme={null}
{
  "context": {
    "subject": {
      "documents": [],
      "identity": {}
    }
  }
}
```

| Field                            | Required | Description                                         |
| -------------------------------- | -------- | --------------------------------------------------- |
| `PrimaryDocument/classification` | Yes      | \[Describe.] {/* TODO: written by the docs team */} |

### Sample response

The following is a sample response returned by the module.

```json JSON theme={null}
{
  "response": {
    "advice": {
      "addressStringIsPresent": false,
      "anchorImageExtracted": true,
      "dateOfBirthIsPresent": true,
      "documentExpiryStatus": "Expired",
      "documentNumberIsPresent": true,
      "expiryDateIsPresent": true,
      "extractionResult": "Extraction Successful",
      "firstNameIsPresent": true,
      "issueDateIsPresent": true,
      "lastNamesIsPresent": true
    },
    "outcome": "Extraction Successful"
  }
}
```
