TF Fiscal

DC-e Content Declaration

POST/api/dce/create

Issue 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

tokenstringstringToken of the issuing company
signstringstringMD5 signature: MD5(token + path + body + timestamp)
timestampstringstringUnix timestamp in seconds (5-minute window)

Body — root

ide*objectobjectDC-e identification
emit*objectobjectIssuer/sender data (CNPJ; or CPF via Marketplace — see below)
dest*objectobjectRecipient data
det*arrayarrayDeclared items/goods — minimum 1
total*objectobjectDeclaration totalizer
transpobjectobjectTransport data
marketplaceobjectobjectMarketplace data (only when ide.tpEmit=1)
fiscoobjectobjectTax authority body data (only when ide.tpEmit=0)
autXMLarrayarrayCNPJs/CPFs authorized to access the XML
infAdicobjectobjectAdditional information
Required fields in the request: 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.

Individual sender (CPF): by the tax authority rules, a CPF cannot be its own issuer (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*stringstringStreet
nro*stringstringNumber
xCplstringstringComplement
xBairro*stringstringNeighborhood
cMun*longlongIBGE municipality code (7 digits)
xMun*stringstringMunicipality name
CEP*stringstringPostal code (8 digits).
UF*stringstringState abbreviation (2 letters)
cPaisintintCountry code.
xPaisstringstringCountry name.
fonestringstringPhone
emailstringstringE-mail

 * 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