openapi: 3.1.0
info:
  title: FleetPay API Fiscal v1
  version: 1.0.0-hml
  description: 'Contrato público do trilho fiscal da transportadora. Abrange configuração

    fiscal, certificado digital A1, NF-e, CT-e, eventos do CT-e, CIOT, frota, motoristas e MDF-e.


    Esta API é exclusiva de homologação. CT-e e MDF-e são identificados

    publicamente por UUID; NF-e usa a chave de acesso, eventos usam uma chave opaca,

    e veículos e motoristas mantêm IDs inteiros.


    O limite padrão é de 120 requisições por minuto por transportadora. Em `429`,

    respeite o header `Retry-After`. Não há suporte a `Idempotency-Key`: depois de

    `202`, timeout ou `503` em uma emissão, consulte o recurso antes de repetir o comando.

    '
  contact:
    name: FleetPay
  license:
    name: Proprietary — FleetPay LLC
    url: https://fleetpay.tech
x-fiscal-hml-servers: &id001
- url: https://api.fleetpay.site/v1
  description: Homologação — único ambiente disponível para a API Fiscal v1
servers: *id001
security:
- bearerAuth: []
tags:
- name: Serviço
  description: Diagnóstico, catálogos e painel fiscal.
- name: Configuração
  description: Dados fiscais e certificado digital A1 da transportadora.
- name: NF-e
  description: Entrada e consulta de NF-e pela chave de acesso.
- name: CT-e
  description: Rascunho, prévia, emissão, consulta e DACTE.
- name: Eventos CT-e
  description: Eventos vinculados ao UUID do CT-e.
- name: CIOT
  description: Ciclo de vida do CIOT vinculado ao UUID do CT-e.
- name: Veículos
  description: Frota da transportadora e dados fiscais.
- name: Motoristas
  description: Motoristas da transportadora e perfis fiscais.
- name: MDF-e
  description: Rascunho, emissão, consulta, eventos e DAMDFE.
paths:
  /fiscal/status:
    servers: *id001
    get:
      tags:
      - Serviço
      summary: Verificar acesso e prontidão fiscal
      operationId: getFiscalStatus
      responses:
        '200':
          $ref: '#/components/responses/StatusOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/configuracao:
    servers: *id001
    get:
      tags:
      - Configuração
      summary: Consultar configuração fiscal da transportadora
      operationId: getFiscalConfiguration
      responses:
        '200':
          $ref: '#/components/responses/FiscalConfigurationOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    put:
      tags:
      - Configuração
      summary: Atualizar configuração fiscal da transportadora
      description: Atualiza somente os campos informados. Envie null para limpar um campo opcional.
      operationId: updateFiscalConfiguration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FiscalConfigurationUpdate'
            example:
              state_registration: '110042490114'
              rntrc: '12345678'
              rntrc_valid_until: '2027-12-31'
              cte_serie: '1'
              city_code: '3550308'
      responses:
        '200':
          $ref: '#/components/responses/FiscalConfigurationOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/certificado:
    servers: *id001
    get:
      tags:
      - Configuração
      summary: Consultar metadados do certificado digital
      description: Nunca devolve o arquivo nem a senha do certificado.
      operationId: getFiscalCertificate
      responses:
        '200':
          $ref: '#/components/responses/CertificateOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      tags:
      - Configuração
      summary: Enviar certificado digital A1
      description: Envia ou substitui o certificado digital da transportadora.
      operationId: uploadFiscalCertificate
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - file
              - cert_pass
              properties:
                file:
                  type: string
                  format: binary
                  description: Certificado A1 em .pfx ou .p12, com no máximo 10 MB.
                cert_pass:
                  type: string
                  format: password
                  description: Senha do certificado; nunca é devolvida pela API.
            encoding:
              file:
                contentType: application/x-pkcs12, application/octet-stream
      responses:
        '201':
          $ref: '#/components/responses/CertificateCreated'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    delete:
      tags:
      - Configuração
      summary: Remover certificado digital
      description: Operação idempotente; removed é false quando não havia certificado cadastrado.
      operationId: deleteFiscalCertificate
      responses:
        '200':
          $ref: '#/components/responses/CertificateDeleted'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/catalogos:
    servers: *id001
    get:
      tags:
      - Serviço
      summary: Obter domínios fiscais
      operationId: getFiscalCatalogues
      responses:
        '200':
          $ref: '#/components/responses/CataloguesOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/painel:
    servers: *id001
    get:
      tags:
      - Serviço
      summary: Obter indicadores do trilho fiscal
      operationId: getFiscalDashboard
      responses:
        '200':
          $ref: '#/components/responses/DashboardOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/nfe:
    servers: *id001
    get:
      tags:
      - NF-e
      summary: Listar NF-e importadas
      operationId: listNfe
      parameters:
      - name: search
        in: query
        description: Emitente, destinatário, número ou chave de acesso.
        schema:
          type: string
      - name: status
        in: query
        schema:
          $ref: '#/components/schemas/NfeStatus'
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      responses:
        '200':
          $ref: '#/components/responses/NfeListOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/nfe/importacoes:
    servers: *id001
    post:
      tags:
      - NF-e
      summary: Importar arquivos de NF-e
      description: >-
        Aceita de 1 a 20 arquivos XML, PDF ou ZIP, com até 10 MB cada. No
        multipart/form-data, envie cada parte usando o nome `arquivos[]` para
        formar o array `arquivos` aceito pela API.
      operationId: importNfe
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
              - arquivos
              properties:
                arquivos:
                  type: array
                  minItems: 1
                  maxItems: 20
                  items:
                    type: string
                    format: binary
            encoding:
              arquivos:
                style: form
                explode: true
      responses:
        '201':
          $ref: '#/components/responses/NfeImportCreated'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/nfe/{access_key}:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/NfeAccessKey'
    get:
      tags:
      - NF-e
      summary: Consultar NF-e
      operationId: getNfe
      responses:
        '200':
          $ref: '#/components/responses/NfeOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    delete:
      tags:
      - NF-e
      summary: Remover NF-e não vinculada
      operationId: deleteNfe
      responses:
        '204':
          description: NF-e removida; sem corpo.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/cte:
    servers: *id001
    get:
      tags:
      - CT-e
      summary: Listar CT-e
      operationId: listCte
      parameters:
      - name: status
        in: query
        schema:
          $ref: '#/components/schemas/CteSituation'
      - name: from
        in: query
        schema:
          type: string
          format: date
      - name: to
        in: query
        schema:
          type: string
          format: date
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      responses:
        '200':
          $ref: '#/components/responses/CteListOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      tags:
      - CT-e
      summary: Criar rascunho de CT-e
      operationId: createCte
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CteDraftInput'
            examples:
              normal:
                $ref: '#/components/examples/CteDraftInput'
      responses:
        '201':
          description: Rascunho criado.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CteEnvelope'
          links:
            ConsultarCte:
              operationId: getCte
              parameters:
                cte_uuid: $response.body#/data/id
            GerarPreviaCte:
              operationId: previewCte
              parameters:
                cte_uuid: $response.body#/data/id
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    get:
      tags:
      - CT-e
      summary: Consultar CT-e
      operationId: getCte
      responses:
        '200':
          $ref: '#/components/responses/CteOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    put:
      tags:
      - CT-e
      summary: Atualizar rascunho de CT-e
      description: Substitui os dados editáveis do rascunho. Documentos já enviados são imutáveis.
      operationId: updateCte
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CteDraftInput'
            examples:
              normal:
                $ref: '#/components/examples/CteDraftInput'
      responses:
        '200':
          $ref: '#/components/responses/CteOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/previa:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CT-e
      summary: Gerar prévia do CT-e
      description: Monta o conteúdo e valida pendências sem efetivar a emissão.
      operationId: previewCte
      responses:
        '200':
          $ref: '#/components/responses/CtePreviewOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/emissao:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CT-e
      summary: Emitir CT-e
      description: 'Inicia a emissão em homologação. Uma resposta 202 exige polling em

        `/cte/{cte_uuid}/consulta`; não repita esta emissão enquanto o resultado for desconhecido.

        '
      operationId: issueCte
      responses:
        '202':
          description: Emissão aceita ou com resultado ainda não conclusivo.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CteIssueEnvelope'
          links:
            ConsultarAutorizacaoCte:
              operationId: queryCte
              parameters:
                cte_uuid: $request.path.cte_uuid
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/consulta:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CT-e
      summary: Consultar autorização do CT-e
      description: Endpoint de polling para emissão com resposta 202, timeout ou resultado ambíguo.
      operationId: queryCte
      responses:
        '200':
          $ref: '#/components/responses/CteQueryOk'
        '202':
          $ref: '#/components/responses/CteQueryPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/cte/{cte_uuid}/dacte:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    get:
      tags:
      - CT-e
      summary: Baixar DACTE
      operationId: downloadDacte
      responses:
        '200':
          description: Arquivo PDF da DACTE.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
            Content-Disposition:
              schema:
                type: string
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/cte/{cte_uuid}/eventos/cancelamento:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - Eventos CT-e
      summary: Cancelar CT-e
      operationId: cancelCte
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JustificationInput'
            example:
              justification: Documento emitido com dados incorretos.
      responses:
        '200':
          $ref: '#/components/responses/CteEventOk'
        '202':
          $ref: '#/components/responses/CteEventPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/eventos/carta-correcao:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - Eventos CT-e
      summary: Registrar carta de correção
      operationId: correctCte
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CteCorrectionInput'
            example:
              alterations:
              - group: compl
                field: xObs
                value: Entrega no portão 2
                item: 1
      responses:
        '200':
          $ref: '#/components/responses/CteEventOk'
        '202':
          $ref: '#/components/responses/CteEventPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/eventos/entrega:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - Eventos CT-e
      summary: Confirmar entrega do CT-e
      operationId: confirmCteDelivery
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CteDeliveryInput'
            examples:
              normal:
                $ref: '#/components/examples/CteDeliveryInput'
      responses:
        '200':
          $ref: '#/components/responses/CteEventOk'
        '202':
          $ref: '#/components/responses/CteEventPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/eventos/entrega/cancelamento:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - Eventos CT-e
      summary: Cancelar confirmação de entrega
      operationId: cancelCteDelivery
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CteDeliveryCancellationInput'
            example:
              sequence: 1
      responses:
        '200':
          $ref: '#/components/responses/CteEventOk'
        '202':
          $ref: '#/components/responses/CteEventPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/eventos/{event_key}/reconciliacao:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    - $ref: '#/components/parameters/EventKey'
    post:
      tags:
      - Eventos CT-e
      summary: Reconciliar evento pendente do CT-e
      operationId: reconcileCteEvent
      responses:
        '200':
          $ref: '#/components/responses/CteEventOk'
        '202':
          $ref: '#/components/responses/CteEventPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/ciot/validacao:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CIOT
      summary: Validar dados para emissão do CIOT
      operationId: validateCiot
      responses:
        '200':
          $ref: '#/components/responses/CiotCheckOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/cte/{cte_uuid}/ciot/emissao:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CIOT
      summary: Emitir CIOT
      description: Em 202, consulte o CIOT antes de repetir qualquer comando.
      operationId: issueCiot
      responses:
        '201':
          $ref: '#/components/responses/CiotCreated'
        '202':
          description: Emissão enviada e ainda não concluída.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CiotOperationEnvelope'
          links:
            ConsultarCiot:
              operationId: queryCiot
              parameters:
                cte_uuid: $request.path.cte_uuid
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/cte/{cte_uuid}/ciot/consulta:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CIOT
      summary: Consultar CIOT
      operationId: queryCiot
      responses:
        '200':
          $ref: '#/components/responses/CiotOk'
        '202':
          $ref: '#/components/responses/CiotPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/ciot/cancelamento:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CIOT
      summary: Cancelar CIOT
      operationId: cancelCiot
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - justification
              properties:
                justification:
                  type: string
                  maxLength: 500
            example:
              justification: Operação de transporte cancelada pelo contratante.
      responses:
        '200':
          $ref: '#/components/responses/CiotOk'
        '202':
          $ref: '#/components/responses/CiotPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/ciot/retificacao:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CIOT
      summary: Retificar CIOT
      operationId: rectifyCiot
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CiotRectificationInput'
            examples:
              normal:
                $ref: '#/components/examples/CiotRectificationInput'
      responses:
        '200':
          $ref: '#/components/responses/CiotOk'
        '202':
          $ref: '#/components/responses/CiotPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/cte/{cte_uuid}/ciot/encerramento:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/CteUuid'
    post:
      tags:
      - CIOT
      summary: Encerrar CIOT
      operationId: closeCiot
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CiotClosingInput'
            examples:
              normal:
                $ref: '#/components/examples/CiotClosingInput'
      responses:
        '200':
          $ref: '#/components/responses/CiotOk'
        '202':
          $ref: '#/components/responses/CiotPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/veiculos:
    servers: *id001
    get:
      tags:
      - Veículos
      summary: Listar veículos ativos
      operationId: listVehicles
      responses:
        '200':
          $ref: '#/components/responses/VehicleListOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      tags:
      - Veículos
      summary: Cadastrar veículo
      operationId: createVehicle
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VehicleCreateInput'
            examples:
              normal:
                $ref: '#/components/examples/VehicleCreateInput'
      responses:
        '201':
          $ref: '#/components/responses/VehicleCreated'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/veiculos/{id}/dados-fiscais:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/VehicleId'
    put:
      tags:
      - Veículos
      summary: Atualizar dados fiscais do veículo
      operationId: updateVehicleFiscalData
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VehicleFiscalInput'
            examples:
              normal:
                $ref: '#/components/examples/VehicleFiscalInput'
      responses:
        '200':
          $ref: '#/components/responses/VehicleOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/motoristas:
    servers: *id001
    get:
      tags:
      - Motoristas
      summary: Listar motoristas
      operationId: listDrivers
      responses:
        '200':
          $ref: '#/components/responses/DriverListOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/motoristas/{id}/dados-fiscais:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/DriverId'
    put:
      tags:
      - Motoristas
      summary: Atualizar dados fiscais do motorista
      operationId: updateDriverFiscalData
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DriverFiscalInput'
            examples:
              normal:
                $ref: '#/components/examples/DriverFiscalInput'
      responses:
        '200':
          $ref: '#/components/responses/DriverOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/mdfe:
    servers: *id001
    get:
      tags:
      - MDF-e
      summary: Listar MDF-e
      operationId: listMdfe
      parameters:
      - name: status
        in: query
        schema:
          $ref: '#/components/schemas/MdfeStatus'
      - $ref: '#/components/parameters/Page'
      - $ref: '#/components/parameters/PerPage'
      responses:
        '200':
          $ref: '#/components/responses/MdfeListOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      tags:
      - MDF-e
      summary: Criar rascunho de MDF-e
      operationId: createMdfe
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MdfeDraftInput'
            examples:
              normal:
                $ref: '#/components/examples/MdfeDraftInput'
      responses:
        '201':
          description: Rascunho criado.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MdfeEnvelope'
          links:
            ConsultarMdfe:
              operationId: getMdfe
              parameters:
                mdfe_uuid: $response.body#/data/id
            EmitirMdfe:
              operationId: issueMdfe
              parameters:
                mdfe_uuid: $response.body#/data/id
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/mdfe/{mdfe_uuid}:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/MdfeUuid'
    get:
      tags:
      - MDF-e
      summary: Consultar MDF-e
      operationId: getMdfe
      responses:
        '200':
          $ref: '#/components/responses/MdfeOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
    put:
      tags:
      - MDF-e
      summary: Atualizar rascunho de MDF-e
      description: Substitui os dados editáveis do rascunho. Documentos já enviados são imutáveis.
      operationId: updateMdfe
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MdfeDraftInput'
            examples:
              normal:
                $ref: '#/components/examples/MdfeDraftInput'
      responses:
        '200':
          $ref: '#/components/responses/MdfeOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '500':
          $ref: '#/components/responses/InternalError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /fiscal/mdfe/{mdfe_uuid}/emissao:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/MdfeUuid'
    post:
      tags:
      - MDF-e
      summary: Emitir MDF-e
      description: Em 202, consulte o MDF-e antes de repetir qualquer comando.
      operationId: issueMdfe
      responses:
        '200':
          $ref: '#/components/responses/MdfeOperationOk'
        '202':
          description: Emissão enviada e ainda não concluída.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MdfeOperationEnvelope'
          links:
            ConsultarAutorizacaoMdfe:
              operationId: queryMdfe
              parameters:
                mdfe_uuid: $request.path.mdfe_uuid
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/mdfe/{mdfe_uuid}/consulta:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/MdfeUuid'
    post:
      tags:
      - MDF-e
      summary: Consultar autorização do MDF-e
      operationId: queryMdfe
      responses:
        '200':
          $ref: '#/components/responses/MdfeOperationOk'
        '202':
          $ref: '#/components/responses/MdfeOperationPending'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/mdfe/{mdfe_uuid}/encerramento:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/MdfeUuid'
    post:
      tags:
      - MDF-e
      summary: Encerrar MDF-e
      operationId: closeMdfe
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MdfeClosingInput'
            example:
              closing_city_code: '3304557'
              closing_city: Rio de Janeiro
              closing_state: RJ
              closed_on: '2026-08-07'
      responses:
        '200':
          $ref: '#/components/responses/MdfeOperationOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/mdfe/{mdfe_uuid}/cancelamento:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/MdfeUuid'
    post:
      tags:
      - MDF-e
      summary: Cancelar MDF-e
      operationId: cancelMdfe
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JustificationInput'
            example:
              justification: Viagem cancelada antes do início do transporte.
      responses:
        '200':
          $ref: '#/components/responses/MdfeOperationOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/mdfe/{mdfe_uuid}/condutores:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/MdfeUuid'
    post:
      tags:
      - MDF-e
      summary: Incluir condutor no MDF-e
      operationId: addMdfeDriver
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MdfeDriverInput'
            example:
              cpf: '12345678909'
              name: Carlos de Souza
      responses:
        '200':
          $ref: '#/components/responses/MdfeOperationOk'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/ValidationOrBusinessRuleFailed'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
  /fiscal/mdfe/{mdfe_uuid}/damdfe:
    servers: *id001
    parameters:
    - $ref: '#/components/parameters/MdfeUuid'
    get:
      tags:
      - MDF-e
      summary: Baixar DAMDFE
      operationId: downloadDamdfe
      responses:
        '200':
          description: Arquivo PDF da DAMDFE.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
            Content-Disposition:
              schema:
                type: string
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/BusinessRuleFailed'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: FleetPay API key
      description: Chave FleetPay ativa da transportadora, com escopo `fiscal`.
  headers:
    RequestId:
      description: Identificador de correlação da chamada.
      schema:
        type: string
        format: uuid
  parameters:
    Page:
      name: page
      in: query
      schema:
        type: integer
        minimum: 1
        default: 1
    PerPage:
      name: per_page
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 25
    NfeAccessKey:
      name: access_key
      in: path
      required: true
      description: Chave de acesso da NF-e, com 44 dígitos.
      schema:
        type: string
        pattern: ^\d{44}$
    CteUuid:
      name: cte_uuid
      in: path
      required: true
      description: UUID público do CT-e.
      schema:
        type: string
        format: uuid
    MdfeUuid:
      name: mdfe_uuid
      in: path
      required: true
      description: UUID público do MDF-e.
      schema:
        type: string
        format: uuid
    EventKey:
      name: event_key
      in: path
      required: true
      description: Identificador público opaco do evento, devolvido em `data.id`.
      schema:
        type: string
        pattern: ^[a-f0-9]{64}$
    VehicleId:
      name: id
      in: path
      required: true
      description: ID inteiro do veículo.
      schema:
        type: integer
        minimum: 1
    DriverId:
      name: id
      in: path
      required: true
      description: ID inteiro do motorista.
      schema:
        type: integer
        minimum: 1
  responses:
    StatusOk:
      description: Acesso fiscal disponível para a transportadora.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StatusEnvelope'
          example:
            data:
              company:
                document: '12345678000190'
                name: Transportadora Exemplo Ltda.
              environment: homologacao
              certificate:
                configured: true
                valid_until: '2027-05-30'
              documents:
                nfe: true
                cte: true
                ciot: true
                mdfe: true
            environment: homologacao
    FiscalConfigurationOk:
      description: Configuração fiscal da transportadora autenticada.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FiscalConfigurationEnvelope'
          example:
            data:
              state_registration: '110042490114'
              rntrc: '12345678'
              rntrc_valid_until: '2027-12-31'
              cte_serie: '1'
              city_code: '3550308'
            environment: homologacao
    CertificateOk:
      description: Metadados do certificado digital da transportadora.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CertificateEnvelope'
          example:
            data:
              configured: true
              holder_name: Transportadora Exemplo Ltda.
              document: '12345678000190'
              valid_from: '2026-05-30'
              valid_until: '2027-05-30'
              status: valido
            environment: homologacao
    CertificateCreated:
      description: Certificado digital enviado e metadados atualizados.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CertificateEnvelope'
    CertificateDeleted:
      description: Resultado da remoção do certificado digital.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CertificateDeleteEnvelope'
          example:
            data:
              removed: true
            environment: homologacao
    CataloguesOk:
      description: Domínios fiscais vigentes.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CataloguesEnvelope'
    DashboardOk:
      description: Indicadores fiscais da transportadora.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DashboardEnvelope'
    NfeListOk:
      description: Página de NF-e.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NfeListEnvelope'
    NfeOk:
      description: NF-e encontrada.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NfeEnvelope'
    NfeImportCreated:
      description: Lote processado e relatório de importação criado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NfeImportEnvelope'
    CteListOk:
      description: Página de CT-e.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CteListEnvelope'
    CteOk:
      description: CT-e encontrado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CteEnvelope'
    CtePreviewOk:
      description: Prévia montada sem efetivar a emissão.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CtePreviewEnvelope'
    CteQueryOk:
      description: Consulta concluída; verifique `authorization.outcome`.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CteQueryEnvelope'
    CteQueryPending:
      description: Autorização pendente ou temporariamente indisponível; mantenha o polling.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          description: Pode ser informado pelo gateway; se ausente, aplique backoff no cliente.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CteQueryEnvelope'
    CteEventOk:
      description: Evento concluído.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CteEventEnvelope'
    CteEventPending:
      description: Evento registrado localmente e pendente de reconciliação.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CteEventEnvelope'
    CiotCheckOk:
      description: Validação executada; o CIOT pode ser emitido.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CiotCheckEnvelope'
    CiotCreated:
      description: CIOT registrado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CiotOperationEnvelope'
    CiotOk:
      description: Operação de CIOT concluída.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CiotOperationEnvelope'
    CiotPending:
      description: Operação de CIOT ainda pendente ou ambígua; consulte novamente.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CiotOperationEnvelope'
    VehicleListOk:
      description: Veículos ativos.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/VehicleListEnvelope'
    VehicleCreated:
      description: Veículo cadastrado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/VehicleEnvelope'
    VehicleOk:
      description: Veículo atualizado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/VehicleEnvelope'
    DriverListOk:
      description: Motoristas da transportadora.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DriverListEnvelope'
    DriverOk:
      description: Perfil fiscal atualizado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DriverEnvelope'
    MdfeListOk:
      description: Página de MDF-e.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MdfeListEnvelope'
    MdfeOk:
      description: MDF-e encontrado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MdfeEnvelope'
    MdfeOperationOk:
      description: Operação de MDF-e concluída.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MdfeOperationEnvelope'
    MdfeOperationPending:
      description: Operação de MDF-e ainda pendente; consulte novamente.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MdfeOperationEnvelope'
    Unauthorized:
      description: Chave de API FleetPay ausente ou inválida.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            error:
              code: nao_autenticado
              message: Informe uma chave de API FleetPay válida no cabeçalho Authorization.
              request_id: 123e4567-e89b-12d3-a456-426614174000
    Forbidden:
      description: Uso fora da URL de homologação, escopo fiscal desabilitado ou chave sem transportadora ativa.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    NotFound:
      description: Recurso não encontrado no tenant autenticado.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    ValidationFailed:
      description: Payload inválido.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    BusinessRuleFailed:
      description: Pendência ou regra de negócio impediu a operação.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    ValidationOrBusinessRuleFailed:
      description: Payload inválido, pendência ou regra de negócio.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    InternalError:
      description: Falha interna sem detalhes de integrações operacionais.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    ServiceUnavailable:
      description: Não foi possível confirmar ou obter o resultado agora. Consulte antes de repetir comandos.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    RateLimited:
      description: Limite por transportadora excedido.
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          description: Segundos até uma nova tentativa.
          required: true
          schema:
            type: integer
            minimum: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            error:
              code: limite_requisicoes
              message: Limite de requisições excedido. Tente novamente em instantes.
              request_id: 52d0aa38-b2a9-4a60-a52e-50c7cd43d7f4
  schemas:
    Environment:
      type: string
      enum:
      - homologacao
      description: Esta API só opera em homologação.
    ErrorEnvelope:
      type: object
      required:
      - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
    ErrorBody:
      type: object
      required:
      - code
      - message
      - request_id
      properties:
        code:
          type: string
          description: Código estável e próprio do contrato FleetPay.
          example: dados_incompletos
        message:
          type: string
          example: Revise os dados obrigatórios antes de emitir.
        details:
          type:
          - object
          - 'null'
          additionalProperties: true
          properties:
            pending_items:
              type: array
              items:
                type: string
        request_id:
          type: string
          format: uuid
    Pagination:
      type: object
      required:
      - page
      - per_page
      - total
      - last_page
      properties:
        page:
          type: integer
          minimum: 1
        per_page:
          type: integer
          minimum: 1
          maximum: 100
        total:
          type: integer
          minimum: 0
        last_page:
          type: integer
          minimum: 1
    CompanySummary:
      type: object
      required:
      - document
      - name
      properties:
        document:
          type: string
          pattern: ^\d{14}$
        name:
          type:
          - string
          - 'null'
    StatusData:
      type: object
      required:
      - company
      - environment
      - certificate
      - documents
      properties:
        company:
          $ref: '#/components/schemas/CompanySummary'
        environment:
          $ref: '#/components/schemas/Environment'
        certificate:
          type: object
          required:
          - configured
          - valid_until
          properties:
            configured:
              type: boolean
            valid_until:
              type:
              - string
              - 'null'
              format: date
        documents:
          type: object
          required:
          - nfe
          - cte
          - ciot
          - mdfe
          properties:
            nfe:
              type: boolean
            cte:
              type: boolean
            ciot:
              type: boolean
            mdfe:
              type: boolean
    StatusEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/StatusData'
        environment:
          $ref: '#/components/schemas/Environment'
    FiscalConfigurationUpdate:
      type: object
      description: Campos fiscais da transportadora. Todos são opcionais; envie null para limpar um valor.
      properties:
        state_registration:
          type:
          - string
          - 'null'
          maxLength: 20
          description: Inscrição estadual, normalizada em maiúsculas.
        rntrc:
          type:
          - string
          - 'null'
          pattern: ^\d{8}$
          description: Registro Nacional de Transportadores Rodoviários de Cargas com 8 dígitos.
        rntrc_valid_until:
          type:
          - string
          - 'null'
          format: date
          description: Data de validade do RNTRC no formato YYYY-MM-DD.
        cte_serie:
          type:
          - string
          - 'null'
          pattern: ^\d{1,3}$
          description: Série numérica do CT-e, com até 3 dígitos.
        city_code:
          type:
          - string
          - 'null'
          pattern: ^\d{7}$
          description: Código IBGE do município com 7 dígitos.
    FiscalConfigurationData:
      type: object
      required:
      - state_registration
      - rntrc
      - rntrc_valid_until
      - cte_serie
      - city_code
      properties:
        state_registration:
          type:
          - string
          - 'null'
        rntrc:
          type:
          - string
          - 'null'
          pattern: ^\d{8}$
        rntrc_valid_until:
          type:
          - string
          - 'null'
          format: date
        cte_serie:
          type:
          - string
          - 'null'
          pattern: ^\d{1,3}$
        city_code:
          type:
          - string
          - 'null'
          pattern: ^\d{7}$
    FiscalConfigurationEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/FiscalConfigurationData'
        environment:
          $ref: '#/components/schemas/Environment'
    CertificateMetadata:
      type: object
      required:
      - configured
      - holder_name
      - document
      - valid_from
      - valid_until
      - status
      properties:
        configured:
          type: boolean
          description: Indica se há certificado cadastrado para a transportadora.
        holder_name:
          type:
          - string
          - 'null'
          description: Razão social extraída do certificado, quando disponível.
        document:
          type:
          - string
          - 'null'
          description: Documento extraído do certificado, somente dígitos quando disponível.
        valid_from:
          type:
          - string
          - 'null'
          format: date
        valid_until:
          type:
          - string
          - 'null'
          format: date
        status:
          type:
          - string
          - 'null'
          enum:
          - valido
          - expirado
          - null
          description: Situação calculada pela data de validade; null quando não há certificado.
    CertificateEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CertificateMetadata'
        environment:
          $ref: '#/components/schemas/Environment'
    CertificateDeleteData:
      type: object
      required:
      - removed
      properties:
        removed:
          type: boolean
          description: True quando havia certificado e ele foi removido; false quando não havia certificado.
    CertificateDeleteEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CertificateDeleteData'
        environment:
          $ref: '#/components/schemas/Environment'
    IntegerOption:
      type: object
      required:
      - value
      - label
      properties:
        value:
          type: integer
        label:
          type: string
    StringOption:
      type: object
      required:
      - value
      - label
      properties:
        value:
          type: string
        label:
          type: string
    CataloguesData:
      type: object
      required:
      - fiscal
      - cte_statuses
      - mdfe_statuses
      properties:
        fiscal:
          type: object
          required:
          - tiposCarga
          - tiposRodado
          - tiposCarroceria
          properties:
            tiposCarga:
              type: array
              items:
                $ref: '#/components/schemas/IntegerOption'
            tiposRodado:
              type: array
              items:
                $ref: '#/components/schemas/StringOption'
            tiposCarroceria:
              type: array
              items:
                $ref: '#/components/schemas/StringOption'
        cte_statuses:
          type: array
          items:
            $ref: '#/components/schemas/StringOption'
        mdfe_statuses:
          type: array
          items:
            $ref: '#/components/schemas/StringOption'
    CataloguesEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CataloguesData'
        environment:
          $ref: '#/components/schemas/Environment'
    DashboardData:
      type: object
      required:
      - reference_month
      - nfe
      - cte
      - mdfe
      properties:
        reference_month:
          type: string
          pattern: ^\d{4}-\d{2}$
        nfe:
          type: object
          required:
          - available_for_cte
          properties:
            available_for_cte:
              type: integer
              minimum: 0
        cte:
          type: object
          required:
          - draft
          - waiting
          - authorized
          - rejected
          - awaiting_mdfe
          properties:
            draft:
              type: integer
              minimum: 0
            waiting:
              type: integer
              minimum: 0
            authorized:
              type: integer
              minimum: 0
            rejected:
              type: integer
              minimum: 0
            awaiting_mdfe:
              type: integer
              minimum: 0
        mdfe:
          type: object
          required:
          - authorized
          - closed
          - open
          properties:
            authorized:
              type: integer
              minimum: 0
            closed:
              type: integer
              minimum: 0
            open:
              type: integer
              minimum: 0
    DashboardEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/DashboardData'
        environment:
          $ref: '#/components/schemas/Environment'
    NfeStatus:
      type: string
      enum:
      - imported
      - linked
      - cancelled
    FiscalParty:
      type: object
      required:
      - document
      - name
      - city
      - state
      properties:
        document:
          type:
          - string
          - 'null'
        name:
          type:
          - string
          - 'null'
        city:
          type:
          - string
          - 'null'
        state:
          type:
          - string
          - 'null'
    NfeCargo:
      type: object
      required:
      - total_value
      - gross_weight
      - net_weight
      - volume_quantity
      - predominant_product
      properties:
        total_value:
          type:
          - number
          - 'null'
          format: double
        gross_weight:
          type:
          - number
          - 'null'
          format: double
        net_weight:
          type:
          - number
          - 'null'
          format: double
        volume_quantity:
          type:
          - integer
          - 'null'
        predominant_product:
          type:
          - string
          - 'null'
    Nfe:
      type: object
      required:
      - id
      - access_key
      - number
      - series
      - issued_at
      - issuer
      - recipient
      - cargo
      - status
      - linked_cte_count
      - created_at
      properties:
        id:
          type: string
          pattern: ^\d{44}$
          description: Chave de acesso da NF-e; é o identificador público do recurso.
        access_key:
          type: string
          pattern: ^\d{44}$
        number:
          type: integer
        series:
          type: string
        issued_at:
          type:
          - string
          - 'null'
          format: date-time
        issuer:
          $ref: '#/components/schemas/FiscalParty'
        recipient:
          $ref: '#/components/schemas/FiscalParty'
        cargo:
          $ref: '#/components/schemas/NfeCargo'
        status:
          $ref: '#/components/schemas/NfeStatus'
        linked_cte_count:
          type: integer
          minimum: 0
        created_at:
          type:
          - string
          - 'null'
          format: date-time
    NfeEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/Nfe'
        environment:
          $ref: '#/components/schemas/Environment'
    NfeListEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          type: object
          required:
          - items
          - pagination
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/Nfe'
            pagination:
              $ref: '#/components/schemas/Pagination'
        environment:
          $ref: '#/components/schemas/Environment'
    NfeImportResult:
      type: object
      required:
      - file_name
      - status
      - access_key
      - reason
      properties:
        file_name:
          type: string
        status:
          type: string
          description: Resultado individual, como `imported`, `duplicated` ou `failed`.
        access_key:
          type:
          - string
          - 'null'
          pattern: ^\d{44}$
        reason:
          type:
          - string
          - 'null'
    NfeImportBatch:
      type: object
      required:
      - id
      - file_name
      - status
      - total
      - imported
      - duplicated
      - failed
      - results
      - created_at
      properties:
        id:
          type: integer
        file_name:
          type: string
        status:
          type: string
        total:
          type: integer
          minimum: 0
        imported:
          type: integer
          minimum: 0
        duplicated:
          type: integer
          minimum: 0
        failed:
          type: integer
          minimum: 0
        results:
          type: array
          items:
            $ref: '#/components/schemas/NfeImportResult'
        created_at:
          type:
          - string
          - 'null'
          format: date-time
    NfeImportEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/NfeImportBatch'
        environment:
          $ref: '#/components/schemas/Environment'
    CteSituation:
      type: string
      enum:
      - rascunho
      - aguardando
      - autorizado
      - rejeitado
      - cancelado
    CteLifecycleStatus:
      type: string
      enum:
      - draft
      - ready
      - sent
      - waiting
      - authorized
      - rejected
      - cancelled
    CiotStatus:
      type: string
      enum:
      - pending
      - sent
      - registered
      - error
      - cancelled
      - closed
    FiscalRoute:
      type: object
      required:
      - origin_city_code
      - origin_city
      - origin_state
      - destination_city_code
      - destination_city
      - destination_state
      properties:
        origin_city_code:
          type:
          - string
          - 'null'
        origin_city:
          type:
          - string
          - 'null'
        origin_state:
          type:
          - string
          - 'null'
        destination_city_code:
          type:
          - string
          - 'null'
        destination_city:
          type:
          - string
          - 'null'
        destination_state:
          type:
          - string
          - 'null'
    CteCiotSummary:
      type: object
      required:
      - status
      - number
      - verification_code
      - message
      - requested_at
      properties:
        status:
          anyOf:
          - type: string
            allOf:
            - $ref: '#/components/schemas/CiotStatus'
          - type: 'null'
        number:
          type:
          - string
          - 'null'
        verification_code:
          type:
          - string
          - 'null'
        message:
          type:
          - string
          - 'null'
        requested_at:
          type:
          - string
          - 'null'
          format: date-time
    CteEvent:
      type: object
      required:
      - id
      - type
      - status
      - sequence
      - reference
      - protocol
      - reason
      - registered_at
      - created_at
      properties:
        id:
          type: string
          pattern: ^[a-f0-9]{64}$
          description: Identificador público opaco usado para reconciliar o evento.
        type:
          type: string
          enum:
          - cancellation
          - correction
          - delivery_confirmation
          - delivery_cancellation
        status:
          type: string
          enum:
          - pending
          - registered
          - rejected
        sequence:
          type: integer
          minimum: 1
        reference:
          type:
          - string
          - 'null'
        protocol:
          type:
          - string
          - 'null'
        reason:
          type:
          - string
          - 'null'
        registered_at:
          type:
          - string
          - 'null'
          format: date-time
        created_at:
          type:
          - string
          - 'null'
          format: date-time
    Cte:
      type: object
      required:
      - id
      - status
      - lifecycle_status
      - freight
      - route
      - access_key
      - number
      - series
      - protocol
      - sefaz_protocol
      - cstat
      - reason
      - authorized_at
      - ciot
      - created_at
      - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: UUID público usado em todos os caminhos do CT-e.
        status:
          $ref: '#/components/schemas/CteSituation'
        lifecycle_status:
          $ref: '#/components/schemas/CteLifecycleStatus'
        freight:
          type: object
          required:
          - total_value
          - cargo_value
          properties:
            total_value:
              type:
              - number
              - 'null'
              format: double
            cargo_value:
              type:
              - number
              - 'null'
              format: double
        route:
          $ref: '#/components/schemas/FiscalRoute'
        access_key:
          type:
          - string
          - 'null'
          pattern: ^\d{44}$
        number:
          type:
          - integer
          - 'null'
        series:
          type:
          - string
          - 'null'
        protocol:
          type:
          - string
          - 'null'
        sefaz_protocol:
          type:
          - string
          - 'null'
        cstat:
          type:
          - string
          - 'null'
        reason:
          type:
          - string
          - 'null'
        authorized_at:
          type:
          - string
          - 'null'
          format: date-time
        ciot:
          $ref: '#/components/schemas/CteCiotSummary'
        nfe_count:
          type: integer
          minimum: 0
          description: Presente nas listagens.
        has_mdfe:
          type: boolean
          description: Presente nas listagens.
        payload:
          type: object
          additionalProperties: true
          description: Presente no detalhe; contém o payload público validado do rascunho.
        nfe:
          type: array
          description: Presente no detalhe.
          items:
            $ref: '#/components/schemas/Nfe'
        events:
          type: array
          description: Presente no detalhe.
          items:
            $ref: '#/components/schemas/CteEvent'
        created_at:
          type:
          - string
          - 'null'
          format: date-time
        updated_at:
          type:
          - string
          - 'null'
          format: date-time
    CteEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/Cte'
        environment:
          $ref: '#/components/schemas/Environment'
    CteListEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          type: object
          required:
          - items
          - pagination
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/Cte'
            pagination:
              $ref: '#/components/schemas/Pagination'
        environment:
          $ref: '#/components/schemas/Environment'
    CtePreview:
      type: object
      required:
      - access_key
      - number
      - series
      - content
      - document
      properties:
        access_key:
          type: string
          pattern: ^\d{44}$
        number:
          type: integer
        series:
          type: string
        content:
          description: Conteúdo fiscal montado para inspeção.
          oneOf:
          - type: object
            additionalProperties: true
          - type: string
        document:
          $ref: '#/components/schemas/Cte'
    CtePreviewEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CtePreview'
        environment:
          $ref: '#/components/schemas/Environment'
    CteIssueResult:
      type: object
      required:
      - document
      - outcome
      - message
      properties:
        document:
          anyOf:
          - type: object
            allOf:
            - $ref: '#/components/schemas/Cte'
          - type: 'null'
        outcome:
          type: string
          enum:
          - accepted
          - refused
          - unknown
        message:
          type:
          - string
          - 'null'
    CteIssueEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CteIssueResult'
        environment:
          $ref: '#/components/schemas/Environment'
    CteAuthorization:
      type: object
      required:
      - outcome
      - cstat
      - access_key
      - message
      properties:
        outcome:
          type: string
          enum:
          - authorized
          - cancelled
          - rejected
          - pending
          - unavailable
          - not_sent
          - no_credentials
        cstat:
          type:
          - string
          - 'null'
        access_key:
          type:
          - string
          - 'null'
          pattern: ^\d{44}$
        message:
          type:
          - string
          - 'null'
    CteQueryResult:
      type: object
      required:
      - document
      - authorization
      - financial
      properties:
        document:
          anyOf:
          - type: object
            allOf:
            - $ref: '#/components/schemas/Cte'
          - type: 'null'
        authorization:
          $ref: '#/components/schemas/CteAuthorization'
        financial:
          type:
          - object
          - 'null'
          additionalProperties: true
    CteQueryEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CteQueryResult'
        environment:
          $ref: '#/components/schemas/Environment'
    CteEventEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CteEvent'
        environment:
          $ref: '#/components/schemas/Environment'
    CteServiceInput:
      type: object
      required:
      - ind_ie_toma
      - retira
      properties:
        cfop:
          type:
          - string
          - 'null'
          minLength: 4
          maxLength: 4
        nat_op:
          type:
          - string
          - 'null'
          maxLength: 60
        tp_serv:
          type:
          - integer
          - 'null'
          minimum: 0
          maximum: 4
        ind_ie_toma:
          type: integer
          enum:
          - 1
          - 2
          - 9
        retira:
          type: string
          enum:
          - '0'
          - '1'
        x_det_retira:
          type:
          - string
          - 'null'
          maxLength: 160
    CteRouteInput:
      type: object
      required:
      - origem_uf
      - destino_uf
      properties:
        origem_codigo_municipio:
          type:
          - string
          - 'null'
          pattern: ^\d{7}$
        origem_municipio:
          type:
          - string
          - 'null'
          maxLength: 80
        origem_uf:
          type: string
          minLength: 2
          maxLength: 2
        destino_codigo_municipio:
          type:
          - string
          - 'null'
          pattern: ^\d{7}$
        destino_municipio:
          type:
          - string
          - 'null'
          maxLength: 80
        destino_uf:
          type: string
          minLength: 2
          maxLength: 2
    CtePayerInput:
      type: object
      required:
      - tipo
      properties:
        tipo:
          type: integer
          enum:
          - 0
          - 3
          - 4
          description: 0 remetente, 3 destinatário, 4 outros.
        documento:
          type:
          - string
          - 'null'
          maxLength: 14
          description: Obrigatório quando `tipo` for 4.
        ie:
          type:
          - string
          - 'null'
          maxLength: 20
        nome:
          type:
          - string
          - 'null'
          maxLength: 120
        logradouro:
          type:
          - string
          - 'null'
          maxLength: 120
        numero:
          type:
          - string
          - 'null'
          maxLength: 20
        complemento:
          type:
          - string
          - 'null'
          maxLength: 60
        bairro:
          type:
          - string
          - 'null'
          maxLength: 80
        codigo_municipio:
          type:
          - string
          - 'null'
          pattern: ^\d{7}$
        municipio:
          type:
          - string
          - 'null'
          maxLength: 80
        uf:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 2
        cep:
          type:
          - string
          - 'null'
          pattern: ^\d{8}$
        email:
          type:
          - string
          - 'null'
          format: email
          maxLength: 120
    CteValuesInput:
      type: object
      required:
      - total
      properties:
        total:
          type: number
          format: double
          minimum: 0.01
        receber:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        componentes:
          type:
          - array
          - 'null'
          maxItems: 20
          items:
            type: object
            properties:
              nome:
                type:
                - string
                - 'null'
                maxLength: 60
              valor:
                type:
                - number
                - 'null'
                format: double
                minimum: 0
    CteIcmsInput:
      type: object
      required:
      - variante
      - cst
      description: Os campos numéricos obrigatórios dependem da variante escolhida.
      properties:
        variante:
          type: string
          enum:
          - ICMS00
          - ICMS20
          - ICMS45
          - ICMS60
          - ICMS90
          - ICMSOutraUF
          - ICMSSN
        cst:
          type: string
          minLength: 2
          maxLength: 2
        v_bc:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        p_icms:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
          maximum: 100
        v_icms:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        p_red_bc:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
          maximum: 100
        v_bc_st_ret:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        v_icms_st_ret:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        p_icms_st_ret:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
          maximum: 100
        v_cred:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
    CteCargoInput:
      type:
      - object
      - 'null'
      properties:
        valor:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        produto_predominante:
          type:
          - string
          - 'null'
          maxLength: 60
        peso_bruto:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        peso_liquido:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        volumes:
          type:
          - integer
          - 'null'
          minimum: 0
    CteTripInput:
      type:
      - object
      - 'null'
      properties:
        trip_starts_at:
          type:
          - string
          - 'null'
          format: date
        trip_ends_at:
          type:
          - string
          - 'null'
          format: date
        trip_distance_km:
          type:
          - integer
          - 'null'
          minimum: 0
          maximum: 99999
        cargo_sh_code:
          type:
          - string
          - 'null'
          pattern: ^\d{4}$
        cargo_type_code:
          type:
          - integer
          - 'null'
          minimum: 1
          maximum: 12
        toll_value:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
        fuel_value:
          type:
          - number
          - 'null'
          format: double
          minimum: 0
    CteCiotInput:
      type:
      - object
      - 'null'
      properties:
        tipo_operacao:
          type:
          - integer
          - 'null'
          enum:
          - 1
          - 2
          - 3
        alto_desempenho:
          type:
          - boolean
          - 'null'
        retorno_vazio:
          type:
          - boolean
          - 'null'
        composicao_veicular:
          type:
          - boolean
          - 'null'
    CtePreviousPartyInput:
      type:
      - object
      - 'null'
      properties:
        documento:
          type:
          - string
          - 'null'
          maxLength: 14
        ie:
          type:
          - string
          - 'null'
          maxLength: 20
        nome:
          type:
          - string
          - 'null'
          maxLength: 120
        fantasia:
          type:
          - string
          - 'null'
          maxLength: 120
        endereco:
          type:
          - object
          - 'null'
          properties:
            logradouro:
              type:
              - string
              - 'null'
              maxLength: 120
            numero:
              type:
              - string
              - 'null'
              maxLength: 20
            complemento:
              type:
              - string
              - 'null'
              maxLength: 60
            bairro:
              type:
              - string
              - 'null'
              maxLength: 80
            codigo_municipio:
              type:
              - string
              - 'null'
              pattern: ^\d{7}$
            municipio:
              type:
              - string
              - 'null'
              maxLength: 80
            uf:
              type:
              - string
              - 'null'
              minLength: 2
              maxLength: 2
            cep:
              type:
              - string
              - 'null'
              pattern: ^\d{8}$
            telefone:
              type:
              - string
              - 'null'
              maxLength: 20
    CtePreviousInput:
      type:
      - object
      - 'null'
      required:
      - chave
      properties:
        chave:
          type: string
          pattern: ^\d{44}$
        tp_serv_origem:
          type:
          - integer
          - 'null'
          minimum: 0
          maximum: 4
        nfe_chaves:
          type:
          - array
          - 'null'
          maxItems: 100
          items:
            type: string
            pattern: ^\d{44}$
        carga:
          type:
          - object
          - 'null'
          properties:
            valor:
              type:
              - number
              - 'null'
              minimum: 0
            produto_predominante:
              type:
              - string
              - 'null'
              maxLength: 60
            peso_bruto:
              type:
              - number
              - 'null'
              minimum: 0
            volumes:
              type:
              - integer
              - 'null'
              minimum: 0
        v_prest_origem:
          type:
          - number
          - 'null'
          minimum: 0
        emit:
          $ref: '#/components/schemas/CtePreviousPartyInput'
        rem:
          $ref: '#/components/schemas/CtePreviousPartyInput'
        dest:
          $ref: '#/components/schemas/CtePreviousPartyInput'
    CteDraftInput:
      type: object
      required:
      - prestacao
      - rota
      - tomador
      - valores
      - icms
      description: 'Informe `nfe_access_keys` com ao menos uma NF-e, ou `cte_anterior.chave` para

        subcontratação. As referências de NF-e, veículo e motorista pertencem à transportadora autenticada.

        '
      properties:
        nfe_access_keys:
          type: array
          minItems: 1
          uniqueItems: true
          items:
            type: string
            pattern: ^\d{44}$
        cte_anterior:
          $ref: '#/components/schemas/CtePreviousInput'
        prestacao:
          $ref: '#/components/schemas/CteServiceInput'
        rota:
          $ref: '#/components/schemas/CteRouteInput'
        tomador:
          $ref: '#/components/schemas/CtePayerInput'
        valores:
          $ref: '#/components/schemas/CteValuesInput'
        icms:
          $ref: '#/components/schemas/CteIcmsInput'
        carga:
          $ref: '#/components/schemas/CteCargoInput'
        veiculo:
          type:
          - object
          - 'null'
          properties:
            vehicle_id:
              type:
              - integer
              - 'null'
              minimum: 1
            trailer_vehicle_id:
              type:
              - integer
              - 'null'
              minimum: 1
        motorista:
          type:
          - object
          - 'null'
          properties:
            driver_user_id:
              type:
              - integer
              - 'null'
              minimum: 1
        viagem:
          $ref: '#/components/schemas/CteTripInput'
        ciot:
          $ref: '#/components/schemas/CteCiotInput'
        observacoes:
          type:
          - string
          - 'null'
          maxLength: 2000
    JustificationInput:
      type: object
      required:
      - justification
      properties:
        justification:
          type: string
          minLength: 15
          maxLength: 255
    CteCorrectionInput:
      type: object
      required:
      - alterations
      properties:
        alterations:
          type: array
          minItems: 1
          maxItems: 20
          items:
            type: object
            required:
            - group
            - field
            - value
            properties:
              group:
                type: string
                maxLength: 20
              field:
                type: string
                maxLength: 20
                description: Campos fiscais vedados não podem ser corrigidos por este evento.
              value:
                type: string
                maxLength: 500
              item:
                type:
                - integer
                - 'null'
                minimum: 1
                maximum: 99
    CteDeliveryInput:
      type: object
      required:
      - proof
      properties:
        proof:
          type: string
          maxLength: 14000000
          pattern: ^data:image/(png|jpe?g);base64,
          description: Imagem PNG ou JPEG em data URL base64.
        receiver_name:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 60
        receiver_document:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 60
        invoice_keys:
          type:
          - array
          - 'null'
          maxItems: 2000
          uniqueItems: true
          items:
            type: string
            pattern: ^\d{44}$
        delivered_at:
          type:
          - string
          - 'null'
          pattern: ^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$
        information:
          type:
          - string
          - 'null'
          maxLength: 2000
        longitude:
          type:
          - number
          - 'null'
          minimum: -180
          maximum: 180
        latitude:
          type:
          - number
          - 'null'
          minimum: -90
          maximum: 90
    CteDeliveryCancellationInput:
      type: object
      description: Informe exatamente um entre `sequence` e `protocol`.
      properties:
        sequence:
          type:
          - integer
          - 'null'
          minimum: 1
          maximum: 999
        protocol:
          type:
          - string
          - 'null'
          maxLength: 80
      oneOf:
      - required:
        - sequence
      - required:
        - protocol
    CiotCheckResult:
      type: object
      required:
      - can_issue
      - warnings
      - blocking_reason
      - fleet
      - checked_at
      properties:
        can_issue:
          type: boolean
        warnings:
          type: array
          items:
            type: string
        blocking_reason:
          type:
          - string
          - 'null'
        fleet:
          type:
          - object
          - 'null'
          additionalProperties: true
        checked_at:
          type: string
          format: date-time
    CiotCheckEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CiotCheckResult'
        environment:
          $ref: '#/components/schemas/Environment'
    CiotOperationData:
      type: object
      required:
      - document
      - ciot
      properties:
        document:
          anyOf:
          - type: object
            allOf:
            - $ref: '#/components/schemas/Cte'
          - type: 'null'
        ciot:
          type: object
          required:
          - status
          - number
          - verification_code
          - protocol
          - message
          properties:
            status:
              $ref: '#/components/schemas/CiotStatus'
            number:
              type:
              - string
              - 'null'
            verification_code:
              type:
              - string
              - 'null'
            protocol:
              type:
              - string
              - 'null'
            message:
              type:
              - string
              - 'null'
    CiotOperationEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/CiotOperationData'
        environment:
          $ref: '#/components/schemas/Environment'
    CiotRouteLeg:
      type: object
      required:
      - origem
      - destino
      properties:
        origem:
          type: object
          required:
          - codigo_municipio_origem
          properties:
            codigo_municipio_origem:
              type: string
              pattern: ^\d{7}$
        destino:
          type: object
          required:
          - codigo_municipio_destino
          properties:
            codigo_municipio_destino:
              type: string
              pattern: ^\d{7}$
        distancia_percorrida:
          type:
          - integer
          - 'null'
          minimum: 1
        qtd_viagens:
          type:
          - integer
          - 'null'
          minimum: 1
          maximum: 999
    CiotCargoChange:
      type:
      - object
      - 'null'
      properties:
        codigo_natureza_carga:
          type:
          - string
          - 'null'
          pattern: ^\d{4}$
        peso_carga:
          type:
          - number
          - 'null'
          format: double
          exclusiveMinimum: 0
        codigo_tipo_carga:
          type:
          - integer
          - 'null'
          minimum: 4
          maximum: 12
    CiotRectificationInput:
      type: object
      minProperties: 1
      description: Informe ao menos um grupo de alteração.
      properties:
        valor_frete:
          type:
          - number
          - 'null'
          format: double
          exclusiveMinimum: 0
        data_fim_viagem:
          type:
          - string
          - 'null'
          format: date
        origem_destino:
          type:
          - array
          - 'null'
          minItems: 1
          maxItems: 20
          items:
            $ref: '#/components/schemas/CiotRouteLeg'
        dados_carga:
          $ref: '#/components/schemas/CiotCargoChange'
    CiotClosingInput:
      type: object
      required:
      - peso_carga
      properties:
        peso_carga:
          type: number
          format: double
          exclusiveMinimum: 0
        origem_destino:
          type:
          - array
          - 'null'
          minItems: 1
          maxItems: 20
          items:
            $ref: '#/components/schemas/CiotRouteLeg'
    VehicleFiscalData:
      type: object
      required:
      - brand
      - model
      - vehicle_kind
      - axles
      - tare_kg
      - wheel_type
      - body_type
      - km_per_liter_model
      - km_per_liter_vehicle
      - owner_ie
      - owner_state
      properties:
        brand:
          type:
          - string
          - 'null'
        model:
          type:
          - string
          - 'null'
        vehicle_kind:
          type:
          - integer
          - 'null'
          enum:
          - 1
          - 2
        axles:
          type:
          - integer
          - 'null'
        tare_kg:
          type:
          - integer
          - 'null'
        wheel_type:
          type:
          - integer
          - 'null'
        body_type:
          type:
          - integer
          - 'null'
        km_per_liter_model:
          type:
          - number
          - 'null'
          format: double
        km_per_liter_vehicle:
          type:
          - number
          - 'null'
          format: double
        owner_ie:
          type:
          - string
          - 'null'
        owner_state:
          type:
          - string
          - 'null'
    Vehicle:
      type: object
      required:
      - id
      - plate
      - plate_state
      - renavam
      - owner_type
      - owner_document
      - owner_name
      - owner_rntrc
      - fiscal
      properties:
        id:
          type: integer
          minimum: 1
        plate:
          type: string
        plate_state:
          type:
          - string
          - 'null'
        renavam:
          type:
          - string
          - 'null'
        owner_type:
          type: string
          enum:
          - own
          - third
        owner_document:
          type:
          - string
          - 'null'
        owner_name:
          type:
          - string
          - 'null'
        owner_rntrc:
          type:
          - string
          - 'null'
        fiscal:
          $ref: '#/components/schemas/VehicleFiscalData'
    VehicleCreateInput:
      type: object
      required:
      - plate
      properties:
        plate:
          type: string
          pattern: ^[A-Z]{3}[0-9][A-Z0-9][0-9]{2}$
        plate_state:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 2
        renavam:
          type:
          - string
          - 'null'
          pattern: ^\d{11}$
        tare_kg:
          type:
          - number
          - 'null'
          minimum: 0
        capacity_kg:
          type:
          - number
          - 'null'
          minimum: 0
        capacity_m3:
          type:
          - number
          - 'null'
          minimum: 0
        axles:
          type:
          - number
          - 'null'
          minimum: 0
          maximum: 255
        body_type:
          type:
          - number
          - 'null'
          minimum: 0
          maximum: 255
        wheel_type:
          type:
          - number
          - 'null'
          minimum: 0
          maximum: 255
        owner_type:
          type:
          - string
          - 'null'
          enum:
          - own
          - third
          default: own
        owner_document:
          type:
          - string
          - 'null'
          maxLength: 14
        owner_name:
          type:
          - string
          - 'null'
          maxLength: 120
        owner_rntrc:
          type:
          - string
          - 'null'
          maxLength: 8
        default_driver_user_id:
          type:
          - integer
          - 'null'
          minimum: 1
    VehicleFiscalInput:
      type: object
      minProperties: 1
      description: Atualização parcial; envie ao menos uma propriedade.
      properties:
        brand:
          type:
          - string
          - 'null'
          maxLength: 40
        model:
          type:
          - string
          - 'null'
          maxLength: 60
        vehicle_kind:
          type:
          - integer
          - 'null'
          enum:
          - 1
          - 2
        axles:
          type:
          - integer
          - 'null'
          minimum: 1
          maximum: 255
        km_per_liter_model:
          type:
          - number
          - 'null'
          minimum: 0
          maximum: 999.99
        km_per_liter_vehicle:
          type:
          - number
          - 'null'
          minimum: 0
          maximum: 999.99
        tare_kg:
          type:
          - integer
          - 'null'
          minimum: 1
          maximum: 999999
        wheel_type:
          type:
          - string
          - 'null'
          enum:
          - '01'
          - '02'
          - '03'
          - '04'
          - '05'
          - '06'
        body_type:
          type:
          - string
          - 'null'
          enum:
          - '00'
          - '01'
          - '02'
          - '03'
          - '04'
          - '05'
        owner_ie:
          type:
          - string
          - 'null'
          maxLength: 20
        owner_state:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 2
    VehicleEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/Vehicle'
        environment:
          $ref: '#/components/schemas/Environment'
    VehicleListEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Vehicle'
        environment:
          $ref: '#/components/schemas/Environment'
    DriverFiscalProfile:
      type: object
      required:
      - cnh_number
      - cnh_category
      - cnh_state
      - cnh_issued_at
      - cnh_valid_until
      - rg_number
      - rg_issuer
      - rg_state
      - father_name
      - mother_name
      properties:
        cnh_number:
          type:
          - string
          - 'null'
        cnh_category:
          type:
          - string
          - 'null'
        cnh_state:
          type:
          - string
          - 'null'
        cnh_issued_at:
          type:
          - string
          - 'null'
          format: date
        cnh_valid_until:
          type:
          - string
          - 'null'
          format: date
        rg_number:
          type:
          - string
          - 'null'
        rg_issuer:
          type:
          - string
          - 'null'
        rg_state:
          type:
          - string
          - 'null'
        father_name:
          type:
          - string
          - 'null'
        mother_name:
          type:
          - string
          - 'null'
    Driver:
      type: object
      required:
      - id
      - name
      - document
      - fiscal_profile
      properties:
        id:
          type: integer
          minimum: 1
        name:
          type: string
        document:
          type:
          - string
          - 'null'
        fiscal_profile:
          anyOf:
          - type: object
            allOf:
            - $ref: '#/components/schemas/DriverFiscalProfile'
          - type: 'null'
    DriverFiscalInput:
      type: object
      minProperties: 1
      description: Atualização parcial; envie ao menos uma propriedade.
      properties:
        cnh_number:
          type:
          - string
          - 'null'
          pattern: ^\d{11}$
        cnh_category:
          type:
          - string
          - 'null'
          enum:
          - A
          - B
          - C
          - D
          - E
          - AB
          - AC
          - AD
          - AE
        cnh_state:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 2
        cnh_issued_at:
          type:
          - string
          - 'null'
          format: date
        cnh_valid_until:
          type:
          - string
          - 'null'
          format: date
        rg_number:
          type:
          - string
          - 'null'
          maxLength: 20
        rg_issuer:
          type:
          - string
          - 'null'
          maxLength: 20
        rg_state:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 2
        father_name:
          type:
          - string
          - 'null'
          maxLength: 120
        mother_name:
          type:
          - string
          - 'null'
          maxLength: 120
    DriverEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/Driver'
        environment:
          $ref: '#/components/schemas/Environment'
    DriverListEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Driver'
        environment:
          $ref: '#/components/schemas/Environment'
    MdfeStatus:
      type: string
      enum:
      - draft
      - sent
      - waiting
      - authorized
      - rejected
      - closed
      - cancelled
    Mdfe:
      type: object
      required:
      - id
      - status
      - vehicle
      - driver_id
      - trailers
      - route
      - cte_ids
      - number
      - series
      - access_key
      - protocol
      - sefaz_protocol
      - cstat
      - reason
      - authorized_at
      - closed_at
      - closing_protocol
      - payload
      - created_at
      - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: UUID público usado em todos os caminhos do MDF-e.
        status:
          $ref: '#/components/schemas/MdfeStatus'
        vehicle:
          $ref: '#/components/schemas/Vehicle'
        driver_id:
          type:
          - integer
          - 'null'
        trailers:
          type: array
          items:
            allOf:
            - $ref: '#/components/schemas/Vehicle'
            - type: object
              required:
              - position
              properties:
                position:
                  type: integer
                  minimum: 1
                  maximum: 3
        route:
          allOf:
          - $ref: '#/components/schemas/FiscalRoute'
          - type: object
            required:
            - starts_at
            - ends_at
            properties:
              starts_at:
                type:
                - string
                - 'null'
                format: date
              ends_at:
                type:
                - string
                - 'null'
                format: date
        cte_ids:
          type: array
          description: UUIDs públicos dos CT-e autorizados cobertos pelo MDF-e.
          items:
            type: string
            format: uuid
        number:
          type:
          - integer
          - 'null'
        series:
          type:
          - string
          - 'null'
        access_key:
          type:
          - string
          - 'null'
          pattern: ^\d{44}$
        protocol:
          type:
          - string
          - 'null'
        sefaz_protocol:
          type:
          - string
          - 'null'
        cstat:
          type:
          - string
          - 'null'
        reason:
          type:
          - string
          - 'null'
        authorized_at:
          type:
          - string
          - 'null'
          format: date-time
        closed_at:
          type:
          - string
          - 'null'
          format: date
        closing_protocol:
          type:
          - string
          - 'null'
        payload:
          type: object
          additionalProperties: true
        created_at:
          type:
          - string
          - 'null'
          format: date-time
        updated_at:
          type:
          - string
          - 'null'
          format: date-time
    MdfeInsuranceInput:
      type:
      - object
      - 'null'
      properties:
        responsavel:
          type:
          - string
          - 'null'
          enum:
          - '1'
          - '2'
        documento:
          type:
          - string
          - 'null'
          maxLength: 14
        seguradora:
          type:
          - string
          - 'null'
          maxLength: 30
        cnpj_seguradora:
          type:
          - string
          - 'null'
          pattern: ^\d{14}$
        apolice:
          type:
          - string
          - 'null'
          maxLength: 20
        averbacoes:
          type:
          - array
          - 'null'
          maxItems: 20
          items:
            type:
            - string
            - 'null'
            maxLength: 40
    MdfeTechnicalContactInput:
      type:
      - object
      - 'null'
      properties:
        cnpj:
          type:
          - string
          - 'null'
          pattern: ^\d{14}$
        contato:
          type:
          - string
          - 'null'
          maxLength: 60
        email:
          type:
          - string
          - 'null'
          format: email
          maxLength: 60
        telefone:
          type:
          - string
          - 'null'
          maxLength: 20
    MdfeDraftInput:
      type: object
      required:
      - cte_uuids
      - vehicle_id
      - origin_state
      - destination_state
      properties:
        cte_uuids:
          type: array
          minItems: 1
          uniqueItems: true
          description: UUIDs públicos de CT-e autorizados e disponíveis.
          items:
            type: string
            format: uuid
        vehicle_id:
          type: integer
          minimum: 1
        trailers:
          type:
          - array
          - 'null'
          maxItems: 3
          uniqueItems: true
          items:
            type: integer
            minimum: 1
        driver_user_id:
          type:
          - integer
          - 'null'
          minimum: 1
        starts_at:
          type:
          - string
          - 'null'
          format: date
        ends_at:
          type:
          - string
          - 'null'
          format: date
        origin_city_code:
          type:
          - string
          - 'null'
          pattern: ^\d{7}$
        origin_city:
          type:
          - string
          - 'null'
          maxLength: 80
        origin_state:
          type: string
          minLength: 2
          maxLength: 2
        destination_city_code:
          type:
          - string
          - 'null'
          pattern: ^\d{7}$
        destination_city:
          type:
          - string
          - 'null'
          maxLength: 80
        destination_state:
          type: string
          minLength: 2
          maxLength: 2
        seguro:
          $ref: '#/components/schemas/MdfeInsuranceInput'
        salvar_seguro_padrao:
          type:
          - boolean
          - 'null'
        info_fisco:
          type:
          - string
          - 'null'
          maxLength: 2000
        observacoes:
          type:
          - string
          - 'null'
          maxLength: 5000
        resp_tec:
          $ref: '#/components/schemas/MdfeTechnicalContactInput'
        serie:
          type:
          - string
          - 'null'
          maxLength: 3
    MdfeEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/Mdfe'
        environment:
          $ref: '#/components/schemas/Environment'
    MdfeListEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          type: object
          required:
          - items
          - pagination
          properties:
            items:
              type: array
              items:
                $ref: '#/components/schemas/Mdfe'
            pagination:
              $ref: '#/components/schemas/Pagination'
        environment:
          $ref: '#/components/schemas/Environment'
    MdfeOperationData:
      type: object
      required:
      - document
      - message
      properties:
        document:
          anyOf:
          - type: object
            allOf:
            - $ref: '#/components/schemas/Mdfe'
          - type: 'null'
        message:
          type:
          - string
          - 'null'
    MdfeOperationEnvelope:
      type: object
      required:
      - data
      - environment
      properties:
        data:
          $ref: '#/components/schemas/MdfeOperationData'
        environment:
          $ref: '#/components/schemas/Environment'
    MdfeClosingInput:
      type: object
      required:
      - closing_city_code
      - closed_on
      properties:
        closing_city_code:
          type: string
          pattern: ^\d{7}$
        closing_city:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 60
        closing_state:
          type:
          - string
          - 'null'
          minLength: 2
          maxLength: 2
        closed_on:
          type: string
          format: date
          description: Data civil igual ou anterior à data atual.
    MdfeDriverInput:
      type: object
      required:
      - cpf
      - name
      properties:
        cpf:
          type: string
          pattern: ^\d{11}$
        name:
          type: string
          minLength: 2
          maxLength: 60
  examples:
    CteDraftInput:
      summary: CT-e normal com NF-e, frota, motorista e dados do CIOT
      value:
        nfe_access_keys:
        - '35260812345678000190550010000018421000018420'
        prestacao:
          cfop: '5353'
          nat_op: Prestação de serviço de transporte
          tp_serv: 0
          ind_ie_toma: 1
          retira: '0'
          x_det_retira: null
        rota:
          origem_codigo_municipio: '3550308'
          origem_municipio: São Paulo
          origem_uf: SP
          destino_codigo_municipio: '3304557'
          destino_municipio: Rio de Janeiro
          destino_uf: RJ
        tomador:
          tipo: 4
          documento: '12345678000190'
          ie: '123456789112'
          nome: Comercial Exemplo Ltda.
          logradouro: Avenida Central
          numero: '1000'
          complemento: Galpão 2
          bairro: Centro
          codigo_municipio: '3550308'
          municipio: São Paulo
          uf: SP
          cep: '01001000'
          email: fiscal@example.com
        valores:
          total: 1850.5
          receber: 1800.5
          componentes:
          - nome: FRETE VALOR
            valor: 1650.5
          - nome: PEDÁGIO
            valor: 200
        icms:
          variante: ICMS00
          cst: '00'
          v_bc: 1850.5
          p_icms: 12
          v_icms: 222.06
          p_red_bc: null
          v_bc_st_ret: null
          v_icms_st_ret: null
          p_icms_st_ret: null
          v_cred: null
        carga:
          valor: 48000
          produto_predominante: Alimentos embalados
          peso_bruto: 12500
          peso_liquido: 12000
          volumes: 480
        veiculo:
          vehicle_id: 71
          trailer_vehicle_id: 72
        motorista:
          driver_user_id: 903
        viagem:
          trip_starts_at: '2026-08-06'
          trip_ends_at: '2026-08-07'
          trip_distance_km: 435
          cargo_sh_code: '0001'
          cargo_type_code: 5
          toll_value: 184.9
          fuel_value: 950
        ciot:
          tipo_operacao: 1
          alto_desempenho: false
          retorno_vazio: false
          composicao_veicular: true
        observacoes: Entrega agendada para 07/08/2026.
    CteDeliveryInput:
      summary: Comprovante de entrega
      value:
        proof: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...
        receiver_name: Maria da Silva
        receiver_document: '12345678901'
        invoice_keys:
        - '35260812345678000190550010000018421000018420'
        delivered_at: '2026-08-07 16:30:00'
        information: Mercadoria entregue sem ressalvas.
        longitude: -43.1729
        latitude: -22.9068
    CiotRectificationInput:
      summary: Retificação de frete, rota e carga
      value:
        valor_frete: 1900.5
        data_fim_viagem: '2026-08-08'
        origem_destino:
        - origem:
            codigo_municipio_origem: '3550308'
          destino:
            codigo_municipio_destino: '3304557'
          distancia_percorrida: 435
          qtd_viagens: 1
        dados_carga:
          codigo_natureza_carga: '0001'
          peso_carga: 12500
          codigo_tipo_carga: 5
    CiotClosingInput:
      summary: Encerramento do CIOT
      value:
        peso_carga: 12500
        origem_destino:
        - origem:
            codigo_municipio_origem: '3550308'
          destino:
            codigo_municipio_destino: '3304557'
          distancia_percorrida: 435
          qtd_viagens: 1
    VehicleCreateInput:
      summary: Veículo de tração próprio
      value:
        plate: ABC1D23
        plate_state: SP
        renavam: '12345678901'
        tare_kg: 8500
        capacity_kg: 28000
        capacity_m3: 90
        axles: 3
        body_type: 2
        wheel_type: 3
        owner_type: own
        owner_document: '12345678000190'
        owner_name: Transportadora Exemplo Ltda.
        owner_rntrc: '12345678'
        default_driver_user_id: 903
    VehicleFiscalInput:
      summary: Complemento fiscal completo
      value:
        brand: Marca Exemplo
        model: Modelo 6x2
        vehicle_kind: 1
        axles: 3
        km_per_liter_model: 2.6
        km_per_liter_vehicle: 2.4
        tare_kg: 8500
        wheel_type: '03'
        body_type: '02'
        owner_ie: '123456789112'
        owner_state: SP
    DriverFiscalInput:
      summary: Perfil fiscal completo
      value:
        cnh_number: '12345678901'
        cnh_category: E
        cnh_state: SP
        cnh_issued_at: '2024-01-15'
        cnh_valid_until: '2029-01-15'
        rg_number: '123456789'
        rg_issuer: SSP
        rg_state: SP
        father_name: José da Silva
        mother_name: Ana da Silva
    MdfeDraftInput:
      summary: MDF-e com dois CT-e e um reboque
      value:
        cte_uuids:
        - 65059145-acde-48ec-96bd-0bf46be6881d
        - 99868737-ff39-4a36-933a-3f69650ec88f
        vehicle_id: 71
        trailers:
        - 72
        driver_user_id: 903
        starts_at: '2026-08-06'
        ends_at: '2026-08-07'
        origin_city_code: '3550308'
        origin_city: São Paulo
        origin_state: SP
        destination_city_code: '3304557'
        destination_city: Rio de Janeiro
        destination_state: RJ
        seguro:
          responsavel: '1'
          documento: '12345678000190'
          seguradora: Seguradora Exemplo
          cnpj_seguradora: '98765432000110'
          apolice: AP-2026-0001842
          averbacoes:
          - AVB-000001
          - AVB-000002
        salvar_seguro_padrao: false
        info_fisco: Informações adicionais de interesse do fisco.
        observacoes: Viagem em homologação.
        resp_tec:
          cnpj: '12345678000190'
          contato: Equipe de Integração
          email: integracao@example.com
          telefone: '1133334444'
        serie: '1'
jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
