---
title: "Processing flows: NF-e, NFC-e, Taxes and Taxes Payment Forms"
description: "Diagrams of the processing flows for NF-e and NFC-e issuance, tax calculation (Taxes) and tax payment slip generation (Taxes Payment Forms): intake, calculation, numbering, signing, authorization, status query, notification, cancellation, CC-e, number disablement and contingency."
source_url: https://nfe.io/docs/emissao-nfe-nfce-fluxos-de-processamento-en/
last_updated: 2026-09-25
---

# Processing Flows: NF-e, NFC-e, Taxes and Taxes Payment Forms

| | |
|---|---|
| **Product** | NFE.io Product Invoice Issuance (`dfetech-product-invoice-api`) |
| **Document** | 2 of 4: Processing flow design |
| **Version** | 1.0 (2026-09-24) |
| **Audience** | Customers, architecture teams, IT and tax departments |
| **Related documents** | [1 of 4: Architecture](./01-architecture.md) · [3 of 4: Processing, resilience, idempotency and contingency](./03-processing-resilience-and-contingency.md) · [4 of 4: Messaging and queues (Portuguese)](../04-mensageria-e-filas.md) · [Versão em português](../02-fluxos-de-processamento.md) |

## 1. How to read this document

This document contains the flow diagrams for each subproduct. Document 3 explains in writing the timing rules, the retry limits, the idempotency guarantees and the contingency settings.

In the diagrams, the English names (for example, `Issued` or `issued_error`) are the values the customer sees in the invoice `status` field and in the webhook action.

### 1.1 Common view: the life of an invoice

```mermaid
flowchart LR
    A["Customer sends<br/>the request"] --> B["API validates<br/>and records it"]
    B --> C["Invoice creation<br/>and tax calculation"]
    C --> D["Numbering<br/>series and number"]
    D --> E["Access key,<br/>signing and XSD validation"]
    E --> F["Authorization<br/>at SEFAZ"]
    F --> G["Distribution XML<br/>nfeProc"]
    G --> H["Webhook<br/>to the customer"]
    H --> I["Query, XML and<br/>DANFE through the API"]
    F -. "timeout<br/>or duplicate" .-> J["Query by<br/>access key"]
    J -.-> G
```

### 1.2 Invoice states (`status`)

```mermaid
stateDiagram-v2
    [*] --> Created: request accepted and invoice created
    Created --> Processing: numbered, signed and sent
    Processing --> Issued: authorized (cStat 100/150)
    Processing --> IssuedContingency: issued in contingency (EPEC or offline)
    IssuedContingency --> Issued: authorized on later transmission
    IssuedContingency --> Error: rejection or retries exhausted on later transmission
    Created --> Error: refused at creation (validation, registry, taxes)
    Processing --> Error: SEFAZ rejection or retries exhausted
    Processing --> IssueDenied: use denied
    Issued --> Cancelled: cancellation approved
    Error --> Disabled: number disabled
    Issued --> [*]
    Cancelled --> [*]
    Disabled --> [*]
    IssueDenied --> [*]
```

---

## 2. NF-e (model 55)

### 2.1 Request intake (API)

```mermaid
flowchart TD
    R["POST /v2 or /v3/companies/{companyId}/productinvoices"] --> AU{"Valid API key<br/>with the product profile?"}
    AU -- no --> E401["401 or 403"]
    AU -- yes --> MAP{"Well-formed payload?"}
    MAP -- no --> E400["400 with the list of errors"]
    MAP -- yes --> EMP["Looks up the company and the<br/>state tax registration (IE)"]
    EMP --> VAL{"Payload and registry<br/>validation rules"}
    VAL -- failure --> E400
    VAL -- ok --> ID["Generates the invoice<br/>identifier (id)"]
    ID --> BL["Stores the original request<br/>in object storage"]
    BL --> Q["Publishes the creation<br/>step to the queue"]
    Q -- "publish failure" --> E503["503: no invoice was created,<br/>the request can be resent"]
    Q -- ok --> OK["200 with the resource<br/>and the invoice id"]
```

### 2.2 Invoice creation and tax calculation

```mermaid
flowchart TD
    S["Worker receives the creation step"] --> LK["Acquires the invoice lock"]
    LK --> EX{"Does the invoice already exist<br/>in the event store?"}
    EX -- yes --> RES["Resumes from the<br/>step the invoice is in"]
    EX -- no --> CAD{"Company and state tax<br/>registration active and<br/>of type NF-e?"}
    CAD -- no --> REF["Refuses the invoice<br/>(Error, issued_error)"]
    CAD -- yes --> PED["Reads the original request"]
    PED --> BY{"Credit or debit invoice<br/>with calculation skipped?"}
    BY -- yes --> FAC
    BY -- no --> TX{"Did any item request<br/>automatic calculation?"}
    TX -- no --> FAC
    TX -- yes --> CALC["Calls Taxes<br/>ICMS, ST, FCP, DIFAL, IPI,<br/>PIS, COFINS, IBS and CBS"]
    CALC -- "success" --> APL["Applies the calculated<br/>values to the items"]
    APL --> FAC
    CALC -- "rejection (4xx)" --> REF
    CALC -- "unavailable" --> RT["New attempt<br/>with increasing waits"]
    RT -. "limit exhausted" .-> REF
    RT --> CALC
    FAC{"EPEC contingency active<br/>for the state tax registration<br/>or for the UF?"}
    FAC -- yes --> CEP["Flags the invoice for<br/>EPEC issuance"]
    FAC -- no --> CRE
    CEP --> CRE["Creates the aggregate<br/>and writes the events (Created)"]
    CRE --> NX["Next step: numbering"]
```

### 2.3 Numbering, signing and authorization

```mermaid
flowchart TD
    N["Numbering step"] --> SN{"Did the request include<br/>series and number?"}
    SN -- yes --> BAT
    SN -- no --> SEQ["Gets the series of the state tax<br/>registration and the next number<br/>in the sequence"]
    SEQ -- "permanent failure" --> REF["Refuses the invoice (issued_error)"]
    SEQ --> BAT["Records series and number"]
    BAT --> SEND["Sending step"]
    SEND --> EPC{"Invoice flagged<br/>for EPEC?"}
    EPC -- yes --> EPEC["EPEC flow (2.9)"]
    EPC -- no --> KEY["Generates the access key"]
    KEY --> CERT["Gets the A1 certificate"]
    CERT --> VCERT{"Certificate within<br/>its validity period?"}
    VCERT -- no --> ERRC["Error without calling SEFAZ<br/>(issued_error)"]
    VCERT -- yes --> SIGN["Generates the version 4.00 XML,<br/>signs it and validates it against the XSD schema"]
    SIGN --> UP["Stores the signed XML"]
    UP --> AUT["NFeAutorizacao4 with indSinc=1<br/>authorizing SEFAZ of the UF"]
    AUT --> RESP["Response handling (2.4)"]
```

### 2.4 SEFAZ response handling and query by access key

```mermaid
flowchart TD
    R{"SEFAZ response"}
    R -- "authorized: cStat 100 or 150" --> M["nfeProc assembly (2.5)"]
    R -- "batch received without<br/>synchronous result" --> C
    R -- "timeout or<br/>inconclusive response" --> C["Query by access key<br/>NFeConsultaProtocolo4"]
    R -- "204 or 539 with the key<br/>of this same invoice" --> C
    R -- "no connection or<br/>SEFAZ unavailable" --> RT["New sending attempt<br/>with increasing waits"]
    R -- "rejection" --> REJ["Stores the rejection XML<br/>(Error, issued_error with cStat and reason)"]
    R -- "certificate refused<br/>in TLS" --> REJ
    C --> CR{"Query result"}
    CR -- "authorized" --> M
    CR -- "denied: 301, 302, 303" --> DEN["Use denied<br/>(IssueDenied, issued_error with the cStat)"]
    CR -- "217: invoice not found<br/>in the SEFAZ database" --> NF{"Queries made<br/>below the limit?"}
    NF -- yes --> CW["Waits and queries<br/>again"]
    CW --> C
    NF -- no --> REJ
    CR -- "unavailable" --> CW
    RT -. "retry limit" .-> FAIL["Retries exhausted<br/>(Error, issued_failed)"]
```

### 2.5 Distribution XML, notification and DANFE

```mermaid
flowchart LR
    M["Attaches the authorization<br/>protocol to the XML"] --> P["Stores the nfeProc"]
    P --> ST["Invoice Issued"]
    ST --> W{"Does the customer have<br/>a registered webhook?"}
    W -- yes --> WH["Sends product_invoice<br/>issued_successfully"]
    W -- no --> REG["Records that there<br/>was no webhook"]
    WH --> FIN["End of flow"]
    REG --> FIN
    FIN -.-> RM["Query index<br/>updated"]
    FIN -.-> PDF["GET .../pdf generates the DANFE<br/>on the first request<br/>and stores the file"]
```

### 2.6 Cancellation

```mermaid
flowchart TD
    D["DELETE .../productinvoices/{id}?reason="] --> V{"Invoice Issued?<br/>Justification with 15 to 255<br/>characters or empty?"}
    V -- no --> E["400 or 404"]
    V -- yes --> A["204: request accepted"]
    A --> W["Worker signs the event<br/>110111 (Cancellation)"]
    W --> S["Sends it to the authorizing SEFAZ<br/>NFeRecepcaoEvento4"]
    S --> R{"Response"}
    R -- "135, 136 or 155" --> MC["Stores the event XML<br/>(Cancelled, cancelled_successfully)"]
    R -- "rejection" --> ER["cancelled_error with the reason"]
    R -- "unavailable" --> RT["New attempt"]
    RT -. "limit" .-> FL["cancelled_failed"]
    RT --> S
```

### 2.7 Electronic Correction Letter (Carta de Correção Eletrônica, CC-e)

```mermaid
flowchart TD
    P["PUT .../productinvoices/{id}/correctionletter"] --> V{"Invoice Issued?<br/>Text with 15 to 1,000 characters?"}
    V -- no --> E["400 or 404"]
    V -- yes --> A["204: request accepted"]
    A --> W["Worker signs event 110110<br/>with the next sequence number"]
    W --> S["Sends it to the authorizing SEFAZ"]
    S --> R{"Response"}
    R -- "135, 136 or 155" --> OK["Stores the event XML. The CC-e XML and PDF<br/>become available<br/>(cce_successfully)"]
    R -- "rejection" --> ER["cce_error with the reason"]
    R -- "unavailable" --> RT["New attempt"]
    RT -. "limit" .-> FL["cce_failed"]
    RT --> S
```

### 2.8 Number disablement (inutilização)

```mermaid
flowchart TD
    subgraph U1["Per refused invoice (asynchronous)"]
        A1["POST .../{id}/disablement"] --> B1{"Invoice in Error<br/>and with a number?"}
        B1 -- no --> X1["400"]
        B1 -- yes --> C1["204: request accepted"]
        C1 --> D1["Worker signs and sends<br/>NFeInutilizacao4"]
        D1 --> E1{"cStat 102?"}
        E1 -- yes --> F1["Disabled<br/>disabled_successfully"]
        E1 -- no --> G1["disabled_error<br/>or new attempt"]
    end
    subgraph U2["Per range (synchronous)"]
        A2["POST .../productinvoices/disablement<br/>UF, series, start and end number"] --> B2["Locks the range"]
        B2 --> C2["Signs and sends<br/>NFeInutilizacao4"]
        C2 --> D2{"Response"}
        D2 -- "102, 206 or 563<br/>(range already disabled)" --> E2["204"]
        D2 -- "data rejection" --> F2["400"]
        D2 -- "other rejection" --> G2["422"]
        D2 -- "unavailable" --> H2["503"]
    end
```

### 2.9 EPEC contingency

```mermaid
flowchart TD
    subgraph ATIV["Activation"]
        M1["Manual strategy:<br/>customer calls switch-authorizer<br/>with authorizer = EPEC"]
        M2["StateTaxAuthorityStatusUnavailable strategy:<br/>NFE.io operations activates<br/>the UF contingency"]
    end
    M1 & M2 --> NEW["Invoices created from that moment on<br/>are flagged for EPEC"]
    NEW --> G["Generates the NF-e with tpEmis=4,<br/>dhCont and xJust"]
    G --> EV["Signs the EPEC event (110140)<br/>and sends it to the National Environment"]
    EV --> R{"Event registered?"}
    R -- yes --> IC["Invoice IssuedContingency,<br/>EPEC XML available<br/>and DANFE with the contingency mark"]
    IC --> WH["Webhook issued_successfully<br/>with status IssuedContingency"]
    R -- "rejection" --> ER["issued_error"]
    WH --> WAIT["Waits for the contingency to end"]
    WAIT --> BACK{"Contingency ended<br/>(authorizer = Normal or<br/>UF back to normal)?"}
    BACK -- no --> WAIT
    BACK -- yes --> TR["Regularization conducted by<br/>NFE.io operations: transmission<br/>of the same NF-e to the home SEFAZ<br/>(legal deadline: 168 hours)"]
    TR --> AUT["Authorized: invoice Issued"]
```

---

## 3. NFC-e (model 65)

### 3.1 Asynchronous issuance

```mermaid
flowchart TD
    R["POST /v2 or /v3/companies/{companyId}/consumerinvoices"] --> V{"Payload and company<br/>valid?"}
    V -- no --> E400["400"]
    V -- yes --> OK["200 with the invoice id"]
    OK --> W["Worker: checks the IE (active, type NFC-e,<br/>Manual strategy), creates the invoice<br/>and calculates the taxes"]
    W -- "Invalid IE or strategy<br/>other than Manual" --> ERW["Refusal (issued_error)"]
    W --> N["Numbering"]
    N --> BR{"UF contingency circuit breaker<br/>open and IE<br/>enabled for offline?"}
    BR -- yes --> OFF["Issues directly in<br/>offline contingency (3.3)"]
    BR -- no --> S["Key, signing,<br/>QR Code with CSC"]
    S --> A["NFeAutorizacao4<br/>indSinc=1"]
    A --> RS{"Response"}
    RS -- "authorized" --> M["nfeProc, Issued<br/>issued_successfully"]
    RS -- "timeout or<br/>SEFAZ unavailable<br/>and IE enabled" --> OFF
    RS -- "timeout or duplicate<br/>(IE not enabled)" --> C["Query by key"]
    RS -- "SEFAZ unavailable<br/>(IE not enabled)" --> RTN["New attempt<br/>with increasing waits"]
    RTN --> A
    RS -- "rejection" --> ER["Error, issued_error"]
    C --> M
```

### 3.2 Synchronous issuance

```mermaid
sequenceDiagram
    autonumber
    participant CL as Customer system (POS)
    participant API as NFC-e API
    participant TX as Taxes
    participant WK as NFC-e Worker
    participant SF as Authorizing SEFAZ

    CL->>API: POST .../consumerinvoices/sync
    API->>API: Validates payload, company and IE
    API->>TX: Tax calculation (when requested)
    TX-->>API: Taxes per item
    API->>API: Creates the invoice (Created)
    API->>WK: Synchronous authorization (internal call)
    WK->>WK: Locks, numbers, signs, QR Code
    WK->>SF: NFeAutorizacao4 indSinc=1 with a maximum deadline
    alt Authorized within the deadline
        SF-->>WK: cStat 100
        WK-->>API: completed
        API-->>CL: 200 with status Issued
    else Timeout or SEFAZ unavailable, IE enabled for offline
        WK->>WK: Regenerates the invoice with tpEmis=9 (offline)
        WK-->>API: completed in contingency
        API-->>CL: 200 with status IssuedContingency
        WK->>SF: Later transmission (3.4)
    else Timeout or duplicate, IE not enabled for offline
        WK-->>API: still processing
        API-->>CL: 503 (the invoice is still being handled)
        WK->>SF: Query by access key
    else SEFAZ unavailable, IE not enabled for offline
        WK->>WK: Refuses the invoice
        API-->>CL: 200 with status Error
    else Rejection
        SF-->>WK: rejection cStat
        API-->>CL: 200 with status Error and the reason
    end
```

### 3.3 Offline contingency (tpEmis=9)

```mermaid
flowchart TD
    subgraph REA["Reactive mode"]
        T1["Normal authorization ends in<br/>timeout or unavailability"] --> C1["Counts one more failure<br/>in the UF circuit breaker"]
        C1 --> H1{"IE enabled<br/>for offline?"}
        H1 -- no --> Q1["Follows the normal flow:<br/>query by key (timeout)<br/>or new attempt (unavailability)"]
        H1 -- yes --> G1["Stores the abandoned key (tpEmis=1)<br/>and regenerates the invoice with tpEmis=9,<br/>dhCont = now"]
    end
    subgraph PRO["Proactive mode"]
        B1{"5 consecutive failures (timeout<br/>or unavailability) in the same UF?"} -- yes --> OP["UF circuit breaker open"]
        OP --> H2{"IE enabled<br/>for offline?"}
        H2 -- yes --> G2["Issues directly with tpEmis=9,<br/>dhCont = circuit breaker opening time"]
        H2 -- no --> N2["Normal attempt"]
    end
    G1 & G2 --> X["New key, signing,<br/>offline QR Code with CSC"]
    X --> IC["Invoice IssuedContingency<br/>NFC-e DANFE in contingency"]
    IC --> WH["issued_contingency (asynchronous)<br/>or 200 IssuedContingency (synchronous)"]
    WH --> TR["Later transmission (3.4)"]
    OK1["Any normal authorization<br/>or authorized retransmission in the UF"] --> CL["Circuit breaker closed"]
```

### 3.4 Later transmission of contingency invoices

```mermaid
flowchart TD
    S["First attempt immediately,<br/>then every 10 minutes"] --> A["Sends the already signed offline XML"]
    A --> R{"Response"}
    R -- "authorized" --> M["nfeProc, Issued<br/>issued_successfully<br/>closes the UF circuit breaker"]
    R -- "duplicate: the abandoned<br/>tpEmis=1 invoice was authorized" --> RC["Reconciles with the original invoice:<br/>the tpEmis=1 key prevails"]
    RC --> Q["Queries by key<br/>and assembles the nfeProc"]
    R -- "timeout or<br/>unavailable" --> S
    R -- "rejection" --> ER["Error, issued_error:<br/>the taxpayer must regularize it"]
    S -. "retry limit" .-> FL["Error, issued_failed"]
```

### 3.5 Cancellation and number disablement

The flows follow the same steps as the NF-e (sections 2.6 and 2.8), with the `consumer_invoice` event type. Cancellation requires an authorized invoice (`Issued`): an invoice in `IssuedContingency` that has not yet been transmitted can only be cancelled after it is authorized. The NFC-e has no correction letter (Carta de Correção).

---

## 4. Taxes: tax calculation

### 4.1 Per-item calculation

```mermaid
flowchart TD
    R["POST /tax-rules/{tenantId}/engine/calculate<br/>or internal call from NF-e/NFC-e"] --> AU{"Route account =<br/>API key account?"}
    AU -- no --> E403["403"]
    AU -- yes --> P["For each item: looks up the<br/>registered product (SKU and origin)"]
    P --> PV{"Product inactive, or<br/>product not registered<br/>and without NCM?"}
    PV -- yes --> E400["400"]
    PV -- no --> CH{"Recent calculation stored<br/>and eligible for reuse?"}
    CH -- "yes and within<br/>validity" --> RB["Recalculates bases and values<br/>with the request data"]
    CH -- no --> ENG["Queries the tax<br/>rules engine"]
    ENG -- success --> SV["Stores the result<br/>for reuse"]
    ENG -- "engine failure" --> FB{"Is there a stored result<br/>(even expired) or a CST 40<br/>rule registered on the product<br/>that covers all items?"}
    FB -- yes --> RB
    FB -- no --> E5["422, 500 or 503<br/>depending on the cause:<br/>nothing is presumed"]
    SV --> CT
    RB --> CT["Applies the product's<br/>custom taxation<br/>(customTax), when present"]
    CT --> CB{"Custom CST 40/41,<br/>engine returns cBenef and the product<br/>does not provide its own?"}
    CB -- yes --> E422["422 before issuance,<br/>avoiding the SEFAZ rejection"]
    CB -- no --> OUT["200 with CFOP, CST/CSOSN,<br/>bases, rates and amounts<br/>of ICMS, ST, FCP, DIFAL,<br/>IPI, PIS and COFINS per item"]
```

IBS and CBS are calculated in a separate call, made by the NF-e and the NFC-e for the items that request the official calculation (section 6).

### 4.2 Product registration

```mermaid
flowchart LR
    C["POST /{tenantId}/products"] --> CR["Product Created"]
    CR --> V["Asynchronous validation"]
    V --> T{"Does it have custom<br/>taxation (customTax)?"}
    T -- no --> AC["Active"]
    T -- yes --> PE["CustomTaxPending:<br/>registration and validation<br/>of the rules in the engine"]
    PE --> CK{"Rules verified?"}
    CK -- yes --> AC
    CK -- "not yet" --> PE
    CK -- "failure" --> ER["Error"]
    PE & AC & ER --> WH["Webhook product_tax"]
```

---

## 5. Taxes Payment Forms: DIFAL payment slips

```mermaid
flowchart TD
    R["POST /v1/tax-payment-forms/{accountId}/{companyId}/gnre<br/>with the NF-e id"] --> L["Reads the authorized NF-e<br/>and the XML"]
    L --> V{"Interstate operation<br/>with vICMSUFDest greater than zero?"}
    V -- no --> NN0["400"]
    V -- yes --> UF{"Destination UF"}
    UF -- "ES" --> DUA["DUA at SEFAZ-ES"]
    UF -- "SP" --> NS["Not supported (400)"]
    UF -- "other UFs" --> GN["GNRE batch on the GNRE Portal"]
    DUA & GN --> ST["Created → Prepared →<br/>Transmitted → Generated"]
    ST --> OUT["Payment slip PDF"]
    ST -- "amount below the minimum<br/>or zero total" --> NN["ErrorNotNeeded:<br/>payment slip not required"]
    ST -- "processing failure" --> RT["New attempt every 10 s,<br/>up to 100 times"]
    RT --> ST
    OUT & NN --> WH["Webhook tax_payment_form"]
```

---

## 6. Relationship between NF-e, NFC-e and Taxes

```mermaid
sequenceDiagram
    autonumber
    participant CL as Customer
    participant INV as NF-e or NFC-e
    participant TX as Taxes
    participant ENG as Rules engine
    participant IBS as IBS/CBS calculation
    participant SF as SEFAZ

    CL->>INV: Issuance request with taxDetermination<br/>on the items and/or ibscbs.calculationMode = OfficialService
    INV->>INV: Validation and recording
    Note over INV: NF-e: in the worker, at the creation step<br/>Synchronous NFC-e: in the API itself<br/>Asynchronous NFC-e: in the worker
    INV->>TX: Per-item calculation (ICMS, ST, FCP, DIFAL, IPI, PIS, COFINS)
    TX->>ENG: Scenario rules (when there is no reuse)
    ENG-->>TX: CST, rates, bases
    TX-->>INV: Calculated taxes
    INV->>TX: IBS and CBS calculation (items with official calculation)
    TX->>IBS: General regime
    IBS-->>TX: Bases and amounts
    TX-->>INV: IBS and CBS
    INV->>INV: Applies the values and creates the invoice
    INV->>SF: Authorization
    SF-->>INV: Protocol
    INV-->>CL: Webhook
```

- The NF-e and the NFC-e call Taxes **only** when the customer requests automatic calculation on the items. Without that request, they use the values in the payload as received.
- Credit invoices and debit invoices of types 01, 02, 03, 05 and 08 skip the calculation.
- Taxes does not communicate with SEFAZ. The issuance flow does not call Payment Forms: Payment Forms reads the already authorized NF-e when the customer requests the payment slip.
