/api/cte/createIssue CT-e
Issues a CT-e from the submitted body. The client sends only the business data; the technical access-key identification fields are calculated by the server (see the note below the ide table). Credit is debited only in production (tpAmb=1) and when the CT-e is authorized. When no definitive response is obtained after the request is sent (for example, on a timeout), the server queries the CT-e by its access key: if it is authorized, success is returned; if it still cannot be confirmed, a failure is returned together with chCTe. In that case, /api/cte/consult must be called first to query that key before the CT-e is issued again. The examples below cover the most common case: road mode (modal=01) and Normal CT-e (tpCTe=0).
Required headers
tokenstring | string | Token of the issuing company |
signstring | string | MD5 signature: MD5(token + path + body + timestamp) |
timestampstring | string | Unix timestamp in seconds (5-minute window) |
ide (tpAmb, CFOP, natOp, modal, cMunIni, UFIni, cMunFim, UFFim); emit with CNPJ and xNome; rem with CNPJ or CPF; dest with CNPJ or CPF; vPrest.vTPrest > 0; imp (with one ICMS variant). For tpCTe=0 (Normal): infCTeNorm with infCarga (proPred + at least 1 infQ) and infModal (the mode corresponding to ide.modal; for modal=01, rodo.RNTRC is required; for modal=02, aereo.tarifa.CL is required). For tpCTe=1 (Supplement): infCteComp.chCTe. For tpCTe=3 (Replacement): infCTeNorm.infCteSub.chCte. All other fields are optional.
Body — root
ide*object | object | CT-e identification |
tpAmb*int | int | Environment: 1=production, 2=staging |
CFOP*int | int | Fiscal operation code (e.g.: 5353 within the state, 6353 interstate) |
natOp*string | string | Nature of the operation (e.g.: "PRESTACAO DE SERVICO DE TRANSPORTE") |
modal*string | string | Mode: "01"=road, "02"=air, "03"=waterway, "04"=rail, "05"=pipeline, "06"=multimodal |
tpCTeint | int | CT-e type: 0=Normal, 1=Supplement, 3=Replacement.Default: 0. The CT-e 4.00 layout abolished the Annulment CT-e (2); requests with 2 are rejected |
tpServint | int | Service type: 0=Normal, 1=Subcontracting, 2=Reshipment, 3=Intermediate Reshipment, 4=Service Linked to Multimodal.Default: 0 |
tomaint | int | Service taker: 0=Sender, 1=Dispatcher, 2=Receiver, 3=Recipient, 4=Others.Default: 0 |
toma4object | object | Service taker data — required when toma=4 (see table below) |
CNPJ/CPFstring | string | Service taker's document (one of the two) |
IEstring | string | State Registration |
xNomestring | string | Company name/name |
xFant,fone,emailstring | string | Trade name, phone, e-mail |
enderTomaobject | object | Address: { xLgr, nro, xCpl, xBairro, cMun, xMun, CEP, UF, cPais, xPais } |
indIETomaint | int | Service taker IE indicator: 1=ICMS taxpayer, 2=Exempt, 9=Non-taxpayer (when 9, the service taker's IE is omitted automatically) |
cMunIni*long | long | IBGE code of the service start municipality (7 digits) |
xMunInistring | string | Name of the start municipality |
UFIni*string | string | Start UF (2 letters) |
cMunFim*long | long | IBGE code of the service end municipality (7 digits) |
xMunFimstring | string | Name of the end municipality |
UFFim*string | string | End UF (2 letters) |
cMunEnvlong | long | IBGE code of the issuance municipality |
xMunEnvstring | string | Name of the issuance municipality |
UFEnvstring | string | Issuance UF |
retiraint | int | Pickup at origin: 0=Yes, 1=No.Default: 1 |
xDetRetirastring | string | Pickup details |
tpImpint | int | DACTE format: 1=Portrait, 2=Landscape.Default: 1 |
infPercursoarray | array | Route UFs: [{ UFPer }] |
dhContstring | string | Date/time of entry into contingency (ISO 8601) |
xJuststring | string | Contingency justification |
serieint | int | CT-e series (3 digits of the access key). Optional — auto-allocated (the company's CT-e series) when omitted or 0; respected when sent |
nCTlong | long | CT-e number (part of the access key). Optional — auto-incremented by the server when omitted or 0; respected when sent (useful for skipping numbering, e.g.: after a duplicate) |
emit*object | object | Issuer data (carrier) |
CNPJ*string | string | Issuer's CNPJ (14 digits) |
CPFstring | string | Issuance with a CPF is not supported: requests without CNPJ are rejected |
IEstring | string | State Registration |
IESTstring | string | State Registration of the tax substitute |
xNome*string | string | Company name |
xFantstring | string | Trade name |
CRTint | int | Tax Regime Code: 1=Simples Nacional, 2=SN exceeding sublimit, 3=Normal Regime, 4=MEI.Default: 3 |
enderEmitobject | object | Address: { xLgr, nro, xCpl, xBairro, cMun, xMun, CEP, UF, fone } |
rem*object | object | Cargo sender |
CNPJ/CPFstring | string | Sender's document (one of the two) |
IEstring | string | State Registration (or "ISENTO") |
xNomestring | string | Company name/name |
xFant,fone,emailstring | string | Trade name, phone, e-mail |
enderRemeobject | object | Sender's address (structure below) |
locColetaarray | array | Pickup locations (optional): [{ CNPJ|CPF, xNome, xLgr, nro, xBairro, cMun, xMun, UF }].The CT-e 4.00 layout does not include this group; sending it has no effect |
dest*object | object | Cargo recipient |
CNPJ/CPFstring | string | Recipient's document (one of the two) |
IEstring | string | State Registration (or "ISENTO") |
xNomestring | string | Company name/name |
fone,email,ISUFstring | string | Phone, e-mail, SUFRAMA Registration |
enderDestobject | object | Recipient's address (structure below) |
locEntobject | object | Delivery location (optional): { CNPJ|CPF, xNome, xLgr, nro, xBairro, cMun, xMun, UF }.The CT-e 4.00 layout does not include this group; sending it has no effect |
vPrest*object | object | Service provision values |
vTPrest*decimal | decimal | Total value of the service provision (> 0) |
vRecdecimal | decimal | Amount receivable |
Comparray | array | Value components: [{ xNome, vComp }] — e.g.: "FRETE PESO", "PEDÁGIO", "GRIS" |
imp*object | object | Taxes (ICMS + tributes) |
ICMS*object | object | ICMS taxation — fill in only one of the variants (see below) |
ICMS00Normal taxation | Normal taxation | { vBC, pICMS, vICMS } (CST 00) |
ICMS20With reduction of calculation base | With reduction of calculation base | { pRedBC, vBC, pICMS, vICMS } (CST 20) |
ICMS45Exempt / non-taxed / deferred | Exempt / non-taxed / deferred | { CST } — "40"=Exempt, "41"=Non-taxed, "51"=Deferred |
ICMS60ICMS charged by tax substitution | ICMS charged by tax substitution | { vBCSTRet, vICMSSTRet, pICMSSTRet, vCred } (CST 60) |
ICMS90Others (special regime) | Others (special regime) | { pRedBC, vBC, pICMS, vICMS, vCred } (CST 90) |
ICMSOutraUFICMS due to another UF | ICMS due to another UF | { pRedBCOutraUF, vBCOutraUF, pICMSOutraUF, vICMSOutraUF } |
ICMSSNSimples Nacional issuer | Simples Nacional issuer | { CST: "90", indSN: 1 } |
vTotTribdecimal | decimal | Approximate total value of tributes |
infAdFiscostring | string | Additional information of interest to the tax authority |
ICMSUFFimobject | object | DIFAL (interstate sharing, optional): { vBCUFFim, pFCPUFFim, pICMSUFFim, pICMSInter, vFCPUFFim, vICMSUFFim, vICMSUFIni }.Written to the CT-e when sent; all seven fields are required |
infTribFedobject | object | Federal tributes (optional): { vPIS, vCOFINS, vIR, vINSS, vCSLL }.In the CT-e 4.00 layout this group exists only in the CT-e OS; sending it to this endpoint has no effect |
infCTeNorm*object | object | Normal CT-e body — required when tpCTe=0 (Normal) or 3 (Replacement) |
infCarga*object | object | Cargo information (table below) |
proPred*string | string | Predominant product |
vCargadecimal | decimal | Total cargo value |
xOutCatstring | string | Other cargo characteristics (e.g.: FRIA, GRANEL, REFRIGERADA) |
vCargaAverbdecimal | decimal | Cargo value for endorsement purposes. Written to the CT-e when sent |
infQ[]*array | array | Quantities — minimum 1: [{ cUnid, tpMed, qCarga }] |
cUnidstring | string | Unit: "00"=M³, "01"=KG, "02"=TON, "03"=UNIT, "04"=LITERS, "05"=MMBTU |
tpMedstring | string | Measurement type (e.g.: "PESO BRUTO", "PESO DECLARADO") |
qCargadecimal | decimal | Quantity |
infDocobject | object | Transported documents (table below) |
infNFearray | array | NF-es by access key: [{ chave, PIN, dPrev, infUnidCarga[], infUnidTransp[] }] — chave with 44 digits.infUnidCarga[]{ tpUnidCarga, idUnidCarga, lacUnidCarga[]{ nLacre }, qtdRat } and infUnidTransp[]{ tpUnidTransp, idUnidTransp, lacUnidTransp[]{ nLacre }, infUnidCarga[], qtdRat } are mutually exclusive |
infNFarray | array | Paper invoices (legacy): [{ nRoma, nPed, mod, serie, nDoc, dEmi, vBC, vICMS, vBCST, vST, vProd, vNF, nCFOP, nPeso, PIN, dPrev, infUnidCarga[], infUnidTransp[] }] — mod: "01" or "04" ("01" when omitted) |
infOutrosarray | array | Other documents: [{ tpDoc, descOutros, nDoc, dEmi, vDocFisc, dPrev, infUnidCarga[], infUnidTransp[] }] — tpDoc: "00"=Declaration, "10"=Pipeline, "59"=CF-e SAT, "65"=NFC-e, "99"=Others |
infModal*object | object | Mode information (table below) |
01Roadrodo | rodo | { RNTRC* } — RNTRC with 8 digits or "ISENTO".occ[] (pickup orders) is currently not written to the CT-e; sending it has no effect |
02Airaereo | aereo | { nMinu, nOCA, dPrevAereo*, natCarga{ xDime }, tarifa*{ CL*, cTar, vTar }, peri[]{ nONU, qTotEmb, qTotProd, uniAP } } — dPrevAereo AAAA-MM-DD; tarifa.CL: M=Minimum, G=General, E=Specific; uniAP: 1=kg, 2=kg G, 3=litre, 4=TI, 5=units.natCarga.cInfManu[] is currently not written to the CT-e; sending it has no effect |
03Waterwayaquav | aquav | { vPrest, vAFRMM, xNavio, nViag, direc, irin, tpNav, balsa[]{ xBalsa }, detCont[]{ nCont, lacre[]{ nLacre }, infDoc[]{ infNF{ serie, nDoc, unidRat } | infNFe{ chave, unidRat } } } } — direc: N/L/S/O; tpNav: 0=Interior, 1=Coastal.The infDoc entries of the same container are written as a single group and must be either all infNF or all infNFe. tpNav is ignored and not written to the XML (the element is optional; writing it would break the element order required by the specification) |
04Railferrov | ferrov | { tpTraf, respFat, ferrEmi, vFrete, chCTeFerroOrigem, ferroEnv[] } — tpTraf: 0=Own, 1=Mutual, 2=Road-rail, 3=Road.The rail mode is not supported yet; the API returns an error before a number is allocated |
05Pipelineduto | duto | { vTar, dIni, dFim } — dates AAAA-MM-DD |
06Multimodalmultimodal | multimodal | { COTM, indNegociavel, seg[]{ infSeg{ xSeg, CNPJ }, nApol, nAver } } — indNegociavel: 0=No, 1=Yes.The layout allows a single seg group; only the first one is written |
docAntobject | object | Previous documents (subcontracting/reshipment): { emiDocAnt[]{ CNPJ|CPF, IE, UF, xNome, idDocAnt[]{ idDocAntPap[]{ tpDoc, serie, subser, nDoc, dEmi } | idDocAntEle[]{ chCTe } } } }.Written to the CT-e when sent; IE, UF and at least 1 idDocAnt are required in each emiDocAnt |
segarray | array | Cargo insurance: [{ respSeg, xSeg, CNPJ, nApol, nAver, vCarga }] — respSeg: 1=Sender…6=Service taker.The infCTeNorm group of the CT-e 4.00 layout does not include this group (insurance information exists only in the multimodal group multimodal.seg); sending it has no effect |
cobrobject | object | Billing/invoices: { fat{ nFat, vOrig, vDesc, vLiq }, dup[]{ nDup, dVenc, vDup } }.Written to the CT-e when sent |
veicNovosarray | array | New vehicles transported: [{ chassi, cCor, xCor, cMod, vUnit, vFrete }].Written to the CT-e when sent |
infCteSubobject | object | Replacement — required when tpCTe=3: { chCte, indAlteraToma }.chCte is the access key of the replaced CT-e; indAlteraToma="1" indicates a change of the service taker (the field name indAltToma is also accepted). refNF, tomaICMS and tomaNaoICMS were abolished in the CT-e 4.00 layout; sending them has no effect |
infGlobalizadoobject | object | Consolidated CT-e information: { xObs } (15 to 256 characters).Written to the CT-e when sent |
infServVincobject | object | Services linked to a multimodal CT-e: { infCTeMultimodal[]{ chCTeMultimodal } }.Written to the CT-e when sent |
expedobject | object | Dispatcher (optional) |
recebobject | object | Receiver (optional) |
complobject | object | Complementary data (observations, flow, delivery) |
xCaracAd,xCaracSer,xEmistring | string | Additional characteristic of the transport / of the service / issuer name |
origCalc,destCalcstring | string | Origin / destination municipality for freight calculation |
xObsstring | string | General observations |
ObsCont/ObsFiscoarray | array | Free observations of the taxpayer / tax authority: [{ xCampo, xTexto }], up to 10 entries each.Written to the CT-e when sent |
fluxo,Entregaobject | object | Cargo flow fluxo{ xOrig, pass[]{ xPass }, xDest, xRota } and delivery forecast Entrega.Entrega must contain both a date group (semData{ tpPer }, comData{ tpPer, dProg } or noPeriodo{ dIni, dFim }) and a time group (semHora{ tpHor }, comHora{ tpHor, hProg } or noInter{ hIni, hFim }). Written to the CT-e when sent |
infCteCompobject | object | Key of the supplemented CT-e — required when tpCTe=1 (Supplement): { chCTe }.Written to the CT-e in infCteComp; a Supplement CT-e does not include infCTeNorm |
autXMLarray | array | CNPJs/CPFs authorized to access the XML: [{ CNPJ } | { CPF }] |
infRespTecobject | object | Technical contact — filled in automatically by the server per UF |
Filled in automatically by the server — you do not need to send them: mod (fixed at 57), cCT (8-digit numeric code), cDV (check digit), cUF (derived from the issuer's UF), dhEmi (current date/time), tpEmis (default 1=Normal), procEmi and verProc.
exped / receb — Dispatcher / Receiver (optional)
CNPJ/CPFstring | string | Document (one of the two) |
IE,xNome,fone,emailstring | string | State Registration, name, phone, e-mail |
enderExped/enderRecebobject | object | Address (same generic structure below) |
Addressobject | object | enderEmit / enderReme / enderExped / enderReceb / enderDest |
xLgrstring | string | Street |
nrostring | string | Number |
xCplstring | string | Complement |
xBairrostring | string | Neighborhood |
cMunstring | string | IBGE municipality code (7 digits) |
xMunstring | string | Municipality name |
CEPstring | string | Postal code (8 digits, digits only) |
UFstring | string | State abbreviation (2 letters) |
cPaisstring | string | Country code (optional; left out of the CT-e when not sent) |
xPaisstring | string | Country name (optional) |
fonestring | string | Phone (only in enderEmit) |
The versaoModal of infModal is always set to "4.00" by the server; values sent are ignored.
* Required field. At least one of CNPJ or CPF is required in the group.
Examples
# sign = md5(token + path + body + timestamp) # Template generated from the endpoint path; replace the placeholders curl -X POST "https://api.tffiscal.com/api/cte/create" \ -H "Content-Type: application/json" \ -H "token: $TOKEN" \ -H "timestamp: $TIMESTAMP" \ -H "sign: $SIGN" \ -d @body.json
{
"ide": {
"CFOP": 5353,
"natOp": "PRESTACAO DE SERVICO DE TRANSPORTE",
"tpAmb": 2,
"tpCTe": 0,
"modal": "01",
"tpServ": 0,
"cMunEnv": 3550308,
"xMunEnv": "SAO PAULO",
"UFEnv": "SP",
"cMunIni": 3550308,
"xMunIni": "SAO PAULO",
"UFIni": "SP",
"cMunFim": 3304557,
"xMunFim": "RIO DE JANEIRO",
"UFFim": "RJ",
"retira": 1,
"indIEToma": 9,
"toma": 0
},
"emit": {
"CNPJ": "26638419000167",
"IE": "141507411110",
"CRT": 1,
"xNome": "TF COMERCIO DE PRESENTES LTDA",
"enderEmit": {
"xLgr": "RUA QUINTANA",
"nro": "34",
"xBairro": "CIDADE MONCOES",
"cMun": "3550308",
"xMun": "SAO PAULO",
"CEP": "04571010",
"UF": "SP",
"fone": "1133334444"
}
},
"rem": {
"CNPJ": "11111111000111",
"IE": "ISENTO",
"xNome": "EMPRESA REMETENTE LTDA",
"fone": "1122223333",
"enderReme": {
"xLgr": "AV PAULISTA",
"nro": "1500",
"xBairro": "BELA VISTA",
"cMun": "3550308",
"xMun": "SAO PAULO",
"CEP": "01310200",
"UF": "SP"
}
},
"dest": {
"CNPJ": "22222222000122",
"IE": "ISENTO",
"xNome": "EMPRESA DESTINATARIA LTDA",
"fone": "2133334444",
"enderDest": {
"xLgr": "AV RIO BRANCO",
"nro": "100",
"xBairro": "CENTRO",
"cMun": "3304557",
"xMun": "RIO DE JANEIRO",
"CEP": "20040002",
"UF": "RJ"
}
},
"vPrest": {
"vTPrest": 1500.00,
"vRec": 1500.00,
"Comp": [
{ "xNome": "FRETE PESO", "vComp": 1500.00 }
]
},
"imp": {
"ICMS": {
"ICMSSN": { "CST": "90", "indSN": 1 }
},
"vTotTrib": 0
},
"infCTeNorm": {
"infCarga": {
"vCarga": 10000.00,
"proPred": "PRODUTOS DIVERSOS",
"infQ": [
{ "cUnid": "01", "tpMed": "PESO BRUTO", "qCarga": 1000.0000 }
]
},
"infDoc": {
"infNFe": [
{ "chave": "35260526638419000167550030000006561341688760" }
]
},
"infModal": {
"versaoModal": "4.00",
"rodo": {
"RNTRC": "12345678"
}
}
}
}
{
"success": true,
"message": "Autorizado o uso do CT-e",
"cStat": "100",
"chCTe": "35260626638419000167570010000000011123456780",
"nProt": "135260000123456",
"xml": "https://storage.../cte/35260626638419000167570010000000011123456780.xml",
"dacte": "https://storage.../cte/35260626638419000167570010000000011123456780.pdf"
}
{
"success": false,
"message": "Rejeicao: ...",
"cStat": "539",
"chCTe": "",
"nProt": "",
"xml": "",
"code": "TAX_AUTHORITY_REJECTED"
}