Integration pattern: Document Processing | Products: Document extraction (pay stubs, W-2s, 1099s, tax returns) | Demo: Document Processing
Get started
Run the demo
Clone and run the Document Processing demo to upload documents, validate them, and extract structured data locally.Open
http://localhost:5173, select Mortgage > Document Processing, and process the pre-loaded test pay stubs. You can also upload your own PDF, JPEG, or PNG files.See full setup instructions for ngrok and environment configuration.Understand the API flow
The demo follows this sequence:
- Create a user — Your server calls POST /v1/users/ to create a Truv user for the borrower.
- Create a document collection — Your server sends Base64-encoded files to POST /v1/documents/collections/ with the
user_id. Truv validates each file (size, type, readability, uniqueness) and classifies it by document type. - Poll for validation — Your server polls GET /v1/documents/collections// until all files reach
successfulstatus. - Finalize the collection — Your server calls POST /v1/documents/collections//finalize/ to trigger data extraction.
- Receive webhooks — Truv sends a
task-status-updatedwebhook withstatus: donewhen extraction completes. The payload includes alink_id. - Retrieve extracted data — Fetch the income report using the
link_idfrom the webhook via GET /v1/links//income/report/.
Review the code
Each step maps to a specific file in the demo. Use these as reference when building your integration.
| Step | Demo file | API reference |
|---|---|---|
| Collection creation | server/routes/upload-documents.js | POST /v1/documents/collections/ |
| Validation polling | src/demos/UploadDocuments.jsx | GET /v1/documents/collections// |
| Finalization | server/routes/upload-documents.js | POST /v1/documents/collections//finalize/ |
| Webhook verification | server/webhooks.js | Webhook events |
| Report retrieval | server/routes/upload-documents.js | Link income report |
Mortgage-specific configuration
Supported document types
| Document | Use case | Fields extracted |
|---|---|---|
| Pay stubs | Income verification | Employer, gross/net pay, deductions, pay period |
| W-2 forms | Annual income | Wages, federal/state taxes, employer EIN |
| 1099 forms (NEC, MISC, DIV) | Self-employed income | Non-employee compensation, payer info |
| Tax returns (1040) | Filed income | AGI, tax liability, filing status |
Common document combinations
Purchase / Refinance (employed borrower):- 2 most recent pay stubs
- Most recent W-2
- Prior year W-2 (if available)
- 1099 forms
- 1040 tax return
- Bank statements (for asset verification)
GSE compliance
Document-extracted data supports Fannie Mae D1C and Freddie Mac AIM. Every document is checked against 50M+ verified pay stubs for fraud detection. The output report uses the same schema as direct payroll connections — no changes to your LOS integration or underwriting workflow.Document upload via Bridge
When document upload is enabled in the Truv Dashboard, borrowers who can’t connect their payroll provider can upload documents directly within the Truv Bridge widget. Documents uploaded through Bridge are identified bydata_source: "docs" in the response.
Next steps
Implementation Guide
Complete API walkthrough for Document Collections
Document Collections API
Full API reference for upload, validate, finalize, and retrieve
Fraud & Manual Review
Handle fraud detection and document errors
GSE Testing
Test with Fannie Mae and Freddie Mac report IDs