TF Fiscal

NF-e Tax Codes

POST/api/category/create

Create tax category

Creates a new tax category (tax template) bound to the authenticated company. Each category aggregates scenarios of ICMS, IPI, PIS, COFINS, and optionally IBS/CBS and IS. To edit an existing one, use /api/category/edit.

Required headers

tokenstringstringCompany token
signstringstringMD5 signature
timestampstringstringUnix timestamp in seconds

Body — top-level

descricao*stringstringCategory description (the key is required; an empty value is accepted and saved)
category_idstringstringCustom ID.
disable_difalbooleanbooleanZeroes the DIFAL for this category: the ICMSUFDest group is still issued, but with the internal rate equal to the interstate rate (difference 0).
desconta_icms_pis_cofinsbooleanbooleanWhen true, the line's ICMS is deducted from the PIS/COFINS base and, in interstate sales to non-taxpayer final consumers, so is the destination-state DIFAL; the base becomes (base − ICMS − DIFAL), with a minimum of 0; applies only to percentage-based PIS/COFINS.
desconta_icms_pis_cofins_ibs_cbsbooleanbooleanComputes the IBS/CBS base with the official RFB formula (unified base of the regular-regime calculator): item value (product + freight + insurance + other − discount) + II − ICMS − FCP − single-phase ICMS − DIFAL and destination-state FCP − ISSQN − PIS − COFINS, floor 0 (PIS and COFINS are only deducted in 2026); if desconta_icms_pis_cofins is also true, the already-reduced PIS/COFINS is used; default false
icms[]*arrayarrayICMS scenarios (structure below)
ipi[]*arrayarrayIPI scenarios (structure below)
pis[]*arrayarrayPIS scenarios (structure below)
cofins[]*arrayarrayCOFINS scenarios (structure below)
ibs_cbs[]arrayarrayIBS/CBS scenarios — tax reform (structure below)
is[]arrayarrayIS scenarios — Selective Tax (structure below).

Body — pis[] and cofins[] (same structure)

cenario*stringstringScenario (the same as ICMS, or "padrao")
tipo_pessoa*stringstring"fisica" or "juridica"
situacao_tributaria*stringstringPIS/COFINS CST
aliquota*stringstringRate
valor_unidadestringstringPIS/COFINS by quantity — value in BRL/unit; v = quantity × value (CST 03 and other per-quantity forms)

 * Required field.

How the category is applied at issuance

  • For each item, issuance looks for the row whose tipo_pessoa matches the recipient and whose cenario matches the operation: saida_dentro_estado / saida_fora_estado (outbound invoice) or entrada_dentro_estado / entrada_fora_estado (inbound invoice and /api/invoice/return). The comparison is exact (lowercase).
  • ICMS: requires the row for the exact scenario — there is no fallback to "padrao". Register at least saida_dentro_estado and saida_fora_estado for each tipo_pessoa you serve.
  • IPI, PIS, COFINS, IBS/CBS and IS: without the exact row, they use the "padrao" row of the same tipo_pessoa.
  • Incoming invoice with no entrada_* row: ICMS uses the matching saida_* row; IPI, PIS, COFINS, IBS/CBS and IS try "padrao" first and only then saida_* (compatibility with older categories).
  • Export (transaction_type="3"): the normal rule applies first (tipo_pessoa + scenario; IPI, PIS, COFINS, IBS/CBS and IS also try "padrao"). Only if nothing matches does ICMS use the first row of the same scenario for any tipo_pessoa (or, if none, the first row), and the other taxes use the first row of the list.
  • Import (transaction_type="2"): ignores cenario and tipo_pessoa — ICMS uses the first row whose CFOP starts with 3 (or, if none, the first row) and the other taxes use the first row.
  • In /api/invoice/return the CFOP is required in the request (field cfop) and replaces the category's codigo_cfop.
  • With no applicable ibs_cbs row, the invoice is issued without the IBS/CBS group (the 0.10/0/0.90 defaults only apply when the row exists).

Examples

# sign = md5(token + path + body + timestamp)
# Template generated from the endpoint path; replace the placeholders
curl -X POST "https://api.tffiscal.com/api/category/create" \
  -H "Content-Type: application/json" \
  -H "token: $TOKEN" \
  -H "timestamp: $TIMESTAMP" \
  -H "sign: $SIGN" \
  -d @body.json