# Consultar um relatório de CNH pelo id

Source: https://minhacnh.doutormultas.com.br/docs/api/referencia/get-api-v1-reports-reportid

Retorna o formato canônico do relatório para a organização autenticada. Enquanto o relatório ainda está sendo processado, `diagnosis` é nulo. Um relatório de outra organização retorna 404. Se `diagnosis.allAlerts` contiver `fines_unverified`, pontos e multas NÃO foram verificados: nunca os informe como zero nem como "sem multas"; o veredito (`diagnosis.status`) continua valendo. `fines_state_only` significa que eles vêm apenas do estado que emitiu a CNH, então infrações registradas em outros lugares podem estar ausentes.

## GET /api/v1/reports/{reportId}

```json
{
  "operationId": "apiAccess.reports.get",
  "summary": "Consultar um relatório de CNH pelo id",
  "description": "Retorna o formato canônico do relatório para a organização autenticada. Enquanto o relatório ainda está sendo processado, `diagnosis` é nulo. Um relatório de outra organização retorna 404. Se `diagnosis.allAlerts` contiver `fines_unverified`, pontos e multas NÃO foram verificados: nunca os informe como zero nem como \"sem multas\"; o veredito (`diagnosis.status`) continua valendo. `fines_state_only` significa que eles vêm apenas do estado que emitiu a CNH, então infrações registradas em outros lugares podem estar ausentes.",
  "tags": [
    "Public API"
  ],
  "parameters": [
    {
      "name": "reportId",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Report"
          },
          "example": {
            "reportId": "rpt_sandbox_0001",
            "externalRef": null,
            "status": "DELIVERED",
            "livemode": false,
            "driver": {
              "id": "drv_sandbox_0001",
              "cpf": "10000000108",
              "name": "ANA BEATRIZ SANDBOX",
              "licenseNumber": "10000000108",
              "licenseCategory": "B",
              "expiryDate": "2030-03-15T00:00:00.000Z",
              "issueState": "SP"
            },
            "diagnosis": {
              "status": "VALID",
              "hasReportData": true,
              "hasPartialData": false,
              "validity": {
                "status": "success",
                "validityStatus": "valid",
                "isExpired": false,
                "daysUntilExpiry": 1200,
                "expiryDate": "2030-03-15T00:00:00.000Z",
                "alerts": []
              },
              "category": {
                "status": "success",
                "category": "B",
                "requiresToxicological": false,
                "alerts": []
              },
              "blocks": {
                "status": "success",
                "hasActiveBlocks": false,
                "totalBlocks": 0,
                "activeBlocks": 0,
                "suspensionsCount": 0,
                "revocationsCount": 0,
                "undetailedCount": 0,
                "alerts": []
              },
              "medicalExams": {
                "status": "success",
                "totalExams": 0,
                "expiredExams": 0,
                "hasExpiredExams": false,
                "alerts": [],
                "exams": []
              },
              "toxicological": {
                "status": "success",
                "hasExam": false,
                "isRequired": false,
                "isExpired": false,
                "daysUntilExpiry": null,
                "expiryDate": null,
                "collectionDate": null,
                "alerts": []
              },
              "provisional": null,
              "pid": null,
              "specializedCourses": null,
              "firstLicenseDate": "2019-01-10",
              "allAlerts": [],
              "diagnosisDate": "2030-01-01T00:00:20.000Z"
            },
            "normalized": {
              "validity": {
                "status": "success",
                "validityStatus": "valid",
                "isExpired": false,
                "daysUntilExpiry": 1200,
                "expiryDate": "2030-03-15T00:00:00.000Z",
                "alerts": []
              },
              "blocks": {
                "status": "success",
                "hasActiveBlocks": false,
                "totalBlocks": 0,
                "activeBlocks": 0,
                "suspensionsCount": 0,
                "revocationsCount": 0,
                "undetailedCount": 0,
                "alerts": []
              },
              "medicalExams": {
                "status": "success",
                "totalExams": 0,
                "expiredExams": 0,
                "hasExpiredExams": false,
                "alerts": [],
                "exams": []
              },
              "toxicological": {
                "status": "success",
                "hasExam": false,
                "isRequired": false,
                "isExpired": false,
                "daysUntilExpiry": null,
                "expiryDate": null,
                "collectionDate": null,
                "alerts": []
              },
              "points": null,
              "fines": null
            },
            "aiAnalysis": null,
            "details": null,
            "holderConsent": null,
            "createdAt": "2030-01-01T00:00:00.000Z",
            "deliveredAt": "2030-01-01T00:00:20.000Z"
          }
        }
      }
    },
    "401": {
      "description": "`UNAUTHORIZED`: o cabeçalho `Authorization` está ausente ou malformado, ou a chave foi revogada.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "403": {
      "description": "`FORBIDDEN`: chave válida, mas a API está desativada para a organização. Com `data.reason: \"holder_consent_disabled\"`, a autorização do titular não está disponível para ela.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "404": {
      "description": "`NOT_FOUND`: o `reportId` não existe ou pertence a outra organização.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "500": {
      "description": "`INTERNAL_SERVER_ERROR`: erro interno; avise o suporte.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ]
}
```

### Schemas

#### Report

```json
{
  "type": "object",
  "properties": {
    "reportId": {
      "type": "string"
    },
    "externalRef": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "enum": [
        "PROCESSING",
        "DELIVERED",
        "ERROR"
      ],
      "type": "string"
    },
    "livemode": {
      "type": "boolean",
      "description": "`false` para um relatório de sandbox (`cnh_test_`)."
    },
    "driver": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "cpf": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "licenseNumber": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "licenseCategory": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "expiryDate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "ISO 8601."
        },
        "issueState": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "cpf",
        "name",
        "licenseNumber",
        "licenseCategory",
        "expiryDate",
        "issueState"
      ]
    },
    "diagnosis": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "status": {
              "enum": [
                "VALID",
                "WARNING",
                "TOXICOLOGICAL_EXPIRED",
                "BLOCKED",
                "EXPIRED",
                "UNKNOWN",
                "NO_LICENSE"
              ],
              "type": "string",
              "description": "O veredito. `NO_LICENSE` é uma consulta bem-sucedida: o CPF não tem CNH emitida. `TOXICOLOGICAL_EXPIRED`: o exame toxicológico exigido pela categoria está vencido ou ausente, sem bloqueio e com a CNH válida. Novos valores podem ser acrescentados: trate um valor desconhecido como `WARNING`."
            },
            "hasReportData": {
              "type": "boolean"
            },
            "hasPartialData": {
              "type": "boolean"
            },
            "validity": {
              "type": "object",
              "additionalProperties": {},
              "description": "Validade e vencimento da CNH."
            },
            "category": {
              "type": "object",
              "additionalProperties": {},
              "description": "Categoria da CNH e se ela exige exame toxicológico."
            },
            "blocks": {
              "type": "object",
              "additionalProperties": {},
              "description": "Bloqueios federais e estaduais, suspensões e cassações. `undetailedCount` conta os impedimentos que o registro informa sem data nem motivo: eles não são bloqueios, nunca ativam `hasActiveBlocks` e aparecem como `status: warning` com um alerta `federal_block_undetailed`."
            },
            "medicalExams": {
              "type": "object",
              "additionalProperties": {},
              "description": "Situação dos exames médicos."
            },
            "toxicological": {
              "type": "object",
              "additionalProperties": {},
              "description": "Situação do exame toxicológico."
            },
            "points": {
              "type": "object",
              "additionalProperties": {},
              "description": "Resumo de pontos, quando as fontes de dados responderam."
            },
            "fines": {
              "type": "object",
              "additionalProperties": {},
              "description": "Resumo de multas, quando as fontes de dados responderam."
            },
            "rollingPoints": {
              "type": "object",
              "additionalProperties": {},
              "description": "Linha do tempo dos pontos nos últimos 12 meses (janela móvel)."
            },
            "autosuspensionRisk": {
              "type": "object",
              "additionalProperties": {},
              "description": "Risco de suspensão automática."
            },
            "provisional": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "riskFineCount": {
                      "type": "number"
                    },
                    "atRisk": {
                      "type": "boolean"
                    },
                    "limit": {
                      "type": "number"
                    },
                    "appealDeadline": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ],
                      "description": "Data de calendário ISO 8601."
                    }
                  },
                  "required": [
                    "riskFineCount",
                    "atRisk",
                    "limit",
                    "appealDeadline"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "description": "Permissão para dirigir (CNH provisória): multas graves ou gravíssimas nos últimos 12 meses colocam a CNH definitiva em risco (`provisional_definitive_at_risk`). Nulo quando a CNH não é provisória ou a fonte não informou."
            },
            "pid": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "expiryDate": {
                      "type": "string",
                      "description": "Data de calendário ISO 8601."
                    },
                    "daysUntilExpiry": {
                      "type": "number"
                    },
                    "state": {
                      "enum": [
                        "valid",
                        "expiring",
                        "expired"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "expiryDate",
                    "daysUntilExpiry",
                    "state"
                  ]
                },
                {
                  "type": "null"
                }
              ],
              "description": "Permissão Internacional para Dirigir (PID). Nulo quando não há."
            },
            "specializedCourses": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "course": {
                        "type": "string",
                        "description": "Um de: tci, tcp, te, tpp, tve, tmt, tmf."
                      },
                      "lapsesAt": {
                        "type": "string",
                        "description": "Data de calendário ISO 8601: conclusão + 5 anos."
                      },
                      "daysUntilLapse": {
                        "type": "number"
                      },
                      "state": {
                        "enum": [
                          "valid",
                          "lapsing"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "course",
                      "lapsesAt",
                      "daysUntilLapse",
                      "state"
                    ]
                  }
                },
                {
                  "type": "null"
                }
              ],
              "description": "Cursos especializados ainda em vigor. Nulo quando a fonte não os informou."
            },
            "firstLicenseDate": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Data de calendário ISO 8601 da primeira habilitação."
            },
            "allAlerts": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Um de: cnh_expired, cnh_expiring_soon, medical_exam_expired, toxicological_exam_required, toxicological_exam_expired, federal_block, federal_block_undetailed, unresolved_block, state_suspension, state_revocation, fines_during_suspension, rolling_limit_exceeded, autosuspensive_no_trigger, no_reports_available, partial_data_available, no_license_found, fines_unverified, fines_state_only, provisional_definitive_at_risk, pid_expiring_soon, pid_expired, specialized_course_lapsing."
                  },
                  "severity": {
                    "enum": [
                      "info",
                      "warning",
                      "error",
                      "critical"
                    ],
                    "type": "string"
                  },
                  "details": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  }
                },
                "required": [
                  "type",
                  "severity"
                ]
              },
              "description": "Se contiver `fines_unverified`, pontos e multas NÃO foram verificados; nunca os informe como zero. Se contiver `fines_state_only`, eles vêm apenas do estado que emitiu a CNH: infrações registradas por outros estados ou órgãos federais podem estar ausentes."
            },
            "diagnosisDate": {
              "type": "string",
              "description": "ISO 8601."
            }
          },
          "required": [
            "status",
            "hasReportData",
            "hasPartialData",
            "validity",
            "category",
            "blocks",
            "medicalExams",
            "toxicological",
            "provisional",
            "pid",
            "specializedCourses",
            "firstLicenseDate",
            "allAlerts",
            "diagnosisDate"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Nulo enquanto o relatório está em `PROCESSING`."
    },
    "normalized": {
      "type": "object",
      "properties": {
        "validity": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {},
              "description": "Igual a `diagnosis.validity`."
            },
            {
              "type": "null"
            }
          ]
        },
        "blocks": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {},
              "description": "Igual a `diagnosis.blocks`."
            },
            {
              "type": "null"
            }
          ]
        },
        "medicalExams": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {},
              "description": "Igual a `diagnosis.medicalExams`."
            },
            {
              "type": "null"
            }
          ]
        },
        "toxicological": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {},
              "description": "Igual a `diagnosis.toxicological`."
            },
            {
              "type": "null"
            }
          ]
        },
        "points": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {},
              "description": "Igual a `diagnosis.points`."
            },
            {
              "type": "null"
            }
          ]
        },
        "fines": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": {},
              "description": "Igual a `diagnosis.fines`."
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "validity",
        "blocks",
        "medicalExams",
        "toxicological",
        "points",
        "fines"
      ]
    },
    "aiAnalysis": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "markdown": {
              "type": "string"
            },
            "status": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "generatedAt": {
              "type": "string"
            }
          },
          "required": [
            "markdown",
            "status",
            "generatedAt"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Análise em linguagem simples; melhor esforço, pode ser nula em um relatório entregue."
    },
    "details": {
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": {},
          "description": "O registro completo por trás do veredito: personal, license, pid, medicalExams, toxicological, courses, stateLookup."
        },
        {
          "type": "null"
        }
      ]
    },
    "holderConsent": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "stateCode": {
              "type": "string",
              "description": "O estado emissor cujos dados a autorização libera, por exemplo `SP`."
            },
            "covers": {
              "type": "array",
              "items": {
                "enum": [
                  "points",
                  "fines"
                ],
                "type": "string"
              },
              "description": "O que a autorização libera no relatório."
            },
            "status": {
              "enum": [
                "required",
                "pending",
                "active",
                "declined",
                "denied",
                "expired",
                "revoked"
              ],
              "type": "string",
              "description": "`required`: peça a autorização ao titular (POST /api/v1/reports/{reportId}/holder-consent). `pending`: há um link aberto ou o titular está autorizando. `active`: autorizado; os dados de `covers` estão no relatório. `declined`, `denied`, `expired`, `revoked`: a autorização não está em vigor; é possível solicitar um novo link."
            },
            "requestExpiresAt": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ISO 8601. Quando o link aberto deixa de funcionar."
            }
          },
          "required": [
            "stateCode",
            "covers",
            "status",
            "requestExpiresAt"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Nulo quando o estado emissor da CNH não exige autorização do titular, ou enquanto a consulta não respondeu. Restrito à sua organização."
    },
    "createdAt": {
      "type": "string",
      "description": "ISO 8601."
    },
    "deliveredAt": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "ISO 8601."
    }
  },
  "required": [
    "reportId",
    "externalRef",
    "status",
    "livemode",
    "driver",
    "diagnosis",
    "normalized",
    "aiAnalysis",
    "details",
    "holderConsent",
    "createdAt",
    "deliveredAt"
  ]
}
```

#### Error

```json
{
  "type": "object",
  "properties": {
    "defined": {
      "type": "boolean"
    },
    "code": {
      "type": "string",
      "description": "Código legível por máquina, por exemplo `UNPROCESSABLE_CONTENT`."
    },
    "status": {
      "type": "number",
      "description": "O status HTTP."
    },
    "message": {
      "type": "string"
    },
    "data": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {},
      "description": "Detalhes extras: `reason` em 403, 409, 422 e 429; `balance`, `limit`, `pricePerReport` em 402; `retryAfter` em 429."
    }
  },
  "required": [
    "defined",
    "code",
    "status",
    "message"
  ]
}
```
