---
title: "Validate Document Endpoint"
method: POST
path: "/api/setup-with-us/validate-document"
tags: ["setup-with-us"]
---

# Validate Document Endpoint

`POST /api/setup-with-us/validate-document`

## Request

- Base URL: `https://api.taxcompass.it` (the document declares no server; this is the origin it was published from)
- URL: `https://api.taxcompass.it/api/setup-with-us/validate-document`
- Auth: none declared

## Response `200`

Successful Response

- DocumentValidationResponse: ``POST /validate-document`` payload — the verdict, its slot, and its proof. ``token`` is the HMAC that ties this verdict to this document and this moment (see :mod:`app.services.verdict_tokens`). The client must hand it back in :class:`SetupSubmitRequest.document_tokens` under the same key it files the verdict under; ``/submit`` refuses a verdict that arrives without it.
  - `verdict` DocumentVerdict, required: The AI's read of one uploaded document — the only thing we keep. ``sufficient`` is the gate the UI loop keys on: a document is sufficient only when it's the right type, legible, not expired, and carries the fields that step needs. When it isn't, ``issues`` says what to fix and ``mismatches`` says where the document disagrees with what the user typed.
    - `doc_type_matches` boolean
    - `detected_doc_type` 'passport' | 'permesso_di_soggiorno' | 'codice_fiscale' | 'tessera_sanitaria' | 'proof_of_address' | 'other', nullable
    - `legible` boolean
    - `expired` boolean, nullable
    - `expiry_date` string, nullable
    - `sufficient` boolean
    - `extracted_fields` object
    - `mismatches` string[]
    - `issues` string[]
    - `confidence` number
  - `doc_type` 'passport' | 'permesso_di_soggiorno' | 'codice_fiscale' | 'tessera_sanitaria' | 'proof_of_address' | 'other', required
  - `token` string, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/taxcompass/apis/taxcompass-api.md) · [All operations](https://skmtc.dev/taxcompass/apis/taxcompass-api/llms.txt) · [OpenAPI document](https://skmtc.dev/taxcompass/apis/taxcompass-api/revisions/fef5fc6a9b91?raw)
