TF Fiscal

NF3-e Electricity

POST/api/nf3e/create

Issue NF3e

Issues an NF3e from the submitted body. The client sends only the business data — the issuer block (emit) is built automatically from the registration of the token's company, and the technical access-key fields are calculated by the server. Credit is debited only in production (tpAmb=1) and when the NF3e is authorized. After authorization, the XML (nf3eProc) and the DANF3E (PDF) are generated and made available by URL.

Required headers

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

Body — root

ideobjectobjectNF3e identification (environment, taxable event period)
dest*objectobjectRecipient / consumer data
acessante*objectobjectConsumer unit data.
det*arrayarrayBilled items — at least 1
totalobjectobjectTotals.
gFat*objectobjectInvoice data (billing period, due date, next reading, barcode, debit method)
gANEEL*arrayarrayBilling history (1 to 5 quantities, exactly 13 periods each)
infAdFiscostringstringInformation of interest to the tax authority
infCplarrayarrayComplementary information (list of texts)
autXMLarrayarrayCNPJs/CPFs authorized to access the XML (list of strings)
Required fields in the request: dest with xNome, one of CNPJ/CPF/idOutros and enderDest (xLgr, xBairro, cMun, xMun, CEP with 8 digits, UF); and at least 1 item in det with xProd, cClass (7 digits from the NF3e item classification table), vItem and vProd; acessante.latGPS and acessante.longGPS; in gFat, CompetFat, dVencFat, dProxLeitura, codBarras, and either codDebAuto or codBanco+codAgencia; and gANEEL. Only the issuer holds the actual values of these fields, so an error is returned when they are missing; the server no longer fills in default values. All other fields are optional.

Filled in automatically by the server — you do not need to send them: mod (fixed at 66), cUF (derived from the company registration), cNF (7-digit numeric code), cDV (access key check digit), tpEmis (normal) and verProc. The complete emit block and the infNF3eSupl (QR code) are also built by the server.

det[].pis / det[].cofins

cststringstringPIS/COFINS CST.
vBCstringstringCalculation base
pAliqstringstringRate (%)
valorstringstringTax value

The vPIS and vCOFINS totals are summed from the items' pis.valor and cofins.valor, and vICMSDeson is summed from the items' ICMS groups, all calculated by the server; the other totals (vPISEfet, vCOFINSEfet, the withholding totals, etc.) are 0.00.

The billing history must be filled in with the actual data of the consumer unit; an error is returned when gANEEL is omitted, and the server no longer generates history data.

 * Required field. In the recipient, at least one of CNPJ, CPF or idOutros is required. Monetary values and rates are sent as strings with a decimal point (e.g.: "75.00").

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 NF3e 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/nf3e/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/nf3e/create" \
  -H "Content-Type: application/json" \
  -H "token: $TOKEN" \
  -H "timestamp: $TIMESTAMP" \
  -H "sign: $SIGN" \
  -d @body.json