We use cookies and similar technologies, including Google Analytics and the Meta Pixel, to improve your experience, measure site traffic and understand signup campaigns. By clicking "Accept", you agree to this use.

Learn more about our privacy practices
Corvo
Português

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_DISABLED until production is turned on (on a self-hosted instance, NFE_PRODUCTION_ENABLED=true; runbook docs/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 (nfceDefaultSeries in PUT /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"
  }
}
FieldWhat it is
recipientOptional. 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_REQUIREDFrom 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.
indPresHow 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[].cardOptional, 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
  }
}
  • qrCode is the text of the QR Code printed on the DANFCE and urlChave is 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/pdf answers the cupom of **80 mm** and GET /v1/invoices/:id/pdf?layout=a4 the same note on an A4 page. GET /v1/invoices/:id/xml answers the authorized XML and POST /v1/invoices/:id/download-url a 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/corrections answers 422 INVOICE_OPERATION_NOT_SUPPORTED. Cancel it and issue another.
  • **Inutilize** numbers with POST /v1/invoices/inutilizations and type: "nfce"; the gaps are in GET /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 with POST /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" in POST /v1/invoices (type: "nfce"). The answer is 201 (not 202) 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 contingency goes off-line by itself. There is nothing to turn on. The old nfceAutoOffline field of PUT /v1/companies/:id/nfe-settings is 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 shows cStat 150 (authorized after the deadline).
  • **Rejected afterwards.** The note is with the consumer already, so it keeps its number, series and key. PUT /v1/invoices/:id accepts only the description, barcode, NCM, CEST, unit and additionalInfo; any other change answers 422 NFCE_CONTINGENCY_FIELD_LOCKED with the paths in details.fields. If it cannot be fixed that way, talk to your accountant.
  • Only states with a QR Code address in Corvo have it (422 NFCE_OFFLINE_NOT_AVAILABLE otherwise). 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

CodeMeaning
NFCE_CONSUMER_ID_REQUIREDThe total reached the limit of the state: give the consumer CPF or CNPJ.
NFCE_DELIVERY_ADDRESS_REQUIREDA delivery sale (indPres 4) needs the consumer id, name and address.
NFCE_IND_PRES_INVALIDindPres must be 1, 4 or 5.
NFCE_CARD_DATA_REQUIRED · NFCE_CARD_BRAND_INVALID · NFCE_CARD_NOT_ALLOWEDProblems in the card data of a payment.
NFCE_SCOPE_NOT_SUPPORTEDNot supported yet: only a normal sale inside the state of the issuer.
NFCE_OFFLINE_NOT_AVAILABLEThe state of the company has no off-line NFC-e yet.
NFCE_CONTINGENCY_FIELD_LOCKEDA correction of an off-line NFC-e changed a field that carries value (details.fields).
INVOICE_OPERATION_NOT_SUPPORTEDFor 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.

EventWhen
nfce.document.authorizedThe SEFAZ authorized the note.
nfce.document.rejected · nfce.document.deniedThe SEFAZ refused or denied it.
nfce.document.failedA failure that needs your look.
nfce.document.reconciliation_required · nfce.document.manual_reviewNo answer, being checked; or the check could not confirm.
nfce.document.cancelled · nfce.document.cancellation_rejectedCancellation registered or refused.
nfce.document.documents_readyThe XML and the DANFCE are ready.
nfce.document.email_sent · nfce.document.email_failedThe e-mail to the consumer went or failed.
nfce.inutilization.completed · nfce.inutilization.rejectedAn inutilization was accepted or refused.
nfce.contingency.deadline_nearAn off-line NFC-e is 20 hours old and still was not transmitted (the limit is 24).