TF Fiscal

NF-e Invoices

POST/api/invoice/create

Issue a new invoice

Issues an NF-e (model 55). The issuing company is identified by the token header; do not send company_id in the body.

Required headers

tokenstringstringIssuing company token
signstringstringMD5 signature: MD5(token + path + body + timestamp)
timestampstringstringUnix timestamp in seconds (5-minute window)

Body — top-level fields

Identification and operation
idstringstringOrder ID in your system.
nature_of_operation*stringstringOperation nature (e.g., "Sale of goods")
transaction_type*stringstringType: "0"=inbound, "1"=outbound, "2"=import, "3"=export
model*stringstringDocument model: "55"=NF-e
issuance_type*stringstringIssuance type — use "1" (normal).
ambiente*stringstring"1"=production, "2"=homologation.
finalidadestringstringPurpose: "1"=normal (default), "2"=complementary, "3"=adjustment, "4"=return.
ref_nfe_chavestringstring44-digit access key of the referenced NF-e (complementary/adjustment/return).
is_reopenbooleanbooleanSkips the deduplication by id and issues a new NF-e (new number), even if an invoice already exists for that order.
dh_sai_entstringstringExit or entry datetime (ISO 8601).
ieststringstringIEST for this invoice (emit/IEST), up to 14 digits; overrides the IEST stored on the company. Omitted: the company's IEST for the destination state is used, only when the destination is another state and the invoice has ICMS-ST withheld
Amounts and discounts
total_discount_amountdecimaldecimalTotal invoice discount.
price_includes_ipibooleanbooleanWhether unit prices already include IPI.
trocodecimaldecimalChange amount (typical for NFC-e)
segurodecimaldecimalInsurance amount (goes to the items' vSeg) — split in proportion to each item's quantity (not its value) and rounded per item; the sum may differ from the amount sent by a few cents
outras_despesasdecimaldecimalOther expenses (go to the items' vOutro) — split in proportion to each item's quantity (not its value) and rounded per item; the sum may differ from the amount sent by a few cents
Indicators and additional info
ind_finalstringstringEnd consumer: "0"=no (B2B), "1"=yes (B2C).
ind_presstringstringPresence indicator: "0"=not applicable, "1"=in-person, "2"=internet, "3"=tele-service, "4"=home delivery, "5"=in-person off-premises, "9"=other.
informacoes_complementaresstringstringComplementary info — appended to infAdic.infCpl after the automatic text (approximate taxes, DIFAL), separated by " | "
informacoes_fiscostringstringInformation for the tax authority (written to infAdic.infAdFisco)
clienteobjectobjectobject, required
products[]arrayarrayarray, at least 1 item

Interstate: how to set the DIFAL base

This section applies only to interstate sales to non-taxpayer recipients (indIEDest=9: individuals or a CNPJ without IE). It does not apply to intrastate operations or to taxpayer recipients. Simples Nacional issuers (CRT 1/4) do not generate the ICMSUFDest group, so nothing in this section applies to them.

Step 1 — look up the buyer’s state

Buyer’s stateSend in addition to aliquota, aliquota_fcp
PE, RJnothing else
SEonly difal_base_por_dentro: true
the other 24 states
AC AL AM AP BA CE DF ES GO MA MG MS MT PA PB PI PR RN RO RR RS SC SP TO
difal_desconta_icms_inter: true
difal_base_por_dentro: true

Important: the DIFAL base method directly determines the tax due; choosing the wrong one leads to underpayment (with exposure to assessments and penalties) or overpayment. The table above reflects the prevailing practice per state and is provided for reference only — state legislation changes, and specific goods may follow differentiated rules. Confirm the applicable method for the destination state with your accountant or tax advisor before going live. If unsure, send neither difal_desconta_icms_inter nor difal_base_por_dentro: the base equals the invoice amount, which is the most conservative treatment.

Step 2 — request examples by scenario

Selling to RJ — difal_desconta_icms_inter and difal_base_por_dentro not required (FECP 2%)

{
  "icms": { "codigo_cfop": "6102", "situacao_tributaria": "00",
            "aliquota": "4", "aliquota_fcp": "2" }
}

Selling to AL — difal_desconta_icms_inter and difal_base_por_dentro both set to true (FECP 1%)

{
  "icms": { "codigo_cfop": "6102", "situacao_tributaria": "00",
            "aliquota": "4", "aliquota_fcp": "1",
            "difal_desconta_icms_inter": true,
            "difal_base_por_dentro": true }
}

If your system already calculates the DIFAL base, send v_bc_uf_dest; difal_desconta_icms_inter and difal_base_por_dentro then no longer apply

{
  "icms": { "aliquota": "4", "aliquota_fcp": "1", "v_bc_uf_dest": "122.29" }
}

What each option produces

How to sendDIFAL baseDIFAL due
neither difal_desconta_icms_inter nor difal_base_por_dentro100.0016.50
both true122.2921.07
v_bc_uf_dest=150150.0026.75

Invoice 100.00, interstate ICMS paid 4.00, destination rate 20.5%, FECP 1%. The 4% interstate rate applies only to imported goods (origem 1, 2, 3 or 8); for domestic goods use 7% or 12%, depending on the states.

Why states differ (background, safe to skip)

ICMS is a tax-inclusive tax. Some states require the DIFAL itself to be added back into its own base (base dupla) after deducting the interstate ICMS already paid (com exclusão); others use the operation amount directly (base única). difal_desconta_icms_inter and difal_base_por_dentro correspond to these two steps. The destination rate itself is maintained by the platform.

Body — shipping_address / delivery_address (objects, optional)

shipping_address is the pickup location (physical origin, if different from the issuer). delivery_address is the delivery location (physical destination, if different from the customer). When present, both require: cpf or cnpj, name, endereco, bairro (min. 2 chars), city, uf, and cep. Both objects share the same structure.
cpfstringstringCPF (alternative to cnpj)
cnpjstringstringCNPJ (alternative to cpf)
iestringstringState Registration
name*stringstringCompany / name
endereco*stringstringStreet address
complementostringstringComplement
numberstringstringNumber (note: the field is number, not numero).
bairro*stringstringNeighborhood
city*stringstringCity
uf*stringstringState
cep*stringstringZIP code
telefonestringstringPhone
emailstringstringEmail
transportationobjectobjectobject, optional
pag_info[]arrayarrayarray, optional

 * Required field.

Examples

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

Fields by scenario

The following sections list, for each field group, the parameters required for each possible value. Each section provides a minimal request fragment containing only that field group, together with the fields required in that case; fields not listed need not be sent. Complete requests are given in "Simplified example" and "Complete example (all fields)" at the end of this page.

Scenario 1: Simples Nacional company selling to an individual (CSOSN 102)

A company under the Simples Nacional regime sells online to an individual consumer; the product taxes are given directly in the product line.

{
  "id": "PED-000014553",
  "nature_of_operation": "Venda de mercadoria",
  "transaction_type": "1",
  "model": "55",
  "issuance_type": "1",
  "ambiente": "2",
  "cliente": {
    "cpf": "88533234775", "name": "Cliente Demo", "email": "cliente.demo@mail.com",
    "endereco": "Rua Presidente Wilson", "numero": "911", "bairro": "Uberaba",
    "city": "Curitiba", "uf": "PR", "cep": "81570440"
  },
  "products": [
    {
      "codigo": "000068", "name": "Pendrive 16GB", "ncm": "85235190",
      "count": 2, "unit": "UN", "unit_price": 28.47, "total_price": 56.94,
      "origem": "0", "indicador_total": "1",
      "impostos": {
        "icms":   { "codigo_cfop": "6102", "situacao_tributaria": "102" },
        "ipi":    { "situacao_tributaria": "53", "codigo_enquadramento": "999" },
        "pis":    { "situacao_tributaria": "49" },
        "cofins": { "situacao_tributaria": "49" }
      }
    }
  ],
  "pag_info": [ { "payment_indicator": "0", "payment_method": "17", "payment_value": 56.94 } ]
}

Scenario 2: Normal-regime company selling to a business (CST 00)

A company under the normal tax regime sells to a business holding a state registration (IE); the product taxes reference a tax category previously saved on the platform (category_id), and the CFOP and tax rates are determined by that tax category.

{
  "id": "PED-000014554",
  "nature_of_operation": "Venda de mercadoria",
  "transaction_type": "1",
  "model": "55",
  "issuance_type": "1",
  "ambiente": "2",
  "ind_final": "0",
  "cliente": {
    "cnpj": "12345678000199", "ie": "123456789", "name": "Empresa Cliente Ltda",
    "endereco": "Rua Exemplo", "numero": "123", "bairro": "Centro",
    "city": "São Paulo", "uf": "SP", "cep": "01234567"
  },
  "products": [
    {
      "codigo": "PROD001", "name": "Smartphone XYZ", "ncm": "85171231",
      "count": 2, "unit": "UN", "unit_price": 1500.00, "total_price": 3000.00,
      "origem": "0", "indicador_total": "1", "category_id": "SEU_CATEGORY_ID"
    }
  ],
  "pag_info": [ { "payment_indicator": "1", "payment_method": "15", "payment_value": 3000.00 } ]
}

Invoice purpose finalidade and referenced invoice ref_nfe_chave 3 blocks

When finalidade is omitted, the invoice is a normal invoice (1). The complementary, adjustment and return purposes each issue a new invoice (new number, new access key) that references the authorized original invoice in ref_nfe_chave (44-digit access key; a single key only). For complementary and return invoices, the API returns an error directly when the reference to the original invoice is missing. Each of these invoices consumes one unit of quota, in the same way as a normal invoice. When only registration data is corrected and no amounts or tax values are affected, a correction letter (CC-e) is used instead of a new invoice.

Complementary invoice (2)

When the original invoice under-declared the price, quantity or tax value, a separate complementary invoice is issued for the difference only. For example, when the original invoice declared ICMS at 12% and the correct rate is 18%, the complementary invoice declares the difference. A complementary invoice normally involves no payment, so pag_info uses 90 (no payment).

"finalidade": "2",
"ref_nfe_chave": "35241022762481000105550030002811221166419985",
"pag_info": [ { "payment_indicator": "0", "payment_method": "90" } ]

Adjustment invoice (3)

Used for tax adjustments provided for in the legislation, such as ICMS assessment adjustments, transfers of credits between branches and inventory adjustments. Whether an adjustment invoice applies should first be confirmed with the accountant.

"finalidade": "3",
"ref_nfe_chave": "35241022762481000105550030002811221166419985"

Return invoice (4)

Returns should preferably be issued through /api/invoice/return: that endpoint automatically sets the inbound direction, the return purpose, no payment (90) and the reference to the original invoice. To issue a return invoice through this endpoint, finalidade must be sent as "4" and transaction_type as "0" (inbound), and the original invoice must be referenced; this endpoint does not adjust the inbound direction automatically. Returned IPI is declared through ipi_devolvido in the product line and takes effect only in return invoices.

"finalidade": "4",
"transaction_type": "0",
"ref_nfe_chave": "35241022762481000105550030002811221166419985",
"pag_info": [ { "payment_indicator": "0", "payment_method": "90" } ]

Final consumer ind_final and buyer presence ind_pres

When ind_final is omitted, the sale is treated as a sale to a final consumer (1); it is declared as a business-to-business transaction only when "0" is sent. "0" must be sent for sales to businesses that purchase for resale or production. When ind_pres is omitted, the sale is an internet sale (2); a value not listed in the table below leaves the default value unchanged.

"ind_final": "0",
"ind_pres": "1"
ind_presDescription
0Not applicable (for example, complementary or adjustment invoices)
1In-person transaction
2Internet (default)
3Telephone
4NFC-e with home delivery
5In-person transaction outside the establishment
9Other non-in-person transaction

Buyer cliente 4 blocks

Domestic transactions (transaction_type 0 or 1) require a document number and a complete address. The state and city codes are taken from the cep lookup result; uf and city are only checked for being non-empty. The key for the street number is numero; when omitted, it is declared as S/N. telefone is not declared when it has fewer than 10 digits. When both cpf and cnpj are sent, the buyer is treated as a CPF holder, and cnpj and ie have no effect.

Individual consumer

cpf is sent. Individuals are always declared as non-taxpayers of ICMS; for interstate sales, the platform calculates DIFAL.

"cliente": {
  "cpf": "88533234775", "name": "Cliente Demo",
  "endereco": "Rua Presidente Wilson", "numero": "911", "bairro": "Uberaba",
  "city": "Curitiba", "uf": "PR", "cep": "81570440"
}

Business buyer, ICMS taxpayer

cnpj and ie (state registration) are sent. A business with a state registration is declared as an ICMS taxpayer, and DIFAL is not calculated for interstate sales.

"cliente": {
  "cnpj": "12345678000199", "ie": "123456789", "name": "Empresa Cliente Ltda",
  "endereco": "Rua Exemplo", "numero": "123", "bairro": "Centro",
  "city": "São Paulo", "uf": "SP", "cep": "01234567"
}

Business buyer without a state registration

Only cnpj is sent. A business without a state registration is declared as a non-taxpayer of ICMS, and for interstate sales DIFAL is calculated in the same way as for individuals. Only the digits of ie are kept; sending "ISENTO" has the same effect as omitting the field.

"cliente": {
  "cnpj": "12345678000199", "name": "Prestadora de Servicos Ltda",
  "endereco": "Av. Brasil", "numero": "500", "bairro": "Centro",
  "city": "Rio de Janeiro", "uf": "RJ", "cep": "20040002"
}
FieldTypeDescription
cpf / cnpj *stringOne of the two is required; punctuation is allowed
iestringState registration; takes effect only together with cnpj
name *stringCharacters beyond the 60th are truncated
endereco *stringStreet
numerostringStreet number; S/N when omitted
bairro *stringNeighborhood, at least 2 characters
city / uf *stringCity and state; the declared values are taken from the cep lookup result
cep *stringZIP code; must be found by the lookup
telefone / email / complementostringOptional

Foreign buyer (export)

When transaction_type is "3" (export) or "2" (import), only name is required, and no ZIP code lookup is performed. c_pais and x_pais must always be sent: when omitted, the country is declared as Brazil and the invoice is rejected.

"transaction_type": "3",
"cliente": {
  "name": "Foreign Buyer Inc.", "id_estrangeiro": "PA1234567",
  "c_pais": "2496", "x_pais": "ESTADOS UNIDOS",
  "endereco": "5th Avenue 100", "city": "New York"
}
FieldTypeDescription
name *stringBuyer name
id_estrangeirostringForeign identification document number (passport or similar)
c_pais *stringCentral Bank of Brazil country code, for example 2496 (United States)
x_pais *stringCountry name
endereco / bairro / citystringDeclared as EXTERIOR when omitted

Pickup address shipping_address and delivery address delivery_address

shipping_address is sent when the goods are dispatched from a location other than the invoice address, and delivery_address is sent when the goods are delivered to a location other than the buyer's address. Both have the same structure and are independent of the transport mode. When provided, cpf or cnpj, name, endereco, bairro, city, uf and cep are all required; the key for the street number is number (unlike cliente.numero); telefone may contain digits only.

"delivery_address": {
  "cnpj": "11222333000181", "name": "Deposito Demo",
  "endereco": "Rua B", "number": "20", "bairro": "Centro",
  "city": "Curitiba", "uf": "PR", "cep": "80010000", "telefone": "41999990000"
}

Product lines products[]

The product amount is calculated as unit_price × count; total_price is recorded only and is not used in the calculation. discount_price is the discount for the line and reduces the tax base of every tax. The invoice-level freight_amount, seguro and outras_despesas are apportioned among the lines in proportion to their quantities. When codigo is omitted, the product name is used instead; when gtin is omitted, it is declared as SEM GTIN.

{
  "codigo": "SKU-001", "name": "Camiseta Algodao", "ncm": "61091000", "cest": "2806300",
  "gtin": "7891234567895", "n_item_ped": "1",
  "count": 3, "unit": "UN", "unit_price": 50.00, "total_price": 150.00, "discount_price": 15.00,
  "origem": "0", "indicador_total": "1", "category_id": "SEU_CATEGORY_ID"
}

Two ways of specifying product taxes 2 blocks

Each product line must use exactly one of two options: a reference to a tax category saved on the platform (category_id), or impostos given directly in the product line. All product lines of the same invoice must use the same option; when the options are mixed, issuance fails for the lines that reference a tax category. When both are sent, category_id prevails, and in impostos only the DIFAL-related fields and ipi_devolvido take effect. The type of ICMS tax code is determined by the company's tax regime: Simples Nacional (CRT 1, 4) accepts only three-digit CSOSN codes, and the normal regime (CRT 2, 3) accepts only two-digit CST codes; when the wrong type is used, the API returns an error.

Tax category reference category_id

Tax categories are configured on the platform separately by buyer type (individual, business) and by scenario (outbound or inbound, intrastate or interstate); the CFOP, CST and tax rates are determined by the matching row. This option is suited to cases in which product taxes are fixed and maintained centrally by the accountant.

{ "name": "Smartphone XYZ", "ncm": "85171231", "count": 1, "unit": "UN",
  "unit_price": 1500.00, "total_price": 1500.00, "origem": "0", "indicador_total": "1",
  "category_id": "SEU_CATEGORY_ID" }

Inline impostos

All four groups icms, ipi, pis and cofins must be provided; when any group is missing, the API returns an error. icms.codigo_cfop is required. ibs_cbs is optional. Rates are sent as percentage strings, for example "18" for 18%. The fields required by each tax code in each group are described in the following sections.

"impostos": {
  "icms":   { "codigo_cfop": "5102", "situacao_tributaria": "00", "aliquota": "18" },
  "ipi":    { "situacao_tributaria": "53", "codigo_enquadramento": "999" },
  "pis":    { "situacao_tributaria": "01", "aliquota": "1.65" },
  "cofins": { "situacao_tributaria": "01", "aliquota": "7.60" }
}

ICMS under the normal regime (CRT 2, 3) 10 blocks

The tax base is the product amount plus the apportioned freight, insurance and other expenses, minus the discount. For sales to a final consumer, IPI is added to the tax base for CST 00, 20, 51 and 90. All fragments below are the content of impostos.icms.

CST 00: fully taxed

aliquota may be omitted: when omitted or 0, the internal rate of the state of origin applies to intrastate sales, and the interstate rate applies to interstate sales (4% for imported goods).

{ "codigo_cfop": "5102", "situacao_tributaria": "00", "aliquota": "18", "aliquota_fcp": "2" }
FieldDescription
aliquotaICMS rate (%); optional
aliquota_fcpFCP rate (%); declared when greater than 0

CST 10: taxed, with ICMS-ST collected for subsequent operations

aliquota_st is required. The ST tax base is (product amount + IPI) × (1 + MVA%), then reduced by aliquota_reducao_st; the amount collected equals the ST tax minus the operation's own ICMS.

{ "codigo_cfop": "5401", "situacao_tributaria": "10", "aliquota": "18",
  "aliquota_st": "18", "aliquota_mva": "40", "aliquota_fcp_st": "2" }
FieldDescription
aliquotaRate of the operation's own ICMS; optional (same rule as CST 00)
aliquota_st *ST rate (%)
aliquota_mvaMVA (%); when omitted, the ST base is calculated on the transaction amount
aliquota_reducao_stST tax base reduction (%)
aliquota_fcp / aliquota_fcp_stFCP and FCP-ST rates (%)

CST 20: reduced tax base

aliquota is required (the default rate is not applied automatically). When there is a reduction, the platform calculates the relieved ICMS amount automatically, and motivo_desoneracao must be provided.

{ "codigo_cfop": "5102", "situacao_tributaria": "20", "aliquota": "18",
  "aliquota_reducao": "33.33", "motivo_desoneracao": "9" }
FieldDescription
aliquota *ICMS rate (%)
aliquota_reducao *Tax base reduction (%)
motivo_desoneracao *ICMS exemption reason code (numeric)
aliquota_fcpFCP rate (%)

CST 30: exempt operation, with ICMS-ST collected for subsequent operations

The operation's own ICMS is 0; only ST is calculated. The fields are the same as the ST part of CST 10; aliquota has no effect.

{ "codigo_cfop": "5403", "situacao_tributaria": "30", "aliquota_st": "18", "aliquota_mva": "40" }

CST 40, 41, 50: exempt, not taxed, suspended

No tax is calculated, and the rate fields have no effect. When there is a relieved ICMS amount, valor_desoneracao and motivo_desoneracao are sent.

{ "codigo_cfop": "5102", "situacao_tributaria": "40" }

CST 51: deferral

aliquota is required; aliquota_diferimento is the deferral percentage, and the platform calculates the ICMS of the operation, the deferred ICMS and the ICMS payable.

{ "codigo_cfop": "5101", "situacao_tributaria": "51", "aliquota": "18", "aliquota_diferimento": "100" }

CST 60: ICMS-ST previously collected

No tax is calculated. The amounts previously collected are provided by the caller and declared as received; each field is declared only when greater than 0.

{ "codigo_cfop": "5405", "situacao_tributaria": "60",
  "v_bc_st_ret": "100.00", "p_st": "18", "v_icms_st_ret": "18.00", "v_icms_substituto": "12.00" }
FieldDescription
v_bc_st_ret / p_st / v_icms_st_retTax base, rate and tax amount previously collected
v_icms_substitutoThe substitute taxpayer's own ICMS
v_bc_fcp_st_ret / p_fcp_st_ret / v_fcp_st_retFCP previously collected

CST 70: reduced tax base, with ICMS-ST collected for subsequent operations

A combination of CST 20 and CST 10: aliquota, aliquota_reducao and aliquota_st are required.

{ "codigo_cfop": "5401", "situacao_tributaria": "70", "aliquota": "18", "aliquota_reducao": "33.33",
  "aliquota_st": "18", "aliquota_mva": "40" }

CST 90: other

When aliquota is 0 or omitted, the operation's own tax is not calculated and ST is not declared either; the ST fields take effect only when aliquota_st is greater than 0.

{ "codigo_cfop": "5949", "situacao_tributaria": "90", "aliquota": "12", "aliquota_reducao": "0" }

CST 02, 15, 53, 61: single-phase ICMS on fuels, levied by quantity

The tax is calculated by quantity; ad_rem_icms is the tax amount per unit (in reais). When q_bc_mono is omitted, the product quantity is used. CST 15 additionally requires ad_rem_icms_ret, CST 53 additionally requires p_dif_mono, and CST 61 requires only ad_rem_icms_ret.

{ "codigo_cfop": "5656", "situacao_tributaria": "02", "ad_rem_icms": "1.47", "q_bc_mono": "1000" }

ICMS under Simples Nacional (CRT 1, 4) 5 blocks

Only three-digit CSOSN codes are accepted. All fragments below are the content of impostos.icms.

CSOSN 102, 103, 300, 400: no credit allowed to the buyer

The most common case; only the CFOP and the CSOSN are required, and the rate fields have no effect.

{ "codigo_cfop": "5102", "situacao_tributaria": "102" }

CSOSN 101: credit allowed to the buyer

The credit rate aliquota_credito must be provided; the platform calculates the credit amount on the product amount.

{ "codigo_cfop": "5101", "situacao_tributaria": "101", "aliquota_credito": "1.25" }

CSOSN 201, 202, 203: ICMS-ST collected for subsequent operations

aliquota_st must be provided; aliquota_mva, aliquota_reducao_st and aliquota_fcp_st are optional. CSOSN 201 additionally requires aliquota_credito.

{ "codigo_cfop": "5401", "situacao_tributaria": "201", "aliquota_credito": "1.25",
  "aliquota_st": "18", "aliquota_mva": "40" }

CSOSN 500: ICMS-ST previously collected

The fields are the same as for CST 60; the amounts previously collected are provided by the caller.

{ "codigo_cfop": "5405", "situacao_tributaria": "500", "v_bc_st_ret": "100.00", "p_st": "18", "v_icms_st_ret": "18.00" }

CSOSN 900: other

aliquota, aliquota_reducao and aliquota_credito may be provided; the ST fields take effect only when aliquota_st is greater than 0.

{ "codigo_cfop": "5949", "situacao_tributaria": "900", "aliquota": "12" }

PIS and COFINS 6 blocks

Both groups follow the same rules and are filled in impostos.pis and impostos.cofins respectively. The CST must be one of the values below; otherwise the group is not declared and the invoice is rejected.

CST 01, 02: taxed at a rate

"pis":    { "situacao_tributaria": "01", "aliquota": "1.65" },
"cofins": { "situacao_tributaria": "01", "aliquota": "7.60" }

CST 03: taxed by quantity

valor_unidade is the tax amount per unit (in reais); the tax equals the quantity multiplied by this value.

"pis": { "situacao_tributaria": "03", "valor_unidade": "0.0864" }

CST 04 to 09: not taxed

Only the CST is declared; the rate fields have no effect.

"pis": { "situacao_tributaria": "07" }

CST 49, 99: other outbound operations

Simples Nacional companies usually use 49. When aliquota is sent, the tax is calculated at that rate; otherwise the tax is 0.

"pis": { "situacao_tributaria": "49" }

CST 50 to 56, 60 to 67, 70 to 75, 98: inbound

Used only in inbound and return invoices. For 70 to 75, the tax is always 0.

"pis": { "situacao_tributaria": "50", "aliquota": "1.65" }

Deducting ICMS and DIFAL from the PIS/COFINS base

When "desconta_icms_pis_cofins": true is sent at the top level of the product line, the PIS and COFINS tax base becomes the product base minus the line's own ICMS and, in interstate sales to non-taxpayer final consumers, also minus the destination-state DIFAL (vICMSUFDest) of the ICMSUFDest group. FCP is not deducted. The legal basis is Supreme Court Tema 69 and Superior Court of Justice Tema 1372.

IPI 3 blocks

codigo_enquadramento in impostos.ipi is the legal classification code (numeric); 999 is used when IPI does not apply.

Taxed: CST 50, 99 (outbound), 00, 49 (inbound)

When aliquota is sent, the tax is calculated at that rate; when no rate is sent but valor_unidade is, the tax is calculated by quantity. When the unit price already includes IPI, "price_includes_ipi": true is sent at the top level of the request or in the product line; the product line setting takes precedence.

"ipi": { "situacao_tributaria": "50", "codigo_enquadramento": "999", "aliquota": "10" }

Not taxed: CST 51 to 55 (outbound), 01 to 05 (inbound)

Only the CST is declared; the rate has no effect. Trading companies not subject to IPI usually use 53.

"ipi": { "situacao_tributaria": "53", "codigo_enquadramento": "999" }

Returned IPI in return invoices ipi_devolvido

Declared only in return invoices; it has no effect in other invoices. The returned IPI amount must be calculated by the caller.

"ipi_devolvido": { "percentual_devolvido": 100, "valor_ipi_devolvido": 15.00 }

IBS and CBS (2026 tax reform) 6 blocks

impostos.ibs_cbs is optional; it is declared only when situacao_tributaria is provided. classificacao_tributaria is filled according to the official cClassTrib classification table (the first three digits match the CST; xxx in the examples must be replaced with the actual code); the platform declares it as received without validation. The default rates for the 2026 test period are 0.1% for state IBS, 0% for municipal IBS and 0.9% for CBS; when p_ibs_uf and p_cbs are sent as 0, the default rates are also used.

CST 000, 010, 220: fully taxed

"ibs_cbs": { "situacao_tributaria": "000", "classificacao_tributaria": "000001" }

CST 011, 200: reduced rate

The rate reduction percentage p_red_aliq must be provided.

"ibs_cbs": { "situacao_tributaria": "200", "classificacao_tributaria": "200xxx", "p_red_aliq": "60" }

CST 221, 222, 830: proportional, reduced base or legal deduction

CST 221 requires proporcao (when omitted, the tax is 0); CST 222 requires p_red_bc; CST 830 requires valor_deducao_legal (in reais).

"ibs_cbs": { "situacao_tributaria": "222", "classificacao_tributaria": "222xxx", "p_red_bc": "20" }

CST 510, 515: deferral

The deferral percentage p_dif must be provided; CST 515 additionally requires p_red_aliq.

"ibs_cbs": { "situacao_tributaria": "510", "classificacao_tributaria": "510xxx", "p_dif": "100" }

CST 620: single-phase taxation of fuels by quantity

The percentage rates aliquota_ibs_mono and aliquota_cbs_mono take precedence; when they are not provided, the per-unit tax amounts valor_unidade_ibs and valor_unidade_cbs are used.

"ibs_cbs": { "situacao_tributaria": "620", "classificacao_tributaria": "620xxx",
  "valor_unidade_ibs": "0.05", "valor_unidade_cbs": "0.10" }

CST 400, 410, 550, 800, 810, 811, 820: exemption, suspension, credit transfer and similar

Only the CST and the classification code are declared; no tax is calculated.

"ibs_cbs": { "situacao_tributaria": "410", "classificacao_tributaria": "410xxx" }

Payment pag_info[] 7 blocks

Each payment requires payment_indicator and payment_method. payment_method is a two-character string (for example "01"); the number 1 is rejected. When pag_info is omitted or sent as an empty array, the invoice is issued as a cash payment, paid in full at sale, for an amount equal to the invoice total. When payment_value is omitted, the invoice total is used; with multiple payments, payment_value must be sent for each payment. The API does not validate the sum of the payments, and an invoice whose payment sum differs from the invoice total is rejected by the tax authority.

Cash, check, bank slip, transfer and vouchers

Applies to 01, 02, 05, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22. Only the payment method, the payment timing and the amount are sent. For these methods, card_info is not written to the invoice.

"pag_info": [
  { "payment_indicator": "0", "payment_method": "15", "payment_value": 56.94 }
]
FieldTypeDescription
payment_indicator *string"0" paid in full at sale, "1" paid in installments
payment_method *stringPayment method code; see Payment Parameters in the knowledge base
payment_valuedecimalAmount of this payment. When omitted, the invoice total is used

Credit and debit cards: card terminal not integrated with the invoicing system

This is the case for e-commerce and most physical stores. payment_method is "03" (credit card) or "04" (debit card), and integration_type is sent as "2". When card_info is omitted, the platform declares the payment as integrated with brand Visa, which does not reflect the actual transaction; therefore card_info must always be sent.

"pag_info": [
  {
    "payment_indicator": "0", "payment_method": "03", "payment_value": 56.94,
    "card_info": { "integration_type": "2", "brand_code": "02" }
  }
]
FieldTypeDescription
card_info.integration_type *string"2" not integrated
card_info.brand_code *stringCard brand code; see Payment Parameters in the knowledge base

Credit and debit cards: card terminal integrated with the invoicing system

Used when the store's point-of-sale system is directly integrated with the card terminal. integration_type is sent as "1", and the acquirer's CNPJ and the authorization code must also be provided.

"pag_info": [
  {
    "payment_indicator": "0", "payment_method": "04", "payment_value": 56.94,
    "card_info": {
      "integration_type": "1", "brand_code": "01",
      "acquirer_cnpj": "01027058000191", "authorization_code": "123456"
    }
  }
]
FieldTypeDescription
card_info.integration_type *string"1" integrated
card_info.brand_code *stringCard brand code
card_info.acquirer_cnpj *stringAcquirer's CNPJ; punctuation is allowed and is removed by the platform
card_info.authorization_code *stringTransaction authorization code

Other payment methods (99)

Payment methods with no corresponding entry in the code table. payment_description is required; when it is missing, the API returns an error.

"pag_info": [
  { "payment_indicator": "0", "payment_method": "99", "payment_value": 56.94, "payment_description": "Vale-troca" }
]
FieldTypeDescription
payment_description *stringDescription of the payment method

Multiple payments and change

When an invoice is paid with several methods, pag_info contains several payments, each with payment_value. When the customer overpays and change is due, troco is sent at the top level of the request. The sum of the payments minus troco must equal the invoice total exactly.

"troco": 3.06,
"pag_info": [
  { "payment_indicator": "0", "payment_method": "01", "payment_value": 40.00 },
  { "payment_indicator": "0", "payment_method": "17", "payment_value": 20.00 }
]
FieldTypeDescription
pag_info[].payment_value *decimalAmount of each payment
trocodecimalChange amount, at the top level of the request. When 0 or omitted, no change is declared

Installment payment

When the amount is paid in installments after the invoice is issued, payment_indicator is sent as "1", usually together with a bank slip (15).

"pag_info": [
  { "payment_indicator": "1", "payment_method": "15", "payment_value": 100.00 }
]

No payment (90) and deferred payment (91)

90 is used for invoices that involve no collection of payment, such as returns, transfers and gifts; 91 is used for deferred payment. For both, the platform sets the amount to 0, and payment_value has no effect. A regular sales invoice that uses 90 is rejected by the tax authority. Return invoices issued through /api/invoice/return use 90 automatically, and pag_info need not be sent.

"pag_info": [
  { "payment_indicator": "0", "payment_method": "90" }
]

Transport transportation 4 blocks

When transportation is omitted, the invoice is issued as "no freight" (9), and no freight or carrier information is declared. When transportation is provided, transport_mode must also be sent; it accepts only 0, 1, 2, 3, 4 and 9, and any other value is rejected. The table below shows the fields that take effect for each transport mode; fields marked "Not applicable" are not written to the invoice even when sent.

transport_modecarrier_infovehicle_info / trailer_infopackagestransport_tax_retention_info
0 Freight contracted by the issuerApplicableApplicableApplicableApplicable
1 Freight contracted by the recipientApplicableApplicableApplicableNot applicable
2 Freight contracted by a third partyApplicableApplicableApplicableNot applicable
3 Sender's own transportNot applicableApplicableApplicableNot applicable
4 Recipient's own transportNot applicableApplicableApplicableNot applicable
9 No freightNot applicableNot applicableNot applicableNot applicable
For interstate transport (sender and recipient in different states), vehicle_info and trailer_info must not be provided. The tax authority rejects such invoices (rejection code 868), and the API returns an error before submission. The same restriction applies to intrastate transport in the state of MG. For interstate transport, carrier_info and packages may be provided.

Transport by a contracted carrier (0, 1, 2)

The goods are carried by a logistics company. In mode 0 the issuer contracts the carrier and bears the freight cost; in mode 1 the recipient contracts the carrier; in mode 2 a third party contracts the carrier. All sub-objects are optional and are filled according to the information available.

"transportation": {
  "transport_mode": "0",
  "carrier_info": {
    "cnpj": "12345678000195", "ie": "123456789", "name": "Transportadora Demo LTDA",
    "endereco": "Rua A, 10", "city": "Curitiba", "uf": "PR"
  },
  "packages": [
    { "qty": 2, "packaging_type": "CAIXA", "number": "001-002", "net_weight": 1.250, "gross_weight": 1.500 }
  ]
}
FieldTypeDescription
transport_mode *string"0", "1" or "2"
carrier_info.cnpj / carrier_info.cpfstringCarrier document number; when carrier_info is provided, one of the two is required
carrier_info.namestringCarrier name; when not provided, no carrier information is written to the invoice
carrier_info.iestringCarrier state registration (written only with a CNPJ)
carrier_info.endereco / city / ufstringCarrier address, city and state
packages[]arrayPackages: qty, packaging_type, mark, number, net_weight, gross_weight, seals[]

Own-vehicle transport (3, 4)

In mode 3 the sender transports the goods with its own vehicle; in mode 4 the recipient collects the goods itself. In this case carrier_info has no effect. Vehicles and trailers may be declared only for intrastate transport; for interstate transport, only packages is provided.

"transportation": {
  "transport_mode": "3",
  "vehicle_info": { "plate": "ABC1D23", "uf": "PR", "rntc": "000123456" },
  "trailer_info": { "plate": "XYZ9Z99", "uf": "PR" },
  "packages": [ { "qty": 10, "packaging_type": "PALLET" } ]
}
FieldTypeDescription
transport_mode *string"3" or "4"
vehicle_info.plate / uf / rntcstringLicense plate, state of the license plate, National Registry of Road Cargo Carriers number (RNTC); intrastate transport only
trailer_info.plate / uf / rntcstringTrailer information, same structure as vehicle_info; intrastate transport only
packages[]arrayPackages; same fields as above

ICMS withholding on freight (mode 0 only)

Provided when the issuer withholds the ICMS on the transport service; written to the invoice only when transport_mode is "0". The withheld amount is calculated by the platform as tax_base × tax_rate, and the city code is obtained from cep.

"transportation": {
  "transport_mode": "0",
  "transport_tax_retention_info": {
    "freight_service_amount": 100.00, "tax_base": 100.00, "tax_rate": 12,
    "cfop": "5352", "cep": "80010000"
  }
}
FieldTypeDescription
freight_service_amount *decimalTransport service amount
tax_base *decimalWithholding tax base
tax_rate *decimalWithholding rate (%)
cfop *stringCFOP of the transport service
cep *stringZIP code of the place where the transport starts; when not provided, the whole group is not written to the invoice

Freight amount freight_amount

freight_amount is included in the invoice under every transport mode: the platform apportions it among the product lines in proportion to their quantities and includes it in the invoice total and in the tax base of every tax. It is filled in only when the freight is borne by the buyer and included in the amount of this invoice; otherwise it is sent as 0 or omitted.

Import and export

When transaction_type is "2" (import) or "3" (export), the transaction is declared as a foreign transaction and DIFAL is not calculated. The buyer fields are described in "Foreign buyer (export)". For imports, each product line must provide ii (Import Tax; keys in camelCase) and import_declarations, with the fields given in the field tables above; when ii is not provided, it is declared with all values set to 0.

"ii": { "vBC": 1000.00, "vDespAdu": 50.00, "vII": 140.00, "vIOF": 0.00 }

Tax bases on import invoices are calculated as follows. IPI base = item amount + freight + insurance − discount + ii.vII, excluding outras_despesas. ICMS base = (item amount + freight + insurance + outras_despesas − discount + ii.vII + IPI + ii.vIOF) ÷ (1 − ICMS rate − FCP rate); the ICMS itself is therefore part of its own base (Complementary Law 87/96, art. 13), and the IPI is included regardless of ind_final. Import PIS/COFINS, the Siscomex fee, AFRMM and other customs charges are summed from the import declaration and sent in outras_despesas; the import duty is sent only in ii.vII and is not added to outras_despesas. ii.vDespAdu and import_declarations[].vAFRMM are declarative only and do not enter any calculation.

Issuance type issuance_type

Only "1" (normal) should be sent. When the tax authority's service is unavailable, the platform automatically switches to contingency issuance and fills in the contingency date and time and justification; when the caller sends a contingency type, these are not filled in and the invoice is rejected.

Response fields (data)

FieldTypeDescription
uuidstringInternal NF-e identifier. Use it in follow-up calls (/api/invoice/get_detail, /refresh, /cancel). On a rejection, uuid and nfe are informative only: the invoice is not stored and the number is reused on the next issuance
statusstringStatus: on a new issuance, "Success" (authorized) or "Failed" (rejected/failed). "Processing" and "Contingencia" only appear when deduplication by id returns an existing invoice
motivostringTax authority text for the cStat; mapped rejections come in PT / 中文. Today an authorization comes back as "Rejeição 100: Autorizado o uso da NF-e" — decide by success/status, never by the text
nfeintIssued NF-e number
serieintNF-e series
chavestring44-digit access key (empty when the invoice was not authorized)
modelostringDocument model: "nfe"
epecbooleanIssued under EPEC contingency
xmlstringURL of the authorized XML. The DANFE (PDF) and other formats come from /api/invoice/get_detail

Response — rejection / error

When the tax authority rejects the invoice, success is false and data.motivo holds the reason; chave comes back empty. Field validation errors (before reaching the tax authority) return success: false with the message in message and no data object. Every response also has message ("成功" on success and "失败" when the tax authority rejects). Failures before the tax authority — field validation, XML schema, certificate, tax authority unavailable — come back with success: false, the text in message and no data. Failures also carry an error code in code (see "Error handling"); a rejection by the tax authority has TAX_AUTHORITY_REJECTED. Where deduplication by id applies, if the request reached the tax authority but no definitive answer came back (for example, a timeout), the API returns success: false with a message stating that the result is not yet confirmed; the order is protected against duplicate issuance, and the same request must be resubmitted a few minutes later with the same id to obtain the invoice. The id must not be changed.
{
  "success": false,
  "message": "失败",
  "code": "TAX_AUTHORITY_REJECTED",
  "data": {
    "uuid": "4663a257-adf1-4561-971f-6aaffbd30ca8",
    "status": "Failed",
    "motivo": "Rejeição 226: Código da UF do Emitente diverge da UF autorizadora / 拒绝 226: 发件人所在州代码与授权州不一致",
    "nfe": 100,
    "serie": 1,
    "chave": "",
    "modelo": "nfe",
    "epec": false,
    "xml": ""
  }
}

Complete NF-e Issuance Examples

Complete Example with Transportation

{
  "nature_of_operation": "Venda de mercadoria",
  "transaction_type": "1",
  "model": "55",
  "issuance_type": "1",
  "ambiente": "2",
  "ind_final": "0",
  "ind_pres": "1",
  "cliente": {
    "cnpj": "12345678000195",
    "ie": "110030010189",
    "name": "Empresa Cliente Ltda",
    "endereco": "Rua Exemplo",
    "numero": "123",
    "complemento": "Sala 45",
    "bairro": "Centro",
    "city": "São Paulo",
    "uf": "SP",
    "cep": "01310100",
    "telefone": "11999999999",
    "email": "contato@empresa.com"
  },
  "products": [
    {
      "codigo": "PROD001",
      "name": "Smartphone XYZ",
      "ncm": "85171300",
      "count": 2,
      "unit": "UN",
      "unit_price": 1500.00,
      "total_price": 3000.00,
      "category_id": "SEU_CATEGORY_ID",
      "origem": 0,
      "indicador_total": 1
    }
  ],
  "transportation": {
    "transport_mode": "0",
    "freight_amount": 30.00,
    "carrier_info": {
      "cnpj": "11222333000181",
      "name": "Transportadora Expressa",
      "endereco": "Rua da Transportadora",
      "city": "São Paulo",
      "uf": "SP"
    },
    "vehicle_info": {
      "plate": "ABC1234",
      "uf": "SP",
      "rntc": "123456"
    },
    "packages": [
      {
        "qty": 1,
        "packaging_type": "CX",
        "gross_weight": 2.500,
        "net_weight": 2.000
      }
    ]
  },
  "shipping_address": {
    "cnpj": "12345678000195",
    "name": "Remetente Ltda",
    "endereco": "Rua do Remetente",
    "number": "100",
    "bairro": "Centro",
    "city": "São Paulo",
    "uf": "SP",
    "cep": "01001000"
  },
  "delivery_address": {
    "cnpj": "98765432000198",
    "name": "Destinatário Ltda",
    "endereco": "Rua do Destinatário",
    "number": "200",
    "bairro": "Centro",
    "city": "Rio de Janeiro",
    "uf": "RJ",
    "cep": "20040020"
  },
  "pag_info": [
    {
      "payment_method": "03",
      "payment_indicator": "0",
      "card_info": {
        "integration_type": "1",
        "brand_code": "01"
      }
    }
  ],
  "informacoes_complementares": "Sem informações adicionais",
  "informacoes_fisco": "ICMS recolhido conforme legislação"
}
INFORMATION: This example includes all important fields, including transportation, detailed fiscal information, and payment. Adapt values according to your specific needs.

Complete Import Example

{
  "id": "PED-IMP-001",
  "nature_of_operation": "Importação para revenda",
  "transaction_type": "2",
  "model": "55",
  "issuance_type": "1",
  "ambiente": "2",
  "finalidade": "1",
  "ind_final": "0",
  "ind_pres": "9",
  "cliente": {
    "name": "EXPORTADOR EXTERIOR CO LTD",
    "endereco": "Pudong District",
    "numero": "456",
    "city": "Shanghai",
    "id_estrangeiro": "CN-EXP-001",
    "c_pais": 1600,
    "x_pais": "CHINA"
  },
  "products": [
    {
      "name": "Fonte chaveada 12V 2A Quickfitting",
      "codigo": "123450000888",
      "ncm": "85044090",
      "count": 2,
      "unit": "PC",
      "unit_price": 0.25,
      "total_price": 0.50,
      "origem": 1,
      "indicador_total": 1,
      "category_id": "SEU_CATEGORY_ID",
      "ii": {
        "vBC": 0.50,
        "vDespAdu": 0.00,
        "vII": 0.00,
        "vIOF": 0.00
      },
      "import_declarations": [
        {
          "nDI": "2312345678",
          "dDI": "2026-04-12",
          "xLocDesemb": "PORTO DE SANTOS",
          "UFDesemb": "SP",
          "dDesemb": "2026-04-15",
          "tpViaTransp": 1,
          "vAFRMM": 1.00,
          "tpIntermedio": 1,
          "cExportador": "EXP-CN-001",
          "additions": [
            {
              "nAdicao": 1,
              "nSeqAdic": 1,
              "cFabricante": "FAB-CN-001",
              "vDescDI": 0,
              "nDraw": ""
            }
          ]
        }
      ]
    },
    {
      "name": "Quick fitting MA",
      "codigo": "123450000157",
      "ncm": "85044090",
      "count": 2,
      "unit": "PC",
      "unit_price": 0.25,
      "total_price": 0.50,
      "origem": 1,
      "indicador_total": 1,
      "category_id": "SEU_CATEGORY_ID",
      "ii": {
        "vBC": 0.50,
        "vDespAdu": 0.00,
        "vII": 0.00,
        "vIOF": 0.00
      },
      "import_declarations": [
        {
          "nDI": "2312345678",
          "dDI": "2026-04-12",
          "xLocDesemb": "PORTO DE SANTOS",
          "UFDesemb": "SP",
          "dDesemb": "2026-04-15",
          "tpViaTransp": 1,
          "vAFRMM": 1.00,
          "tpIntermedio": 1,
          "cExportador": "EXP-CN-001",
          "additions": [
            {
              "nAdicao": 1,
              "nSeqAdic": 2,
              "cFabricante": "FAB-CN-001",
              "vDescDI": 0,
              "nDraw": ""
            }
          ]
        }
      ]
    }
  ],
  "pag_info": [
    {
      "payment_method": "90",
      "payment_indicator": "0"
    }
  ]
}
INFORMATION: Example for NFe Import (CFOP 3.xxx). Differences from a domestic NFe:
  • transaction_type: "2" — inbound (import) operation.
  • cliente without cnpj/cpf/uf/cep; uses id_estrangeiro, c_pais (BACEN table — China = 1600) and x_pais.
  • category_id must point to a tax category with CFOP 3.xxx and CST/CSOSN compatible with import.
  • Product origem = 1 (foreign — direct import) or 6 (foreign — direct import, no domestic equivalent, on the CAMEX list). Origin 2 is for foreign goods bought in the domestic market, not for the import itself.
  • The ii block (Import Tax) is emitted when transaction_type="2" (it does not depend on the CFOP) and should be sent in that case — the API does not check it. Values come from the DI issued by the customs broker (vBC, vDespAdu, vII, vIOF). May be zero for testing.
  • The import_declarations block (Import Declaration) contains customs clearance data: nDI, dDI, clearance location/state/date, transport mode, intermediary, exporter and additions.
  • vAFRMM is required when tpViaTransp = 1 (Sea).