# Criar um relatório de CNH para um CPF

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

Enfileira um relatório de CNH para o CPF informado. Retorna 202 com o reportId; o resultado é entregue por webhook e fica disponível consultando GET /api/v1/reports/{reportId}.

## POST /api/v1/reports

```json
{
  "operationId": "apiAccess.reports.create",
  "summary": "Criar um relatório de CNH para um CPF",
  "description": "Enfileira um relatório de CNH para o CPF informado. Retorna 202 com o reportId; o resultado é entregue por webhook e fica disponível consultando GET /api/v1/reports/{reportId}.",
  "tags": [
    "Public API"
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "cpf": {
              "type": "string"
            },
            "externalRef": {
              "type": "string",
              "maxLength": 255
            }
          },
          "required": [
            "cpf"
          ]
        }
      }
    }
  },
  "responses": {
    "202": {
      "description": "OK",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/AcceptedReport"
          },
          "example": {
            "reportId": "rpt_sandbox_0001",
            "status": "PROCESSING",
            "driver": {
              "id": "drv_sandbox_0001",
              "cpf": "10000000108",
              "name": "ANA BEATRIZ SANDBOX",
              "licenseNumber": "10000000108",
              "licenseCategory": "B",
              "expiryDate": "2030-03-15T00:00:00.000Z",
              "issueState": "SP"
            },
            "statusUrl": "/api/v1/reports/rpt_sandbox_0001",
            "webhookConfigured": false,
            "estimatedDeliveryAt": "2030-01-01T00:00:30.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"
          }
        }
      }
    },
    "402": {
      "description": "`PAYMENT_REQUIRED`: o saldo está abaixo do `creditLineLimit` da organização. `data` traz `balance`, `limit` e `pricePerReport`.",
      "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"
          }
        }
      }
    },
    "422": {
      "description": "`UNPROCESSABLE_CONTENT`: CPF inválido, ou uma regra de sandbox em `data.reason` (`sandbox_cpf_on_live_key`, `sandbox_cpf_not_in_corpus`, `sandbox_magic_cpf`, `holder_consent_not_applicable`).",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "429": {
      "description": "`TOO_MANY_REQUESTS`: limite de requisições excedido. `data` traz `retryAfter` e `reason`; veja o cabeçalho `Retry-After`.",
      "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

#### AcceptedReport

```json
{
  "type": "object",
  "properties": {
    "reportId": {
      "type": "string"
    },
    "status": {
      "enum": [
        "PROCESSING",
        "DELIVERED",
        "ERROR"
      ],
      "type": "string"
    },
    "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"
      ]
    },
    "statusUrl": {
      "type": "string",
      "description": "Caminho para consultar (polling): `/api/v1/reports/{reportId}`."
    },
    "webhookConfigured": {
      "type": "boolean"
    },
    "estimatedDeliveryAt": {
      "type": "string",
      "description": "ISO 8601."
    }
  },
  "required": [
    "reportId",
    "status",
    "driver",
    "statusUrl",
    "webhookConfigured",
    "estimatedDeliveryAt"
  ]
}
```

#### 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"
  ]
}
```
