Skip to main content

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

SectionPurpose
documentDocument classification, language, page count, and overall confidence.
partiesExtracted people and companies with business roles.
propertyProperty address, cadastral, and ownership information.
contractContract-level business facts.
paymentsExpected rent, installments, bill payments, or tax payments.
bank_accountLogical bank account details when present.
expensesInvoice or expected cost details when relevant.
utilityUtility bill or service information when relevant.

Confidence per field

Each extracted field should contain:

  • value: the extracted value
  • confidence: number from 0 to 1
  • source: optional page or text location
  • raw_text: optional source text snippet for review

UI behavior

Confidence rangeUI behavior
>= 0.90Show as high-confidence pre-filled value.
0.70 - 0.89Show as editable value with review highlight.
< 0.70Require 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