Generic JSON Schema
AI extraction should return a predictable JSON envelope. The exact schema can evolve by document type, but the top-level structure should remain stable.
Example payload
{
"document": {
"document_type": "RENTAL_CONTRACT",
"language": "it",
"source_pages": 5,
"overall_confidence": 0.86
},
"parties": [
{
"role": "LANDLORD",
"party_type": "PERSON",
"first_name": {"value": "Mario", "confidence": 0.95},
"last_name": {"value": "Rossi", "confidence": 0.95},
"fiscal_code": {"value": "RSSMRA...", "confidence": 0.81}
}
],
"property": {
"address": {"value": "Via Roma 10", "confidence": 0.92},
"city": {"value": "Milano", "confidence": 0.93},
"cadastral_sheet": {"value": "12", "confidence": 0.74}
},
"contract": {
"contract_type": {"value": "RESIDENTIAL", "confidence": 0.88},
"start_date": {"value": "2026-01-01", "confidence": 0.91},
"end_date": {"value": "2030-12-31", "confidence": 0.89},
"rent_amount": {"value": 1200, "confidence": 0.96},
"payment_due_day": {"value": 5, "confidence": 0.84}
},
"payments": [
{
"due_date": {"value": "2026-02-05", "confidence": 0.86},
"amount": {"value": 1200, "confidence": 0.96},
"currency": {"value": "EUR", "confidence": 0.99}
}
],
"bank_account": {
"iban": {"value": "IT60X...", "confidence": 0.79},
"account_name": {"value": "Mario Rossi", "confidence": 0.73}
}
}
Top-level sections
| Section | Purpose |
|---|---|
document | Document classification, language, page count, and overall confidence. |
parties | Extracted people and companies with business roles. |
property | Property address, cadastral, and ownership information. |
contract | Contract-level business facts. |
payments | Expected rent, installments, bill payments, or tax payments. |
bank_account | Logical bank account details when present. |
expenses | Invoice or expected cost details when relevant. |
utility | Utility bill or service information when relevant. |
Confidence per field
Each extracted field should contain:
value: the extracted valueconfidence: number from0to1source: optional page or text locationraw_text: optional source text snippet for review
UI behavior
| Confidence range | UI behavior |
|---|---|
>= 0.90 | Show as high-confidence pre-filled value. |
0.70 - 0.89 | Show as editable value with review highlight. |
< 0.70 | Require manual confirmation or leave blank with suggestion. |
Backend behavior
The backend should reject invalid formats even when confidence is high. Examples:
- invalid fiscal code format
- invalid IBAN checksum
- end date before start date
- unsupported currency
- rent amount less than or equal to zero
- missing required party role for a contract