NFC-e: consumer sale
Issue the NFC-e (model 65), the note for a sale to the final consumer, through the same /v1/invoices routes, in test mode (homologação), starting in SP.
The NFC-e is the note of the sale at the counter, to a consumer who often gives no name. It lives in the same routes as the NF-e and the NFS-e: /v1/invoices. Send type: "nfce" to create or validate one, and ?type=nfce to list. A request without type is still an NFS-e. NFS-e and NF-e do not change.
Availability and accreditation
- **Open to everyone.** The NFC-e needs no release: every account issues it in test. In production (live) the answer is
422 NFE_PRODUCTION_DISABLEDuntil production is turned on (on a self-hosted instance,NFE_PRODUCTION_ENABLED=true; runbookdocs/fiscal/runbooks/nfce-homologacao.md). - **Accreditation at the SEFAZ.** The state registration (IE) of the company must be accredited to issue NFC-e at its state. It is done once, on the SEFAZ site, by the company or its accountant. Without it the SEFAZ refuses the notes.
- **No CSC needed.** Corvo uses the QR Code v3 (online), which does not take the CSC (the security code that older QR Codes asked for) nor its id. You have nothing to register or keep.
- **Series.** The NFC-e has its own series (
nfceDefaultSeriesinPUT /v1/companies/:id/nfe-settings, default 1) and its own numbering.
Issue
Validate with POST /v1/invoices/validate (dry-run, same body) and issue with POST /v1/invoices and an Idempotency-Key, as in the NF-e. The body has no natOp and no recipient address, unless the sale is a delivery.
Request body
{
"type": "nfce",
"companyId": "5b8b6a0e-3c6f-4f4e-9a1b-0d7a6d5c2e11",
"recipient": { "taxId": "123.456.789-09" },
"indPres": 1,
"items": [
{
"code": "CAFE1",
"description": "Café coado",
"ncm": "09012100",
"cfop": "5102",
"unit": "UN",
"quantity": 2,
"unitPrice": 8
}
],
"payments": [
{
"tPag": "03",
"amount": 16,
"card": { "tpIntegra": 2, "tBand": "01" }
}
]
}Answer 202
{
"data": {
"type": "nfce",
"id": "9d1c3b8e-5f2a-4a53-b0a4-7c1d7a2e4f10",
"status": "queued"
}
}| Field | What it is |
|---|---|
recipient | Optional. The consumer may stay anonymous. taxId (CPF or CNPJ), name and email are all optional; with an e-mail the XML and the DANFCE are sent after the authorization (sendEmail). |
limit / NFCE_CONSUMER_ID_REQUIRED | From the limit of the state (R$ 10.000,00 by default, compared in cents: R$ 9.999,99 goes, R$ 10.000,00 needs the CPF or CNPJ) the identification is required. |
indPres | How the sale happened: 1 in person at the store (default), 4 delivery, 5 in person outside the store. 4 needs the consumer taxId, name and address, otherwise NFCE_DELIVERY_ADDRESS_REQUIRED before any number is used. |
payments[].card | Optional, only for tPag 03 (credit), 04 (debit) and 17 (Pix): tpIntegra (1 integrated, 2 not, the default), cnpj of the card operator, tBand (brand, 2 digits) and cAut (authorization). Integrated needs cnpj and cAut (NFCE_CARD_DATA_REQUIRED). Another means with card data answers NFCE_CARD_NOT_ALLOWED. |
Read, QR Code and files
GET /v1/invoices/:id
{
"data": {
"type": "nfce",
"id": "9d1c3b8e-5f2a-4a53-b0a4-7c1d7a2e4f10",
"status": "authorized",
"number": 12,
"series": 1,
"accessKey": "35261111222333000181650010000000121234567891",
"qrCode": "https://www.nfce.fazenda.sp.gov.br/qrcode?p=...",
"urlChave": "https://www.nfce.fazenda.sp.gov.br/consulta",
"documentsReady": true
}
}qrCodeis the text of the QR Code printed on the DANFCE andurlChaveis the page where the consumer looks the note up. Both come with the authorized note.- The **DANFCE** is the printed receipt:
GET /v1/invoices/:id/pdfanswers the cupom of **80 mm** andGET /v1/invoices/:id/pdf?layout=a4the same note on an A4 page.GET /v1/invoices/:id/xmlanswers the authorized XML andPOST /v1/invoices/:id/download-urla temporary link. - In test mode the first item shows the text
NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL, as the SEFAZ demands. Your saved item is not changed.
Cancel, no correction letter, inutilize
- **Cancel** with
POST /v1/invoices/:id/cancel(justification of 15 to 255 characters). The NFC-e is meant to be cancelled **within 30 minutes** of the authorization; after that, the SEFAZ may refuse and the answer says so. Talk to your accountant in that case. - **There is no correction letter (CC-e)** for the NFC-e:
POST /v1/invoices/:id/correctionsanswers422INVOICE_OPERATION_NOT_SUPPORTED. Cancel it and issue another. - **Inutilize** numbers with
POST /v1/invoices/inutilizationsandtype: "nfce"; the gaps are inGET /v1/invoices/number-gaps?type=nfce. In SP the suggestion stays on until the accountant confirms the rules of the state. - A rejected NFC-e is fixed with
PUT /v1/invoices/:id(same number) or given up withPOST /v1/invoices/:id/discard, like the NF-e.
Off-line NFC-e (contingency)
When the SEFAZ cannot be reached, the sale at the counter cannot wait. In **off-line contingency** (tpEmis 9) Corvo numbers, signs and answers at once; the note is sent to the SEFAZ later, within **24 hours**.
- **Ask for it** with
contingency: "offline"inPOST /v1/invoices(type: "nfce"). The answer is201(not202) with{ type, id, status: "contingency_pending", accessKey, qrCode, xmlUrl, pdfUrl }: the XML and the DANFCE (with the notice "EMITIDA EM CONTINGÊNCIA") are ready to hand over. - **Or let Corvo decide.** It is always on: when the SEFAZ cannot be reached, a request without
contingencygoes off-line by itself. There is nothing to turn on. The oldnfceAutoOfflinefield ofPUT /v1/companies/:id/nfe-settingsis deprecated and ignored. - **Transmission.** Corvo sends the very same signed XML as soon as the SEFAZ answers. After **20 hours** without success you get the webhook
nfce.contingency.deadline_near(and an e-mail to the account owner, in production). After 24 hours it is still sent and the SEFAZ showscStat150 (authorized after the deadline). - **Rejected afterwards.** The note is with the consumer already, so it keeps its number, series and key.
PUT /v1/invoices/:idaccepts only the description, barcode, NCM, CEST, unit andadditionalInfo; any other change answers422NFCE_CONTINGENCY_FIELD_LOCKEDwith the paths indetails.fields. If it cannot be fixed that way, talk to your accountant. - Only states with a QR Code address in Corvo have it (
422NFCE_OFFLINE_NOT_AVAILABLEotherwise). The QR Code of an off-line note carries the signature of the issuer (RSA SHA-1 with the A1).
Errors of the NFC-e
| Code | Meaning |
|---|---|
NFCE_CONSUMER_ID_REQUIRED | The total reached the limit of the state: give the consumer CPF or CNPJ. |
NFCE_DELIVERY_ADDRESS_REQUIRED | A delivery sale (indPres 4) needs the consumer id, name and address. |
NFCE_IND_PRES_INVALID | indPres must be 1, 4 or 5. |
NFCE_CARD_DATA_REQUIRED · NFCE_CARD_BRAND_INVALID · NFCE_CARD_NOT_ALLOWED | Problems in the card data of a payment. |
NFCE_SCOPE_NOT_SUPPORTED | Not supported yet: only a normal sale inside the state of the issuer. |
NFCE_OFFLINE_NOT_AVAILABLE | The state of the company has no off-line NFC-e yet. |
NFCE_CONTINGENCY_FIELD_LOCKED | A correction of an off-line NFC-e changed a field that carries value (details.fields). |
INVOICE_OPERATION_NOT_SUPPORTED | For example, a correction letter on a NFC-e. |
The other codes (NFE_VALIDATION_FAILED, COMPANY_NFE_INCOMPLETE, UF_NOT_ENABLED, NFE_PRODUCTION_DISABLED, IDEMPOTENCY_KEY_REUSED...) are the ones of the NF-e: see NF-e: errors and hints.
Webhooks
The NFC-e uses the same registration and signature as the other webhooks. The data carries documentType: "nfce" and documentId.
| Event | When |
|---|---|
nfce.document.authorized | The SEFAZ authorized the note. |
nfce.document.rejected · nfce.document.denied | The SEFAZ refused or denied it. |
nfce.document.failed | A failure that needs your look. |
nfce.document.reconciliation_required · nfce.document.manual_review | No answer, being checked; or the check could not confirm. |
nfce.document.cancelled · nfce.document.cancellation_rejected | Cancellation registered or refused. |
nfce.document.documents_ready | The XML and the DANFCE are ready. |
nfce.document.email_sent · nfce.document.email_failed | The e-mail to the consumer went or failed. |
nfce.inutilization.completed · nfce.inutilization.rejected | An inutilization was accepted or refused. |
nfce.contingency.deadline_near | An off-line NFC-e is 20 hours old and still was not transmitted (the limit is 24). |