# Extracting and validating documents

> This section shows how to build a process that downloads an invoice, extracts data with UiPath Document Understanding™, routes a **Document Validation** task to a user, and completes on approval.

This section shows how to build a process that downloads an invoice, extracts data with UiPath Document Understanding™, routes a **Document Validation** task to a user, and completes on approval.

To build this process, you need to achieve the following objectives:

* Create an RPA workflow to download an invoice, extract fields, and generate validation artifacts.
* Create an Action App to validate the extracted content.
* Model a Maestro process that runs the RPA workflow, hands off to a user for validation, and finishes on approval.

## Prerequisites

* You need access to Maestro, Orchestrator (shared folder and storage bucket), Studio Web, and Apps.
* You need a Document Understanding extractor/classifier configured for invoices.
* You need a sample invoice URL (publicly reachable or hosted in your environment).
* Create or open a Solution in Studio Web, and add a Maestro process. Read how to [model a process](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/model-your-process).
* Ensure you can publish to your target Orchestrator folder and have a defined storage bucket.
* Ensure your Document Understanding model (extractor/classifier) is available to the RPA workflow.

## Step 1 - Building and publishing the RPA workflow in Studio Web

To build and publish the RPA workflow in Studio Web, take the following steps:

1. Create a new RPA project (e.g., **Document Extraction**).
2. Add the following activities:
   * **Download File from URL**. Add the invoice URL as input.
   * **Extract Document Data**. Use your DU model and include classification if applicable.
   * **Create Document Validation Artifacts**. Configure the shared Orchestrator folder and the storage bucket.
3. Test the workflow locally in Studio Web.
4. Publish the workflow to Orchestrator.

   **Result:** The RPA workflow is published to Orchestrator and ready for use in a Maestro process.

   ![RPA process extract document](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-rpa-process-extract-document-616733-64502af3.webp)

   ![extract document data](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-extract-document-data-616737-c616b3ea.webp)

## Step 2 - Building and publishing the Action App in Studio Web

To build and publish the Action App in Studio Web, take the following steps:

1. Create an **Action App task** named **Document Validation**.
2. In the **Action schema**, add an input property (for example, `validationData`) of type **ContentValidationData**.
3. Add the **validation control** to the App, and set its data source to the `validationData` property.
4. Publish the Action App.

   **Result:** The Action App is published and ready to be assigned as a user task.

   ![Action App task configured for document validation](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-app-task-616752-281e2197.webp)

   ![validation control](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-validation-control-616756-dae55680.webp)

## Step 3 - Modeling the agentic process in Maestro

To model the process in Maestro, take the following steps:

1. Add a **Start event**.
   * Use **None** (manual) for testing, or **Message** if you plan to trigger externally.
2. Add a **Service task – Run extraction**.
   * Implementation: **Start and wait for RPA workflow**.
   * Select the workflow you published in [Step 1 - Build and publish the RPA workflow (Studio Web)](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/how-to-document-extraction-and-validation).
   * Map inputs (e.g., Invoice URL).
   * Capture outputs. Maestro exposes them as variables.
3. Add a **User task – Validate Document Extraction**.
   * Implementation: **Create action app task**.
   * Select the **Document Validation** Action App from [Step 2](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/how-to-document-extraction-and-validation).
   * Map the user task input to the extraction output (bind to the `ContentValidationData` payload).
4. Add an **Exclusive gateway** to branch on the user’s decision.
   * **Approve**: proceed to **End**.
   * **Reject**: route to a correction branch (optional) or loop back to RPA.

   **Result:** The agentic process connects the RPA workflow, validation task, and approval gateway.

   ![document extraction agentic process](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-document-extraction-agentic-process-616748-39d9e69d.webp)

## Step 4 - Publishing, running and validating the Maestro process

To publish, run and validate the Maestro process, take the following steps:

1. Publish and deploy the Maestro process. Read more about [publishing](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/publishing-deploying-and-upgrading-agentic-processes).
2. Start a **Debug** run from the Start event.
3. When the **Document Validation** task is created, open it from the running instance.
4. Review the extracted fields in the validation control. Select **Approve** to continue the flow.
5. After completion, inspect **Variables** to see the stored `documentValidation` data and references to artifacts in your storage bucket.

   **Result:** The process runs end to end: the invoice is extracted, a validation task is created, and the result is stored in your storage bucket.

   ![expand variable](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-expand-variable-616762-7ebd11ba.webp)

   ![information variable](https://dev-assets.cms.uipath.com/assets/images/maestro/maestro-information-variable-616766-b69976b2.webp)
