NF-e: validate, issue and follow
Check an NF-e with the dry-run, issue it with an Idempotency-Key and follow its states until it is authorized.
1. Validate (dry-run)
POST /v1/invoices/validate runs the same checks as the real issue, builds the note and checks it against the official layout, but sends nothing to the SEFAZ, reserves no number and charges nothing. It answers the access key the note would have. Add ?includeXml=true to also get the XML.
Request body (the same one to issue)
{
"type": "nfe",
"companyId": "5b8b6a0e-3c6f-4f4e-9a1b-0d7a6d5c2e11",
"recipient": {
"taxId": "123.456.789-09",
"name": "Maria da Silva",
"indIeDest": 9,
"email": "[email protected]",
"address": {
"street": "Rua das Flores",
"number": "10",
"district": "Centro",
"zip": "01001-000",
"cityCode": "3550308",
"city": "São Paulo",
"state": "SP"
}
},
"items": [
{
"code": "SKU1",
"description": "Camiseta de algodão",
"ncm": "61091000",
"cfop": "5102",
"unit": "UN",
"quantity": 2,
"unitPrice": 10,
"tax": { "csosn": "102" }
}
],
"payments": [{ "tPag": "17", "amount": 20 }]
}Answer 200
{
"data": {
"valid": true,
"accessKeyPreview": "35261111222333000181550010000000011234567891"
}
}When something is wrong the answer is 422 and details lists each field with its path, such as items[1].ncm. The dashboard marks those fields in the form.
Answer 422
{
"statusCode": 422,
"code": "ERROR_NFE_VALIDATION_FAILED",
"type": "validation",
"message": "The NF-e has problems; see details",
"details": [
{ "field": "items[1].ncm", "code": "NCM_INVALID", "message": "NCM must have 8 digits" }
]
}2. Issue
POST /v1/invoices
curl -X POST https://api-notas.arquivix.com/v1/invoices \
-H "X-API-Key: $ARQUIVIX_API_KEY" \
-H "Idempotency-Key: pedido-1042" \
-H "Content-Type: application/json" \
-d @nfe.jsonAnswer 202
{
"data": {
"type": "nfe",
"id": "0b7f2f0e-8f43-4f6e-8a35-6a3b0f1d9c77",
"status": "queued"
}
}Idempotency-Key(1 to 200 characters) is required. Repeating the same key with the same body returns the same note (200,replayed: true); the same key with another body answers409IDEMPOTENCY_KEY_REUSED. A retry never issues two notes.recipient.indIeDest:9non-taxpayer (most people),1taxpayer (needsstateRegistration),2exempt.items[].cfop:5xxxinside the state,6xxxfor another state.items[].ncm: 8 digits.items[].tax.csosn:102,101,400or500; left out, the company default applies.paymentsminuschangemust equal the total of the note. Totals are computed by Arquivix Notas from the items (each item rounded to cents).payments[].cardis optional. The SEFAZ requires the card group fortPag03 (credit), 04 (debit) and 17 (Pix); if you leave it out, Arquivix Notas sendstpIntegra2 (not integrated). Sendcard{tpIntegra,cnpj,tBand,cAut} only for an integrated payment.sendEmail(defaulttrue): when the recipient has an e-mail, the XML and the DANFE are sent after the authorization.- Text fields accept letters, digits and common punctuation. Emoji and line breaks are refused with the field named, before the SEFAZ.
Regime normal (CRT 3)
A Lucro Presumido or Lucro Real company issues with CRT 3. Each item sends its ICMS and, when the company pays IPI, the IPI; Arquivix Notas computes the bases and amounts from the rates (ICMS base under LC 87/1996, art. 13; vNF adds IPI, ICMS-ST and FCP-ST, MOC 7.0 field W16). PIS and COFINS go with CST 01 and the basic rate of the company's fiscal profile: 0.65% and 3% cumulative (Law 9.718/1998) or 1.65% and 7.6% non-cumulative (Laws 10.637/2002 and 10.833/2003). Each item also carries the IBSCBS group (CST 000, cClassTrib 000001) the SEFAZ requires from CRT 3 (rejection 1115): in 2026, CBS 0.9% and IBS 0.1% (LC 214/2025, arts. 346 and 343) on the item value without IPI, ICMS, FCP, DIFAL, PIS and COFINS (LC 214/2025, art. 12, § 2º; NT 2025.002-RTC), summed in total/IBSCBSTot; vNF does not change. Without published rates for the year, the note is blocked. The NFC-e of CRT 3 takes the own ICMS (CST 00, 20, 40, 41, 60 or 90), PIS/COFINS and the IBSCBS group; IPI, ICMS-ST and DIFAL answer 422 NFCE_SCOPE_NOT_SUPPORTED (issue an NF-e).
Item of a CRT 3 note
{
"code": "SKU-10",
"description": "Furadeira 500 W",
"ncm": "84672100",
"cfop": "6102",
"unit": "UN",
"quantity": 1,
"unitPrice": 400,
"tax": {
"icms": { "cst": "00", "rate": 12 },
"ipi": { "cst": "50", "cEnq": "999", "rate": 5 },
"difal": { "internalRate": 18, "interstateRate": 12, "fcpRate": 2 }
}
}| Field | What it is |
|---|---|
tax.icms.cst | 00, 10, 20, 30, 40, 41, 50, 51, 60, 70 or 90. Required on CRT 3 (ICMS_REQUIRED). |
tax.icms.rate · baseReduction · fcpRate | pICMS, pRedBC (CST 20 and 70) and pFCP (ADCT, art. 82), in %. |
tax.icms.st | ICMS-ST for CST 10, 30 and 70 (LC 87/1996, art. 8º, II): modBCST 4 (MVA, the default) or 6, mva already adjusted, baseReduction, rate and fcpRate. The own ICMS is deducted. Without MVA on modBCST 4 the answer is ICMS_ST_MVA_REQUIRED; another modBCST is ICMS_ST_MODBC_NOT_SUPPORTED. |
tax.difal | Required in an interstate sale to a final consumer who is not a taxpayer (idDest 2, indFinal 1, indIeDest 9; CF, art. 155, §2º, VII): internalRate, interstateRate (4, 7 or 12, Senate Resolutions 22/1989 and 13/2012), fcpRate and, for the double base, base. 100% goes to the destination (ADCT, art. 99). |
tax.ipi | cst (50, 99 taxed; 52, 53... not taxed), cEnq (3 digits, 999 normal taxation) and rate. |
tax.pisCst · tax.cofinsCst · pisRate · cofinsRate | Default 01 with the basic rate of the profile. 02 needs pisRate/cofinsRate (PIS_COFINS_RATE_REQUIRED). |
Returns and incoming notes
tpNf says the direction: 1 saída (the default) or 0 entrada, such as goods a customer sends back. The CFOP follows it: 5xxx/6xxx going out, 1xxx/2xxx coming in, inside or outside the UF (CFOP_DESTINATION_MISMATCH, Rejeições 518 and 519). references lists the notes this one refers to by their access key (NFref, up to 999).
A return is finNfe: 4 (MOC 7.0 and NT 2016.002): it refers to at least one note (RETURN_REFERENCE_MISSING, Rejeição 321) and has no payment, one tPag 90 with amount 0 (RETURN_PAYMENT_NOT_ALLOWED, Rejeição 871). A key with a wrong check digit answers REFERENCE_KEY_INVALID on references[n].accessKey. The taxes of each item are the ones you send, normally the same CST and rate of the note being returned. GET /v1/invoices/{id} answers tpNf, finNfe and references as they went in the XML, so a return can be told from a sale. The same single tPag 90 with amount 0 fits any NF-e with no payment, such as a transfer between branches (CFOP 5409/6409) or a shipment for consignment: the payments then do not have to add up to vNF. The NFC-e always carries the payment of the sale.
When the returned note had IPI, send it back on each item in tax.ipiReturn: percent is the share of the goods returned (pDevol) and amount the IPI given back (vIPIDevol), normally the IPI of the original note times that share. It goes in the impostoDevol group (NT 2016.002), outside imposto, and joins vIPIDevol and vNF in the total. Only a return takes it: on any other note it answers IPI_RETURN_NOT_A_RETURN.
POST /v1/invoices: a customer return
{
"type": "nfe",
"companyId": "<company id>",
"finNfe": 4,
"tpNf": 0,
"natOp": "Devolucao de venda",
"references": [
{
"accessKey": "23261104558154000154550010000001061807943589"
}
],
"recipient": {
"...": "the customer who returns"
},
"items": [
{
"code": "TEC-001",
"description": "Tecido tricoline",
"ncm": "52081200",
"cfop": "1202",
"unit": "M",
"quantity": 10,
"unitPrice": 20,
"tax": {
"icms": {
"cst": "00",
"rate": 20
}
}
}
],
"payments": [
{
"tPag": "90",
"amount": 0
}
]
}Saved products and customers
To avoid typing the same items again, save them as products of the company. They live in the same favorites as the services: GET /v1/companies/:companyId/service-favorites?kind=product lists them, POST with kind: "product" saves one and DELETE /v1/companies/:companyId/service-favorites/:favoriteId removes it (nfe.documents.view or nfe.documents.issue). Without kind the routes still work as before, for services. A product has description, ncm and unitPrice, and optionally code, gtin, cest, cfop, unit, csosn and origin. Saving the same description again updates the product. Up to 500 per company. On MCP, service_favorite_list, service_favorite_create and service_favorite_delete take kind: "product". In the dashboard, search them on each item, use "Save as product" and see the list in Products.
When an NF-e is accepted, Arquivix Notas also saves the recipient in the saved customers (GET /v1/customers/:taxId), now with the address (with the IBGE city code), the indIeDest and the state registration. The NF-e form fills the recipient from it, and you can correct it with PATCH /v1/customers/:taxId (address, indIeDest, stateRegistration) or on the Customers page.
3. Follow
Issuing is asynchronous, like the NFS-e. Read the note with GET /v1/invoices/:id or wait for the webhook. The states are:
| Status | Meaning |
|---|---|
queued, processing | Waiting to be sent, or being sent to the SEFAZ. |
authorized | The SEFAZ authorized it. protocol, authorizedAt and, a moment later, documentsReady appear. |
rejected | The SEFAZ refused it. See lastError. The number is kept: fix it and send again (PUT) or discard it. |
denied | The SEFAZ denied it (final). |
retry_pending | The SEFAZ was unavailable. Arquivix Notas tries again by itself. |
reconciliation_required | No answer from the SEFAZ. Arquivix Notas checks by the access key, without issuing again. If the SEFAZ does not know the key, the same signed XML goes again 6 hours after the issue, by itself. |
manual_review | The check could not confirm. Ask again with POST /v1/invoices/:id/sync. |
cancelling, cancelled | Cancellation requested, then registered. |
discarded | A rejected note that was given up (final). Its number needs an inutilization. |