CFOP by Scenario
Find the operation code for each business scenario and how the platform applies it
CFOP (Código Fiscal de Operações e Prestações) is the 4-digit operation code every item line of an electronic invoice must carry. It tells the tax authority the nature of the movement (sale, return, transfer, consignment, import/export…) and its direction (inbound or outbound; same state, another state or abroad). A wrong CFOP gets the invoice rejected at best, and distorts tax filings and credits at worst.
This page is organised by business scenario: identify the nature of the operation, then the counterparty’s location, and read the code. Hover a code to see the official Portuguese description.
The first digit sets direction and scope
| Digit | Direction | Counterparty location | Platform transaction_type |
|---|---|---|---|
1 | Inbound | Same state | 0 |
2 | Inbound | Another state | 0 |
3 | Inbound | Abroad (import) | 2 |
5 | Outbound | Same state | 1 |
6 | Outbound | Another state | 1 |
7 | Outbound | Abroad (export) | 3 |
How the platform applies CFOP
- Direction comes from
transaction_type: 0 inbound → 1/2/3.xxx, 1 outbound → 5/6/7.xxx, 2 import → 3.xxx, 3 export → 7.xxx. The first digit must match, or the tax authority rejects the invoice. - Same state vs. interstate is resolved by the platform by comparing the issuer's and recipient's UF. ICMS rows in the tax category (
category_id) are picked by scenario:saida_dentro_estado/saida_fora_estado/entrada_dentro_estado/entrada_fora_estado, falling back topadrao, and split bytipo_pessoa(fisica / juridica). Recommended: configure the CFOP of every scenario in the category and send onlycategory_idwhen issuing. - Inline per invoice is also possible:
products[].impostos.icms.codigo_cfop. When inlining, send all four groups icms / ipi / pis / cofins. - Both
5.102and5102are accepted; the dot is stripped. - Return endpoint (
/api/invoice/return): withoutcfopit defaults to1202(same state) or2202(interstate); the return invoice is forced to inbound,finalidade=4, referencing the original. - Import (3.xxx) requires import tax
impostos.iiand the DI declaration fields; if a category mixes several ICMS rows, import prefers the 3.xxx one. - Three most common mistakes: interstate sale to a consumer or non-taxpayer with 6102 (should be 6108); a return issued with a sale code (should be 1202 / 2202); first digit inconsistent with
transaction_type.
Sales (outbound)
transaction_type = 1. Same state vs. interstate only changes the first digit (5 / 6); interstate also depends on whether the recipient is an ICMS taxpayer.
| Scenario | Same state | Interstate | Abroad | Notes |
|---|---|---|---|---|
| Sale of own productionVenda de produção do estabelecimento. | 5101 | 6101 | 7101 | Interstate sale to a consumer or non-taxpayer uses 6107 (below). |
| Resale of goods bought from third parties (trading, e-commerce)Venda de mercadoria adquirida ou recebida de terceiros, ou qualquer venda de mercadoria efetuada pelo MEI com exceção das saídas classificadas nos códigos 5.501, 5.502, 5.504 e 5.505. | 5102 | 6102 | 7102 | Interstate sale to a consumer or non-taxpayer uses 6108. The most common category setup on the platform is 5102 / 6102 / 6108. |
| Interstate sale to consumers or non-taxpayers (B2C, e-commerce)Venda de produção do estabelecimento. | 5101own production5102resale goods | 6107own production6108resale goods | — | Same-state sales do not distinguish the recipient type. Interstate involves DIFAL (interstate rate difference). In the category, configure by tipo_pessoa: juridica → 6102, fisica → 6108. |
| Sale of ST goods with tax already withheld upstream (substituted party)Venda de mercadoria adquirida ou recebida de terceiros em operação com mercadoria sujeita ao regime de substituição tributária, na condição de contribuinte substituído. | 5405 | 6404 | — | Typical for Simples Nacional retailers reselling ST goods. ICMS with CSOSN 500 or CST 60. |
| Sale of ST goods as the substitute (you withhold ICMS-ST)Venda de produção do estabelecimento em operação com produto sujeito ao regime de substituição tributária, na condição de contribuinte substituto. | 5401own production5403resale goods | 6401own production6403resale goods | — | ICMS with CST 10 or CSOSN 201 – 203; ST base and amount are required. |
| Bonus, donation or promotional giftRemessa em bonificação, doação ou brinde. | 5910 | 6910 | — | No payment: use 90 (no payment) in pag_info. |
| Free samplesRemessa de amostra grátis. | 5911 | 6911 | — | |
| Future delivery — invoice first, ship laterLançamento efetuado a título de simples faturamento decorrente de venda para entrega futura. | 5922 | 6922 | — | Billing only; when goods ship, use the next row and reference this invoice. |
| Future delivery — actual shipmentVenda de produção do estabelecimento originada de encomenda para entrega futura. | 5116own production5117resale goods | 6116own production6117resale goods | — | |
| Sale to order (venda à ordem)Venda de produção do estabelecimento industrial ou rural, entregue ao destinatário por conta e ordem do adquirente originário, em venda à ordem. | 5118own production5119resale goods51205923 | 6118own production6119resale goods61206923 | — | 5118 / 5119: original seller invoices the buyer (goods delivered to the buyer's consignee); 5120: buyer resells to the consignee; 5923: symbolic dispatch from the original seller to the consignee. |
| Other outbound (when no specific code fits)Outra saída de mercadoria ou prestação de serviço não especificada. | 5949 | 6949 | 7949 | Generic code, and the one most often challenged in audits. Returns, samples, demonstrations and repairs all have dedicated codes and should not be replaced by it. |
Returns
A return moves in the opposite direction of the original: customer returns = your inbound (1/2/3.2xx); return to supplier = your outbound (5/6/7.2xx). Always reference the original (ref_nfe_chave) with finalidade = 4.
| Scenario | Same state | Interstate | Abroad | Notes |
|---|---|---|---|---|
| Customer returns goods you soldDevolução de venda de mercadoria adquirida ou recebida de terceiros, ou qualquer devolução de mercadoria efetuada pelo MEI com exceção das classificadas nos códigos 1.503, 1.504, 1.505 e 1.506. | 1202resale goods1201own production | 2202resale goods2201own production | 3202resale goods3201own production | Use /api/invoice/return. Without cfop the platform defaults to 1202 (same state) / 2202 (interstate); pass 1201 / 2201 explicitly for own production. |
| You return purchased goods to the supplierDevolução de compra para comercialização, ou qualquer devolução de mercadorias efetuada pelo MEI com exceção das classificadas no código 5.503. | 5202resale goods5201for manufacturing | 6202resale goods6201for manufacturing | 7202resale goods7201for manufacturing | Use /api/invoice/create: transaction_type = 1, finalidade = 4, ref_nfe_chave referencing the supplier's invoice. |
| ST goods — customer returnDevolução de venda de mercadoria adquirida ou recebida de terceiros em operação com mercadoria sujeita ao regime de substituição tributária. | 1411resale goods1410own production | 2411resale goods2410own production | — | |
| ST goods — return to supplierDevolução de compra para comercialização em operação com mercadoria sujeita ao regime de substituição tributária. | 5411resale goods5410for manufacturing | 6411resale goods6410for manufacturing | — |
Purchases (inbound)
transaction_type = 0. Inbound invoices are normally issued by the supplier; issue your own when the supplier cannot (individuals, abroad) or when self-registration is required.
| Scenario | Same state | Interstate | Abroad | Notes |
|---|---|---|---|---|
| Purchase for resaleCompra para comercialização. | 1102 | 2102 | 3102 | For purchases abroad use the import scenario (transaction_type = 2). |
| Purchase for manufacturingCompra para industrialização ou produção rural. | 1101 | 2101 | 3101 | |
| Purchase of fixed assetsCompra de bem para o ativo imobilizado. | 1551 | 2551 | 3551 | |
| Purchase of material for use or consumptionCompra de material para uso ou consumo. | 1556 | 2556 | 3556 | |
| Purchase of ST goodsCompra para comercialização em operação com mercadoria sujeita ao regime de substituição tributária. | 1403resale goods1401for manufacturing | 2403resale goods2401for manufacturing | — | |
| Stock reclassification (kit assembly / disassembly)Lançamento efetuado a título de reclassificação de mercadoria decorrente de formação de kit ou de sua desagregação. | 1926inbound5926outbound | — | — | Internal bookkeeping, no counterparty. |
| Other inbound (when no specific code fits)Outra entrada de mercadoria ou prestação de serviço não especificada. | 1949 | 2949 | 3949 |
Transfers between branches of the same company
| Scenario | Same state | Interstate | Abroad | Notes |
|---|---|---|---|---|
| Transfer — sending branchTransferência de produção do estabelecimento. | 5151own production5152resale goods | 6151own production6152resale goods | — | Branches under the same CNPJ root. |
| Transfer — receiving branchTransferência para comercialização. | 1152resale goods1151for manufacturing | 2152resale goods2151for manufacturing | — |
Dispatch and return (non-sale movements)
These documents carry no revenue and usually no payment (pag_info = 90). Dispatch and return codes are used in pairs.
| Scenario | Same state | Interstate | Abroad | Notes |
|---|---|---|---|---|
| Consignment — dispatch (consignor)Remessa de mercadoria em consignação mercantil ou industrial. | 5917 | 6917 | — | When goods are actually sold, the consignor issues the sale: 5114 (resale goods) / 5113 (own production). |
| Consignment — unsold goods returnedDevolução de mercadoria remetida em consignação mercantil ou industrial. | 1918 | 2918 | — | |
| Consignment — consignee sells the goodsVenda de mercadoria adquirida ou recebida de terceiros, recebida anteriormente em consignação mercantil. | 5115 | — | — | |
| Repair — dispatch and return (owner)Remessa de mercadoria ou bem para conserto ou reparo. | 5915dispatch1916return | 6915dispatch2916return | — | |
| Repair — receipt and return (repair shop)Entrada de mercadoria ou bem recebido para conserto ou reparo. | 1915inbound5916outbound | 2915inbound6916outbound | — | |
| Demonstration / trade fair — dispatchRemessa de mercadoria ou bem para demonstração, mostruário ou treinamento. | 5912demonstration5914trade fair | 6912demonstration6914trade fair | — | |
| Demonstration / trade fair — returnRetorno de mercadoria ou bem remetido para demonstração, mostruário ou treinamento. | 1913demonstration1914trade fair | 2913demonstration2914trade fair | — | |
| Toll manufacturing — ordering partyRemessa para industrialização por encomenda. | 5901dispatch1902return1124processing fee | 6901dispatch2902return2124processing fee | — | Send materials → receive finished goods → book the processor's fee invoice. |
| Toll manufacturing — processorEntrada para industrialização por encomenda. | 1901inbound5902return5124processing fee | 2901inbound6902return6124processing fee | — | Receive materials → return finished goods → invoice the processing fee. |
| Third-party warehouse — depositorRemessa para depósito fechado, armazém geral ou outro estabelecimento da mesma empresa ou de terceiro. | 5905dispatch1906return | 6905dispatch2906return | — | Common for third-party logistics and overseas warehouses; already in use by platform customers (5905). |
| Third-party warehouse — warehouse operatorEntrada de mercadoria recebida para depósito em depósito fechado, armazém geral ou outro estabelecimento da mesma empresa ou de terceiro. | 1905inbound5906return | 2905inbound6906return | — | |
| Stock write-off (loss, theft, deterioration, closure)Lançamento efetuado a título de baixa de estoque decorrente de perda, roubo, deterioração. | 59275928business closure | — | — | |
| Complementary registration (invoice issued after the fact)Lançamento efetuado em decorrência de emissão de documento fiscal relativo à operação ou prestação também acobertada por documento fiscal do varejo. | 5929 | 6929 | — | For example an NF-e issued to consolidate sales already documented by NFC-e. |
Import and export
| Scenario | Same state | Interstate | Abroad | Notes |
|---|---|---|---|---|
| ImportCompra para comercialização. | — | — | 3102resale goods3101for manufacturing3551fixed asset3556use & consumption | transaction_type = 2. Import tax impostos.ii and DI fields are mandatory; the category's 3.xxx ICMS row is preferred. |
| Direct exportVenda de produção do estabelecimento. | — | — | 7101own production7102resale goods7949 | transaction_type = 3. Identify the recipient with id_estrangeiro; the platform ignores tipo_pessoa. |
| Indirect export — dispatch to an exporter / trading companyRemessa de produção do estabelecimento, com fim específico de exportação. | 5501own production5502resale goods | 6501own production6502resale goods | — | |
| Indirect export — exporter receives and ships abroadEntrada de mercadoria recebida com fim específico de exportação. | 1501inbound | 2501inbound | 7501outbound | |
| Export lot formationRemessa de mercadorias para formação de lote de exportação, de produtos industrializados ou produzidos pelo próprio estabelecimento. | 5504own production5505resale goods | 6504own production6505resale goods | — |
Services and transport
| Scenario | Same state | Interstate | Abroad | Notes |
|---|---|---|---|---|
| Transport service invoice (CT-e, carrier's side)Prestação de serviço de transporte para execução de serviço da mesma natureza. | 5351same-nature service5352industrial customer5353commercial customer5359goods outside ICMS flow5932origin outside registered state | 6351same-nature service6352industrial customer6353commercial customer6359goods outside ICMS flow6932origin outside registered state | — | Pick by customer type: industrial 5352, commercial 5353; goods outside the ICMS flow (non-taxpayers, personal effects) use 5359. |
| Purchase of transport service (freight booking)Aquisição de serviço de transporte por estabelecimento industrial. | 1352industrial customer1353commercial customer | 2352industrial customer2353commercial customer | — | "Industrial / commercial" refers to the purchaser's own nature. |
| Services under municipal service tax (ISS)Prestação de serviço sujeita ao ISSQN. | 5933outbound1933inbound | 6933outbound2933inbound | — | Pure services normally go through NFS-e; use these on an NF-e only when goods and services share one invoice. |
Official descriptions are the tax authority's Portuguese text (hover a code), compiled from Ajuste SINIEF 07/01 and later amendments. This page covers common scenarios only; for anything not listed, confirm direction and scope first, then look the nature up in the official table or contact support.