← HomeFleetPay / API

Pass a CT-e to a subcontractor

Parameters, data structure and responses from the versioned contract.

POST/fiscal/cte/{cte_uuid}/subcontratacao
declareCteSubcontractingSandbox Base: https://api.fleetpay.site/v1

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

The contracting company declares which carrier it subcontracted for a CT-e it issued through FleetPay — and its authorized XML is delivered to the subcontracted carrier's tax inbox, exactly as if that carrier had submitted it through POST /fiscal/cte-subcontratacao.

Without this, even with both companies on FleetPay, the subcontracted carrier's ERP had to resend a document the platform already held; skipping that step caused the counter-CT-e batch to report "CT-e original não recebido" (original CT-e not received).

  • Only an authorized CT-e is accepted (cte_nao_autorizado otherwise); the forwarded XML is the exact byte-for-byte copy archived upon authorization.
  • The subcontracted party must be a carrier that is a FleetPay customer (subcontratada_nao_encontrada, subcontratada_nao_transportadora) and cannot be the same company (subcontratada_igual_contratante).
  • The destination inbox matches the CT-e's environment; receipt is idempotent by key: 201 on first delivery, 200 on subsequent deliveries.
  • No financial action takes place here; the subcontracted carrier then follows the normal flow (POST /fiscal/cte/contra or POST /fiscal/cte-subcontratacao/lote).

Depends on the release containing PR core#1459.

Authentication

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

Parameters

cte_uuidpath · stringRequired

Public CT-e UUID.

Constraints
{
  "type": "string",
  "format": "uuid"
}

Request Body

Required

application/json

subcontratadaobjectRequired
observacaostring | nullOptional
maxLength255

Responses

200 HTTP Response

Resubmission — the subcontractor's inbox already contained the document (received_count incremented).

201 HTTP Response

First delivery — the CT-e entered the subcontractor's inbox.

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.

404 HTTP Response

Resource not found in the authenticated tenant.

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.

503 HTTP Response

Archived XML currently unavailable (xml_indisponivel) — try again.

application/json

Complete Operation Definition
{
  "tags": [
    "CT-e de subcontratação"
  ],
  "summary": "Repassar o CT-e à subcontratada (ponte da subcontratação)",
  "operationId": "declareCteSubcontracting",
  "description": "A **contratante** declara a quem subcontratou um CT-e que ela emitiu pela FleetPay — e o\nXML autorizado dele cai na caixa fiscal da **subcontratada**, exatamente como se ela o\ntivesse entregue em `POST /fiscal/cte-subcontratacao`.\n\nSem isto, com as duas empresas na FleetPay, o ERP da subcontratada precisava reenviar um\ndocumento que a plataforma já tinha; esquecer esse passo fazia o lote de contra-CT-e\nresponder \"CT-e original não recebido\".\n\n- Só CT-e **autorizado** (`cte_nao_autorizado` caso contrário); o XML repassado é o\n  arquivado na autorização, byte a byte.\n- A subcontratada precisa ser uma transportadora cliente FleetPay\n  (`subcontratada_nao_encontrada`, `subcontratada_nao_transportadora`) e não pode ser a\n  própria empresa (`subcontratada_igual_contratante`).\n- A caixa de destino é a do **ambiente do CT-e**; a recepção é idempotente pela chave:\n  `201` na primeira entrega, `200` nas seguintes.\n- Nada financeiro acontece aqui; a partir daí a subcontratada segue o fluxo normal\n  (`POST /fiscal/cte/contra` ou `POST /fiscal/cte-subcontratacao/lote`).\n\nDepende do release que leva o PR core#1459.\n",
  "parameters": [
    {
      "$ref": "#/components/parameters/CteUuid"
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "subcontratada"
          ],
          "properties": {
            "subcontratada": {
              "type": "object",
              "required": [
                "cnpj"
              ],
              "properties": {
                "cnpj": {
                  "type": "string",
                  "description": "CNPJ da transportadora subcontratada (com ou sem máscara; aceita CNPJ alfanumérico)."
                }
              }
            },
            "observacao": {
              "type": [
                "string",
                "null"
              ],
              "maxLength": 255
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Reenvio — a caixa da subcontratada já tinha o documento (`received_count` somado)."
    },
    "201": {
      "description": "Primeira entrega — o CT-e entrou na caixa da subcontratada.",
      "headers": {
        "X-Request-Id": {
          "$ref": "#/components/headers/RequestId"
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "data": {
                "type": "object",
                "properties": {
                  "cte": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "access_key": {
                        "type": "string"
                      }
                    }
                  },
                  "subcontratada": {
                    "type": "object",
                    "properties": {
                      "cnpj": {
                        "type": "string"
                      },
                      "nome": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    }
                  },
                  "recebimento": {
                    "$ref": "#/components/schemas/InboundCteReceipt"
                  }
                }
              },
              "environment": {
                "$ref": "#/components/schemas/Environment"
              }
            }
          }
        }
      }
    },
    "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"
    },
    "503": {
      "description": "XML arquivado indisponível agora (`xml_indisponivel`) — tente novamente.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorEnvelope"
          }
        }
      }
    }
  },
  "method": "POST",
  "path": "/fiscal/cte/{cte_uuid}/subcontratacao"
}