← HomeFleetPay / API

Issue a contra-CT-e

Parameters, data structure and responses from the versioned contract.

POST/fiscal/cte/contra
issueContraCteSandbox Base: https://api.fleetpay.site/v1

Technical descriptions are translated from the versioned contract. Original identifiers and JSON are preserved; data examples are omitted.

Issues the subcontracted carrier's CT-e against the contracting company's CT-e, referencing its key in infDocAnt and naming the contracting company as the service payer.

tipo_servico sets the counter-CT-e's ide/tpServ: 1 subcontracting (default), 2 onward carriage, 3 intermediate onward carriage. For onward carriage, the route is the segment performed, not the contracting company's entire trip: 2 and 3 require origem and destino (400 validacao if missing). A segment identical to the original CT-e's entire trip returns 422 contra_cte_invalido (redespacho_exige_rota); an original CT-e linked to multimodal transport returns 422 contra_cte_invalido (origem_incompativel_com_tipo). The tax rule is resolved using the segment's route and service type.

The payload is concise: provide the original CT-e key (which must already have arrived in the Monitor DFe inbox), the driver (by CPF), the vehicle (by license plate) performing the segment, and the freight amount — the transfer to the driver. Sender, recipient, cargo, route and taxation are read from the original CT-e XML.

valor_frete is optional: without it, the carrier's pricing rule suggests the segment amount. A 202 response requires polling at /cte/{cte_uuid}/consulta.

Authentication

[
  {
    "oauth2": []
  },
  {
    "chaveApi": []
  }
]
Availability depends on the environment, enabled scopes and provider. This reference does not execute requests or collect credentials.

Parameters

No parameters declared for this operation.

Request Body

Required

application/json

chave_cte_originalstringRequired

Access key (44 digits) of the contracting company's CT-e.

minLength44
maxLength44
motoristaobjectRequired
placastringRequired

Vehicle license plate (Brazilian format, e.g. ABC1D23 or ABC1234).

valor_fretenumber · doubleOptional

Driver transfer amount for the leg. Optional.

minimum0.01
tipo_servicointeger | nullOptional

Counter-CT-e ide/tpServ: 1 subcontracting (default), 2 onward carriage, 3 intermediate onward carriage.

1 · 2 · 3 · null

Responses

202 HTTP Response

Issuance accepted or outcome still inconclusive.

application/json

Headers

X-Request-Id

Call correlation identifier.

400 HTTP Response

Invalid request

application/json

errorobjectOptional
401 HTTP Response

FleetPay API key missing or invalid.

application/json

Headers

X-Request-Id

Call correlation identifier.

403 HTTP Response

Fiscal scope disabled for the key, or no active carrier associated with the key.

application/json

Headers

X-Request-Id

Call correlation identifier.

422 HTTP Response

Invalid payload, outstanding requirement or business rule.

application/json

Headers

X-Request-Id

Call correlation identifier.

429 HTTP Response

Per-carrier limit exceeded.

application/json

Headers

X-Request-Id

Call correlation identifier.

Retry-After

Seconds until another attempt.

500 HTTP Response

Internal failure without operational integration details.

application/json

Headers

X-Request-Id

Call correlation identifier.

Complete Operation Definition
{
  "tags": [
    "CT-e"
  ],
  "summary": "Emitir contra-CT-e (subcontratação ou redespacho)",
  "description": "Emite o CT-e da transportadora **subcontratada** contra o CT-e da contratante, referenciando\na chave dele em `infDocAnt` e com a contratante como tomador.\n\n`tipo_servico` diz o `ide/tpServ` do contra-CT-e: `1` subcontratação (padrão), `2`\nredespacho, `3` redespacho intermediário. No redespacho a rota é o **trecho** executado,\nnão a viagem da contratante: `2` e `3` exigem `origem` e `destino` (`400` `validacao`\nsem eles); um trecho igual à viagem inteira do CT-e original responde `422`\n`contra_cte_invalido` (`redespacho_exige_rota`), e um CT-e original vinculado a\nmultimodal, `422` `contra_cte_invalido` (`origem_incompativel_com_tipo`). A regra de\ntributação é resolvida pela rota do trecho e pelo tipo.\n\nO payload é enxuto: informe a **chave do CT-e original** (que já precisa ter chegado pela\ncaixa do Monitor DFe), o **motorista** (por CPF) e o **veículo** (por placa) que executam o\ntrecho, e o **valor do frete** — o repasse ao motorista. Remetente, destinatário, carga,\nrota e tributação são lidos do XML do CT-e original.\n\n`valor_frete` é opcional: sem ele, a regra de precificação da transportadora sugere o valor\ndo trecho. Uma resposta 202 exige polling em `/cte/{cte_uuid}/consulta`.\n",
  "operationId": "issueContraCte",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "chave_cte_original",
            "motorista",
            "placa"
          ],
          "properties": {
            "chave_cte_original": {
              "type": "string",
              "minLength": 44,
              "maxLength": 44,
              "description": "Chave de acesso (44 dígitos) do CT-e da contratante."
            },
            "motorista": {
              "type": "object",
              "required": [
                "cpf"
              ],
              "properties": {
                "cpf": {
                  "type": "string",
                  "pattern": "^[0-9]{11}$",
                  "description": "CPF do motorista que executa o trecho (somente dígitos)."
                }
              }
            },
            "placa": {
              "type": "string",
              "description": "Placa do veículo (padrão brasileiro, ex. ABC1D23 ou ABC1234)."
            },
            "valor_frete": {
              "type": "number",
              "format": "double",
              "minimum": 0.01,
              "description": "Valor do repasse ao motorista pelo trecho. Opcional."
            },
            "tipo_servico": {
              "type": [
                "integer",
                "null"
              ],
              "enum": [
                1,
                2,
                3,
                null
              ],
              "description": "`ide/tpServ` do contra-CT-e: `1` subcontratação (padrão), `2` redespacho, `3` redespacho intermediário."
            },
            "origem": {
              "$ref": "#/components/schemas/ContraCteLoteRota"
            },
            "destino": {
              "$ref": "#/components/schemas/ContraCteLoteRota"
            }
          }
        }
      }
    }
  },
  "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"
          }
        }
      }
    },
    "400": {
      "$ref": "#/components/responses/Erro400"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "422": {
      "$ref": "#/components/responses/ValidationOrBusinessRuleFailed"
    },
    "429": {
      "$ref": "#/components/responses/RateLimited"
    },
    "500": {
      "$ref": "#/components/responses/InternalError"
    }
  },
  "method": "POST",
  "path": "/fiscal/cte/contra",
  "parameters": []
}