← HomeFleetPay / API

Receive a third-party CT-e

Parameters, data structure and responses from the versioned contract.

POST/fiscal/cte-subcontratacao
receiveInboundCteSandbox Base: https://api.fleetpay.site/v1

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

Submits to FleetPay the XML of a CT-e issued by another company, typically the contracting carrier, which is the source for your subcontracting counter-CT-e.

Purpose

Other reception methods depend on a third party between you and the platform. Here, your system submits the document directly, making it available in FleetPay even without a contracted automatic reception service.

This also enables POST /fiscal/cte/contra: that endpoint needs the original CT-e XML to prepare the counter-CT-e and can find it here.

Submission

Choose one of two forms:

  • application/json with the xml field: raw XML or base64. Encoding is detected from the content; no flag is required.
  • multipart/form-data with the arquivo field.

Accepts cteProc (with protocol) or raw CTe. Limit: 2 MB.

Safe Resubmission

The operation is idempotent by access key. The first submission returns 201; subsequent submissions return 200 with the same resource and an incremented received_count. Network retries, nightly reprocessing and double clicks do not create duplicate records or errors.

If a resubmission contains XML different from the archived version, commonly when sending CTe followed by cteProc with the protocol, the content is replaced by the latest version and content_updated is true.

Reception Is Not Issuance

Recording receipt does not generate any fiscal document. The counter-CT-e is still created through POST /fiscal/cte/contra, with the driver, vehicle and price for your leg; none of these three is in the contracting carrier's XML.

A CT-e that does not allow a counter-CT-e, such as one issued by your own company, is still received: carrier_role identifies your role and allows_counter_cte indicates eligibility, so you do not need to reimplement the rule.

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

xmlstringRequired

CT-e XML, raw or base64-encoded. Accepts cteProc (with protocol) or CTe.

maxLength2097152

multipart/form-data

arquivostring · binaryRequired

CT-e XML, up to 2 MB.

Responses

200 HTTP Response

Previously known document. Delivery is idempotent: the same resource is returned, with received_count incremented.

application/json

Headers

X-Request-Id

Call correlation identifier.

201 HTTP Response

First receipt of this document; the resource was created.

application/json

Headers

X-Request-Id

Call correlation identifier.

400 HTTP Response

Invalid payload.

application/json

Headers

X-Request-Id

Call correlation identifier.

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 de subcontratação"
  ],
  "summary": "Receber um CT-e de terceiro",
  "description": "Entrega à FleetPay o XML de um CT-e emitido por outra empresa — tipicamente o da\ntransportadora **contratante**, que dá origem ao seu contra-CT-e de subcontratação.\n\n## Por que existe\n\nAs demais formas de recepção dependem de um terceiro entre você e a plataforma. Aqui é o\nseu sistema que entrega o documento, e ele passa a existir na FleetPay sem intermediário\n— inclusive quando nenhuma recepção automática está contratada.\n\nÉ também o que destrava `POST /fiscal/cte/contra`: aquele endpoint precisa do XML do CT-e\noriginal para montar o contra-CT-e, e passa a encontrá-lo aqui.\n\n## Como enviar\n\nDuas formas, escolha uma:\n\n- `application/json` com o campo `xml` — o XML cru ou em **base64**. A codificação é\n  detectada pelo conteúdo; não há flag a acertar.\n- `multipart/form-data` com o campo `arquivo`.\n\nO documento pode ser o `cteProc` (com protocolo) ou o `CTe` cru. Limite de 2 MB.\n\n## Reenviar é seguro\n\nA operação é **idempotente pela chave de acesso**. O primeiro envio responde `201`; os\nseguintes respondem `200` com o mesmo recurso e `received_count` somado. Retry de rede,\nreprocessamento noturno e clique duplo não criam registro duplicado nem erro.\n\nSe o reenvio trouxer um XML diferente do arquivado — o caso comum é mandar o `CTe` e\ndepois o `cteProc` com o protocolo —, o conteúdo é substituído pelo mais recente e\n`content_updated` vem `true`.\n\n## Receber não é emitir\n\nRegistrar a chegada não gera documento fiscal nenhum. O contra-CT-e continua nascendo em\n`POST /fiscal/cte/contra`, com motorista, veículo e o preço do **seu** trecho — nenhum dos\ntrês está no XML da contratante.\n\nUm CT-e que não admite contra-CT-e (por exemplo, um que a sua própria empresa emitiu) é\nrecebido do mesmo jeito: o campo `carrier_role` nomeia o seu papel e `allows_counter_cte`\nresponde a pergunta prática, sem que você precise reimplementar a regra.\n",
  "operationId": "receiveInboundCte",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/InboundCteInput"
        }
      },
      "multipart/form-data": {
        "schema": {
          "type": "object",
          "required": [
            "arquivo"
          ],
          "properties": {
            "arquivo": {
              "type": "string",
              "format": "binary",
              "description": "XML do CT-e, até 2 MB."
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "$ref": "#/components/responses/InboundCteReceivedAgain"
    },
    "201": {
      "$ref": "#/components/responses/InboundCteReceived"
    },
    "400": {
      "$ref": "#/components/responses/ValidationFailed"
    },
    "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-subcontratacao",
  "parameters": []
}