/api/dce/createIssue DC-e
Issues a DC-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 DC-e is authorized.
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) |
Body — root
ide*object | object | DC-e identification |
tpAmb*int | int | Environment: 1=production, 2=staging.The only truly required field of ide. |
tpEmitint | int | Issuer type: 0=Tax Authority Application, 1=Marketplace, 2=Own issuer.Optional — default: 2 |
cUFint | int | IBGE code of the issuer's UF (2 digits). Optional — derived from emit.enderEmit.UF when omitted. If sent, it must be consistent with that UF (tax authority rejects with cStat=220 in case of divergence) |
serieint | int | Fiscal document series (3 digits of the access key) — identifies the DC-e numbering set. Optional — default: DC-e series registered for the company |
nDClong | long | Sequential DC-e number (part of the access key). Optional — auto-incremented by the server when omitted or 0 |
nSiteAutorizint | int | Identification of the authorizer site that processed the DC-e (1 digit of the access key). Usually 0 (primary site). Optional — default: 0 |
tpEmisint | int | Issuance method: 1=Normal, 9=Contingency.Optional — default: 1 |
emit*object | object | Issuer/sender data (CNPJ; or CPF via Marketplace — see below) |
CNPJstring | string | Issuer's CNPJ (14 digits). Provide either this field or CPF, not both |
CPFstring | string | CPF of the individual sender (11 digits). Only allowed for issuance via Marketplace — see note below |
xNome*string | string | Issuer's/sender's name or company name |
enderEmit*object | object | Issuer's address (see structure below) |
dest*object | object | Recipient data |
CNPJstring | string | Recipient's CNPJ (14 digits) |
CPFstring | string | Recipient's CPF (11 digits) |
xNome*string | string | Recipient's name or company name. In the test environment ( tpAmb=2), the server replaces it with DCE EMITIDA EM AMBIENTE DE HOMOLOGACAO |
enderDest*object | object | Recipient's address (see structure below) |
det*array | array | Declared items/goods — minimum 1 |
nItemint | int | Sequential item number, starting at 1.Optional — when omitted or 0, items are numbered by their position in the array (the first item is 1) |
xProd*string | string | Description of the declared good/merchandise |
NCM*string | string | NCM code (2 or 8 digits) |
qCom*decimal | decimal | Quantity (> 0) |
vUnComdecimal | decimal | Unit value |
vProd*decimal | decimal | Total item value (> 0) |
infAdProdstring | string | Additional item information |
total*object | object | Declaration totalizer |
vDC*decimal | decimal | Total declared value (> 0) |
transpobject | object | Transport data |
modTransint | int | Transport mode: 0=Postal service, 1=own, 2=carrier.Default: 2 |
CNPJTranspstring | string | Carrier's CNPJ |
marketplaceobject | object | Marketplace data (only when ide.tpEmit=1) |
CNPJstring | string | Marketplace's CNPJ |
xNomestring | string | Marketplace name |
Sitestring | string | Marketplace website |
fiscoobject | object | Tax authority body data (only when ide.tpEmit=0) |
CNPJstring | string | Body's CNPJ |
xOrgaostring | string | Body name |
UFstring | string | Body's UF |
autXMLarray | array | CNPJs/CPFs authorized to access the XML |
CNPJstring | string | CNPJ authorized to consult/download the XML |
CPFstring | string | CPF authorized to consult/download the XML |
infAdicobject | object | Additional information |
infAdFiscostring | string | Information of interest to the tax authority |
infCplstring | string | Supplementary information of interest to the taxpayer |
infAdMarketPlacestring | string | Additional marketplace information |
ide.tpAmb; emit.CNPJ (14 digits) or emit.CPF (11 digits, individual sender via Marketplace — see the note under emit), emit.xNome and emit.enderEmit (xLgr, nro, xBairro, cMun, xMun, CEP with 8 digits, UF); dest with CNPJ or CPF, dest.xNome and dest.enderDest (same address fields); at least 1 item in det with xProd, NCM (2 or 8 digits), qCom > 0 and vProd > 0; and total.vDC > 0. All other fields are optional.
Filled in automatically by the server — you do not need to send them: mod (fixed at 99) and cDV (key check digit) are always set by the server; cDC (6-digit numeric code), dhEmi (issuance date/time) and verProc (process version) are generated when omitted. The serie, nDC and cUF fields in the table above are also filled in automatically when omitted.
tpEmit=2 requires a CNPJ). To issue with a CPF as the sender, just send emit.CPF (without emit.CNPJ): the server automatically sets tpEmit=1 (Marketplace), uses your company's CNPJ (from the token) as the authorized issuer in the access key, and fills the marketplace block with the company's data. The CPF you provide appears as the sender in emit.
enderEmit / enderDest — Address
xLgr*string | string | Street |
nro*string | string | Number |
xCplstring | string | Complement |
xBairro*string | string | Neighborhood |
cMun*long | long | IBGE municipality code (7 digits) |
xMun*string | string | Municipality name |
CEP*string | string | Postal code (8 digits). May contain a hyphen or dots, which the server removes before writing the XML |
UF*string | string | State abbreviation (2 letters) |
cPaisint | int | Country code. Default: 1058 (Brazil) |
xPaisstring | string | Country name. Default: BRASIL |
fonestring | string | Phone |
emailstring | string |
* Required field. In the issuer and in the recipient, at least one of CNPJ or CPF is required.
Response when the result is not confirmed
When the request was sent to the tax authority but no definitive answer was obtained (for example, a connection timeout or an HTTP error returned by the tax authority), the DC-e may already have been authorized. In this case the response returns success=false together with the chave, serie and number of this attempt; that number is not assigned to any other document. The status must first be confirmed by calling /api/dce/consult with the chave, before deciding whether to issue the document again.
Examples
# sign = md5(token + path + body + timestamp) # Template generated from the endpoint path; replace the placeholders curl -X POST "https://api.tffiscal.com/api/dce/create" \ -H "Content-Type: application/json" \ -H "token: $TOKEN" \ -H "timestamp: $TIMESTAMP" \ -H "sign: $SIGN" \ -d @body.json
{
"ide": {
"tpAmb": 2,
"tpEmit": 2
},
"emit": {
"CNPJ": "12345678000199",
"xNome": "EMPRESA EXEMPLO LTDA",
"enderEmit": {
"xLgr": "RUA EXEMPLO",
"nro": "100",
"xBairro": "CENTRO",
"cMun": 4106902,
"xMun": "CURITIBA",
"CEP": "80010000",
"UF": "PR"
}
},
"dest": {
"CPF": "12345678909",
"xNome": "JOAO DA SILVA",
"enderDest": {
"xLgr": "AVENIDA DESTINO",
"nro": "500",
"xBairro": "JARDIM",
"cMun": 4113700,
"xMun": "LONDRINA",
"CEP": "86010000",
"UF": "PR"
}
},
"det": [
{
"nItem": 1,
"xProd": "LIVROS DIVERSOS",
"NCM": "49019900",
"qCom": 3,
"vUnCom": 50.00,
"vProd": 150.00
}
],
"total": {
"vDC": 150.00
}
}
{
"ide": {
"tpAmb": 2,
"tpEmit": 2,
"cUF": 41,
"serie": 1,
"nSiteAutoriz": 0
},
"emit": {
"CNPJ": "12345678000199",
"xNome": "EMPRESA EXEMPLO LTDA",
"enderEmit": {
"xLgr": "RUA EXEMPLO",
"nro": "100",
"xCpl": "SALA 2",
"xBairro": "CENTRO",
"cMun": 4106902,
"xMun": "CURITIBA",
"CEP": "80010000",
"UF": "PR",
"cPais": 1058,
"xPais": "BRASIL",
"fone": "4133334444",
"email": "contato@exemplo.com"
}
},
"dest": {
"CNPJ": "98765432000188",
"xNome": "DESTINATARIO EXEMPLO LTDA",
"enderDest": {
"xLgr": "AVENIDA DESTINO",
"nro": "500",
"xCpl": "GALPAO 3",
"xBairro": "JARDIM",
"cMun": 4113700,
"xMun": "LONDRINA",
"CEP": "86010000",
"UF": "PR",
"cPais": 1058,
"xPais": "BRASIL",
"fone": "4333335555",
"email": "destino@exemplo.com"
}
},
"autXML": [
{ "CNPJ": "11222333000144" },
{ "CPF": "98765432100" }
],
"det": [
{
"nItem": 1,
"xProd": "LIVROS DIVERSOS",
"NCM": "49019900",
"qCom": 3,
"vUnCom": 50.00,
"vProd": 150.00,
"infAdProd": "Caixa 1 de 2"
},
{
"nItem": 2,
"xProd": "MATERIAL DE ESCRITORIO",
"NCM": "48201000",
"qCom": 10,
"vUnCom": 8.00,
"vProd": 80.00,
"infAdProd": "Caixa 2 de 2"
}
],
"total": {
"vDC": 230.00
},
"transp": {
"modTrans": 2,
"CNPJTransp": "55666777000188"
},
"infAdic": {
"infAdFisco": "Operacao nao sujeita a emissao de nota fiscal",
"infCpl": "Remessa de bens entre filiais"
}
}
{
"success": true,
"message": "DC-e autorizada",
"chave": "41250612345678000199990010000000011201234564",
"serie": 1,
"number": 1,
"cStat": "100",
"xMotivo": "Autorizado o uso do DC-e",
"nProt": "141250000123456",
"xml": "https://storage.../dce/41250612345678000199990010000000011201234564.xml",
"dace": "https://storage.../dce/41250612345678000199990010000000011201234564.pdf"
}
{
"success": false,
"message": "DC-e rejeitada: Rejeicao: ...",
"chave": "41250612345678000199990010000000011201234564",
"serie": 1,
"number": 1,
"cStat": "225",
"xMotivo": "Rejeicao: Falha no Schema XML",
"nProt": "",
"xml": "",
"dace": "",
"code": "TAX_AUTHORITY_REJECTED"
}