NF-e: files and webhooks
Download the authorized XML and the DANFE, and receive the nfe.* webhook events.
Files
After the authorization, Arquivix Notas builds the authorized XML (nfeProc) and the DANFE (the printable PDF) and sets documentsReady: true on the note. Before that, asking for a file answers 409 DOCUMENTS_NOT_READY. A rejected note has no DANFE, but GET /v1/invoices/:id/xml gives the signed XML the SEFAZ refused (nfe-rejeitada-<number>.xml, with no protocol), so you can check what was sent.
GET /v1/invoices/:id/xmlandGET /v1/invoices/:id/pdfanswer the file itself.POST /v1/invoices/:id/download-urlwith{ "format": "xml" | "pdf" }answers a temporary link (downloadUrl,expiresAt). Another format answersNFE_DOWNLOAD_FORMAT_INVALID.- The monthly package for the accountant (
GET /v1/companies/:id/invoice-package) also carries the NF-e and the NFC-e of the month (foldersnfe/andnfce/, withnfe-resumo.csv).
Send the e-mail again
POST /v1/invoices/:id/email sends an authorized NF-e or NFC-e again, with the XML and the DANFE (the DANFCE for a NFC-e). It goes to the e-mail of the recipient, or to the address you send in { "email": "[email protected]" }. The same Idempotency-Key is one send. A note that is not authorized yet or has no files ready answers 409 DOCUMENTS_NOT_READY; a cancelled one, 409 INVOICE_CANCELLED_NO_EMAIL; no address at all, 422 CUSTOMER_EMAIL_MISSING. In the dashboard, the button is Resend e-mail on the note page.
Copy a note
In the dashboard, Copy on the note page (or in the list) opens the form already filled with the recipient, items, payments, nature of operation and additional information of that note. You review it and issue: the new note has its own number, key and the date of the moment. Only a normal NF-e is copied (never a return or a complement), and prices are copied as they were, so check them before issuing. Through the agent, nfe_repeat does the same with invoice_id, type (nfe or nfce) and an idempotency_key, and answers NFE_REPEAT_NOT_NORMAL for a note that is not a normal sale.
Webhooks
NF-e events use the same webhook registration and signature as the NFS-e ones (see Webhooks). The data carries documentType: "nfe" and documentId instead of invoiceId; the NFS-e events do not change. List the deliveries of a note with the documentId.
| Event | When |
|---|---|
nfe.document.authorized | The SEFAZ authorized the note. |
nfe.document.rejected · nfe.document.denied | The SEFAZ refused or denied it. |
nfe.document.failed | A failure that needs your look. |
nfe.document.reconciliation_required · nfe.document.manual_review | No answer, being checked; or the check could not confirm. |
nfe.document.cancelled · nfe.document.cancellation_rejected | Cancellation registered or refused. |
nfe.document.corrected | A correction letter was registered. |
nfe.document.documents_ready | The XML and the DANFE are ready to download. |
nfe.document.email_sent · nfe.document.email_failed | The e-mail to the recipient went or failed. |
nfe.inutilization.completed · nfe.inutilization.rejected | An inutilization was accepted or refused. |
nfe.contingency.entered · nfe.contingency.exited | The NF-e of a state started, or stopped, going out through the SVC. The data carries uf, tpAmb, authority (SVCAN or SVCRS) and dhCont; there is no documentId. |
When the SEFAZ of the state is down (SVC)
If the SEFAZ of the state of the company stops answering while the rest of the government still does, Arquivix Notas sends the NF-e through the SEFAZ Virtual de Contingência (SVC-AN or SVC-RS, depending on the state). It is automatic: you do nothing and the request does not change.
- Only a note that was never sent changes: it gets a new key (
tpEmis6 or 7) with the same number and series. A note that may already have reached its SEFAZ keeps its key and waits for it; Arquivix Notas checks it by key and never numbers it again. - The note is valid. The response shows
emissionType6 (SVC-AN) or 7 (SVC-RS),contingencyAtandcontingencyReason; the DANFE says "EMITIDA EM CONTINGÊNCIA SVC". - If it is Arquivix Notas's own network that cannot reach the government, the SVC does not help (it is a government host too) and the note waits as usual.
- The NFS-e and the NFC-e do not use the SVC. Inutilization is only made at the SEFAZ of the state.