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

# OCR and Authenticity

> OCR and Authenticity information for document uploads.

Argyle offers uploaded document processing through <a href="https://www.ocrolus.com/" target="_blank">Ocrolus' optical character recognition (OCR) service</a>. The text within uploaded documents is scanned, and the authenticity of the document is evaluated. The results are made available to view directly in Console or retrieve via Argyle's API.

<Note>
  Ocrolus is available for W-2, 1099, and paystub [document uploads](/workflows/document-processing).
</Note>

<img src="https://mintcdn.com/argyle/X2Ud-Ls5bpXC3Xsk/images/argyle-guides/integrations/document-ocr-processors/1-OCR.png?fit=max&auto=format&n=X2Ud-Ls5bpXC3Xsk&q=85&s=6de9ad37fde8b3ebf60776ae3d35fa3a" alt="Image showing the process of integrating third party OCR data with Argyle." width="2700" height="1260" data-path="images/argyle-guides/integrations/document-ocr-processors/1-OCR.png" />

## Uploading documents

Documents can be uploaded via Argyle's API or directly by users through Argyle Link.

<Note>
  Refer to our [Document Processing Guide](/workflows/document-processing#uploading-documents) for more information on setting up document uploads.
</Note>

## Document classification

After documents are uploaded, you can optionally choose to classify the documents. This classification pre-processing step will return:

* The document type (e.g. paystubs or W-2)
* Key data fields (e.g. pay date or year)

This document information can be used to decide which documents are sent to full OCR data extraction and authenticity analysis (i.e. send only paystubs to full OCR).

<Note>
  If you are interested in document classification, reach out to your Argyle customer success manager.
</Note>

## Retrieving OCR data

<div className="argyle-divider" />

### Console

<img src="https://mintcdn.com/argyle/X2Ud-Ls5bpXC3Xsk/images/argyle-guides/integrations/document-ocr-processors/2-OCR.png?fit=max&auto=format&n=X2Ud-Ls5bpXC3Xsk&q=85&s=15a597c09e758e006539b57076d826f8" alt="Uploaded document OCR information can be viewed by selecting the  JSON toggle within the Connections sections of Console." width="8136" height="5248" data-path="images/argyle-guides/integrations/document-ocr-processors/2-OCR.png" />

1. Select an individual user within the <a href="https://console.argyle.com/connections" target="_blank">Connections</a> section of Console.
2. When viewing **Uploaded documents**:
   * An `OCR` tag is shown when OCR data is available.
   * The **Authenticity** column will display the document's [Authenticity score](/integrations/ocr/ocrolus#authenticity-scores).
3. Click the `{} JSON` toggle to view OCR data and detailed Authenticity information.
   * The [`ocr_data`](/api-reference/user-uploads#object-metadata-ocr_data) object within the JSON will contain the OCR data.
   * The [`ocr_authenticity`](/api-reference/user-uploads#object-metadata-ocr_authenticity) object will contain details on individual instances of tampering or other authenticity-related edits.
   <Note>
     Refer to Ocrolus' documentation for <a href="https://docs.ocrolus.com/docs/capture" target="_blank">data field descriptions</a> and <a href="https://docs.ocrolus.com/docs/authenticity-score" target="_blank">how document authenticity is evaluated</a>.
   </Note>
4. Click the `View summary` button to view a summary of authenticity information for the uploaded document.
   <Note>
     Additional OCR data including employee, employer, and income details will also be shown for paystubs.
   </Note>

<img src="https://mintcdn.com/argyle/X2Ud-Ls5bpXC3Xsk/images/argyle-guides/integrations/document-ocr-processors/3-OCR.png?fit=max&auto=format&n=X2Ud-Ls5bpXC3Xsk&q=85&s=46a236fa361202ed5b0c193b1e16c898" alt="Summary information of document authenticity returned by Ocrolus can be viewed in Console." width="1492" height="1619" data-path="images/argyle-guides/integrations/document-ocr-processors/3-OCR.png" />

### API

Uploaded documents can be retrieved through Argyle's [`/user-uploads`](/api-reference/user-uploads) endpoint.

<Accordion title="Example JSON — Uploaded document with OCR and Authenticity data">
  ```json theme={}
  {
    "id": "0187bf23-cd80-118d-c0b8-58023e21c8e5",
    "account": "01856c65-43b6-8b5d-b32a-56b8fbda5c28",
    "document_type": "paystub",
    "file_url": "www.argyle.com/storagename",
    "file_name": "2024_10_paystub.pdf",
    "status": "submitted",
    "metadata": {
      "ocr_data": {
          "uuid": "d38a23ef-835e-4e72-a5d3-9fefc3e5a989",
          "status": "COMPLETED",
          "net_pay": {
              "totals": {
                  "ytd_pay": {
                      "amount": null,
                      "currency": null
                  },
                  "current_pay": {
                      "amount": "426.93",
                      "currency": "USD"
                  },
                  "description": "NET PAY",
                  "canonical_description": null
              },
              "distribution_details": [
                  {
                      "bank_name": null,
                      "current_pay": {
                          "amount": "426.93",
                          "currency": "USD"
                      },
                      "description": "CHECKING 1699",
                      "account_number": "1699",
                      "bank_account_type": "CHECKING"
                  }
              ]
          },
          "doc_uuid": "3b43a2fb-0b2b-4c9b-a24c-26e216c3426f",
          "earnings": {
              "totals": [
                  {
                      "ytd_pay": {
                          "amount": "1399.80",
                          "currency": "USD"
                      },
                      "current_pay": {
                          "amount": "427.05",
                          "currency": "USD"
                      },
                      "description": "GROSS PAY",
                      "current_hours": "28.47",
                      "canonical_description": null
                  }
              ],
              "subtotals": [
                  {
                      "ytd_pay": {
                          "amount": "1324.80",
                          "currency": "USD"
                      },
                      "current_pay": {
                          "amount": "427.05",
                          "currency": "USD"
                      },
                      "description": "REGULAR",
                      "current_rate": "15.0000",
                      "current_hours": "28.47",
                      "canonical_description": "REGULAR PAY"
                  },
                  {
                      "ytd_pay": {
                          "amount": "75.00",
                          "currency": "USD"
                      },
                      "current_pay": {
                          "amount": "45.00",
                          "currency": "USD"
                      },
                      "description": "SURGE PREM $ 5",
                      "current_rate": "5.000",
                      "current_hours": "9.00",
                      "canonical_description": "OTHER"
                  }
              ]
          },
          "employee": {
              "name": "BOB JONES",
              "address": {
                  "city": null,
                  "line1": "759 VICTORIA PLAZA",
                  "line2": null,
                  "state_code": "NY",
                  "postal_code": "10014"
              },
              "taxpayer_id": {
                  "id_type": null,
                  "last_4_digits": null
              },
              "marital_status": "SINGLE"
          },
          "employer": {
              "name": "WAREHOUSE SERVICES INC",
              "address": {
                  "city": "SEATTLE",
                  "line1": "202 WESTLAKE AVE N",
                  "line2": null,
                  "state_code": "WA",
                  "postal_code": "98109"
              }
          },
          "book_uuid": "b6ded9fb-72b9-45ab-b788-deeeb424bc4b",
          "confidence": "EXACT_MATCH",
          "deductions": {
              "totals": [],
              "subtotals": [
                  {
                      "ytd_pay": {
                          "amount": "20.30",
                          "currency": "USD"
                      },
                      "current_pay": {
                          "amount": "6.85",
                          "currency": "USD"
                      },
                      "description": "MEDICARE TAX",
                      "canonical_description": "MEDICARE TAX"
                  },
                  {
                      "ytd_pay": {
                          "amount": "14.00",
                          "currency": "USD"
                      },
                      "current_pay": {
                          "amount": "9.00",
                          "currency": "USD"
                      },
                      "description": "MO STATE INCOME TAX",
                      "canonical_description": "STATE TAX"
                  },
                  {
                      "ytd_pay": {
                          "amount": "86.79",
                          "currency": "USD"
                      },
                      "current_pay": {
                          "amount": "29.27",
                          "currency": "USD"
                      },
                      "description": "SOCIAL SECURITY TAX",
                      "canonical_description": "SOCIAL SECURITY TAX"
                  }
              ]
          },
          "ocr_page_count": 1,
          "paystub_details": {
              "pay_date": "2020-12-28",
              "pay_frequency": null,
              "paystub_provider": "ADP",
              "pay_period_end_date": "2020-12-26",
              "pay_period_start_date": "2020-12-16",
              "pay_frequency_captured": "NOT LISTED"
          },
          "doc_page_numbers": [
              1
          ],
          "rejection_reason": null,
          "confidence_scores": [
              {
                  "key": "earnings.subtotals[0].current_hours",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[0].ytd_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[2].current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "net_pay.distribution_details[0].account_number",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[0].description",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[0].description",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.totals[0].current_hours",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[1].description",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[0].ytd_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[0].current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "net_pay.distribution_details[0].current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.totals[0].current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "net_pay.distribution_details[0].bank_account_type",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[1].ytd_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[1].ytd_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[2].ytd_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[0].current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[1].current_rate",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[1].current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.totals[0].ytd_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[0].current_rate",
                  "confidence": 1.0
              },
              {
                  "key": "net_pay.totals.current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[1].current_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[2].description",
                  "confidence": 1.0
              },
              {
                  "key": "deductions.subtotals[1].description",
                  "confidence": 1.0
              },
              {
                  "key": "earnings.subtotals[1].current_hours",
                  "confidence": 1.0
              },
              {
                  "key": "employment_details.annual_salary.amount",
                  "confidence": 1.0
              },
              {
                  "key": "employee.address.city",
                  "confidence": 1.0
              },
              {
                  "key": "employee.address.line1",
                  "confidence": 1.0
              },
              {
                  "key": "employee.address.line2",
                  "confidence": 1.0
              },
              {
                  "key": "employee.address.postal_code",
                  "confidence": 1.0
              },
              {
                  "key": "employee.address.state_code",
                  "confidence": 1.0
              },
              {
                  "key": "employee.name",
                  "confidence": 1.0
              },
              {
                  "key": "employer.address.city",
                  "confidence": 1.0
              },
              {
                  "key": "employer.address.line1",
                  "confidence": 1.0
              },
              {
                  "key": "employer.address.line2",
                  "confidence": 1.0
              },
              {
                  "key": "employer.address.postal_code",
                  "confidence": 1.0
              },
              {
                  "key": "employer.address.state_code",
                  "confidence": 1.0
              },
              {
                  "key": "employer.name",
                  "confidence": 1.0
              },
              {
                  "key": "employment_details.hire_date",
                  "confidence": 1.0
              },
              {
                  "key": "employment_details.hourly_rate.amount",
                  "confidence": 1.0
              },
              {
                  "key": "employee.marital_status",
                  "confidence": 1.0
              },
              {
                  "key": "net_pay.totals.ytd_pay.amount",
                  "confidence": 1.0
              },
              {
                  "key": "employment_details.pay_basis",
                  "confidence": 1.0
              },
              {
                  "key": "paystub_details.pay_date",
                  "confidence": 1.0
              },
              {
                  "key": "paystub_details.pay_frequency_captured",
                  "confidence": 1.0
              },
              {
                  "key": "paystub_details.pay_period_end_date",
                  "confidence": 1.0
              },
              {
                  "key": "paystub_details.pay_period_start_date",
                  "confidence": 1.0
              },
              {
                  "key": "paystub_details.paystub_provider",
                  "confidence": 1.0
              },
              {
                  "key": "employee.taxpayer_id.last_4_digits",
                  "confidence": 1.0
              }
          ],
          "employment_details": {
              "hire_date": null,
              "pay_basis": "HOURLY",
              "hourly_rate": {
                  "amount": null,
                  "currency": null
              },
              "annual_salary": {
                  "amount": null,
                  "currency": null
              }
          },
          "uploaded_image_bucket_uuid": null
      },
      "ocr_authenticity": {
          "book_uuid": "e048543d-043f-441a-b1cf-524328034ddf",
          "doc_analysis": [
              {
                  "detect_status": "COMPLETED",
                  "form_analysis": [
                      {
                          "signals": [
                              {
                                  "identifier": "earnings_edits",
                                  "page_number": 1,
                                  "display_name": "Earnings Edits",
                                  "signal_count": 1,
                                  "supporting_data": [
                                      {
                                          "values": [
                                              {
                                                  "key": "field_name",
                                                  "value": "earnings:grossPay(Current)",
                                                  "data_type": "str"
                                              },
                                              {
                                                  "key": "original_text",
                                                  "value": "427.05",
                                                  "data_type": "str"
                                              },
                                              {
                                                  "key": "tampered_text",
                                                  "value": "100.000",
                                                  "data_type": "str"
                                              }
                                          ]
                                      }
                                  ]
                              }
                          ],
                          "form_type": "PAYSTUB",
                          "form_uuid": "83fc263e-4463-4ed1-aeeb-407ed3123178",
                          "form_authenticity": {
                              "score": 40,
                              "version": "1.0",
                              "reason_codes": [
                                  {
                                      "code": "004-H",
                                      "confidence": "HIGH",
                                      "description": "original document recovered"
                                  },
                                  {
                                      "code": "330-H",
                                      "confidence": "HIGH",
                                      "description": "paystub earnings tampered"
                                  }
                              ]
                          }
                      }
                  ],
                  "uploaded_doc_type": "PAYSTUB",
                  "uploaded_doc_uuid": "56fc50b0-d162-43d0-ab1a-809b85b3a3c1",
                  "is_image_based_pdf": false
              }
          ]
      },
      "ocr_authenticity_score": 40
    },
    "created_at": "2023-03-17T10:40:00.672Z",
    "updated_at": "2023-03-17T10:45:20.035Z"
  }
  ```
</Accordion>

The following fields contain OCR and Authenticity related information:

* `ocr_data` — Object. Contains OCR data.
* `ocr_authenticity` — Object. Contains details on individual instances of tampering or other authenticity-related edits made to the uploaded document that were detected.
* `ocr_authenticity_score` — Integer. Single score that captures the likelihood the uploaded document is authentic.

<Note>
  Refer to Ocrolus' documentation for <a href="https://docs.ocrolus.com/docs/capture" target="_blank">data field descriptions</a> and <a href="https://docs.ocrolus.com/docs/authenticity-score" target="_blank">how document authenticity is evaluated</a>.

  <Note>
    Argyle does not return HTTP or Ocrolus-specific status codes returned by the Ocrolus API.
  </Note>
</Note>

## Authenticity scores

Authenticity scores are <a href="https://docs.ocrolus.com/docs/authenticity-score" target="_blank">determined by Ocrolus</a>.

| Score range | Authenticity level    | Examples                                                      |
| ----------- | --------------------- | ------------------------------------------------------------- |
| 0-29        | Very low authenticity | Identity information (SSN, employee name, address) tampering  |
| 30-49       | Low authenticity      | Created as a template, income tampering                       |
| 50-79       | Medium authenticity   | Editing software detected, dates tampering, fields misaligned |
| 80+         | High authenticity     | Document is an image (80 score)                               |

<Note>
  Currently available only for paystub and W-2 document types.
</Note>

## OCR webhooks

Subscribe to the following webhooks to be notified of OCR updates:

* [`user_uploads.ocr_completed`](/api-reference/user-uploads-webhooks/ocr-completed)
* [`user_uploads.ocr_failed`](/api-reference/user-uploads-webhooks/ocr-failed)
* [`user_uploads.ocr_authenticity`](/api-reference/user-uploads-webhooks/ocr-authenticity)

## OCR errors

If an uploaded document cannot be processed by Ocrolus, an `error` object will be returned within the `ocr_data` object.

This `error` object will contain:

* A `status` field listing the <a href="https://docs.ocrolus.com/docs/document-status" target="_blank">Ocrolus document status</a>. For errors, the value will either be `FAILED` or `REJECTED`.
* A `rejection_reason` field listing the <a href="https://docs.ocrolus.com/docs/rejection-reasons" target="_blank">Ocrolus rejection reason</a> for `REJECTED` documents.

The two most common rejection errors are:

* `DOCUMENT TYPE NOT SUPPORTED` — For example, a bank statement was submitted when a paystub was expected.
* `DOCUMENT IS UNREADABLE` — The document was too blurry to read and could not be processed.

```json theme={}
"metadata": {
    "ocr_data": {
        "error": {
            "pk": 80352036,
            "md5": "e623b68dc110aad14158fdba31d40c6f",
            "name": "form/paystubs/4e6ad54c-4232-4459-9e20-96fa721b9a38",
            "uuid": "2cba5abd-3a2d-48a1-b786-0c6d4550d4ea",
            "pages": 1,
            "status": "REJECTED",
            "document_class": "COMPLETE",
            "image_group_pk": null,
            "rejection_reason": "DOCUMENT TYPE NOT SUPPORTED",
            "mixed_uploaded_doc_pk": null,
            "rejection_reason_description": null
        }
    },
    "ocr_authenticity": {},
    "ocr_authenticity_score": null
}
```
