DC-e Brazil

Generate and cancel DC-e (Declaração de Conteúdo Eletrônica) documents for non-commercial shipments within Brazil.

The DC-e (Declaração de Conteúdo Eletrônica) is a Brazilian fiscal document required for non-commercial domestic shipments — such as personal belongings, gifts, donations, or samples — that do not have a Nota Fiscal Eletrônica (NF-e).

Workflow

flowchart TD
    A[Start: Brazil domestic shipment] --> B{What fiscal document<br/>do you have?}

    B -- "NF-e<br/>(commercial)" --> C["Pass NF-e data in xmlData<br/>documentType: nfe<br/>nfeKey, nfeNumber, nfeSerie, nfeDate"]

    B -- "Own DC-e<br/>(already issued)" --> D["Pass DC-e data in xmlData<br/>documentType: dce<br/>dceKey, dceNumber, dceSerie,<br/>dceDate, dceValue"]

    B -- "No fiscal document" --> E["Generate DC-e via Envia<br/>POST /dce/autorizar"]

    E --> F{SEFAZ Response<br/>cStat = 100?}
    F -- Yes --> G["Authorized ✓<br/>Save: dceKey, dceNumber,<br/>dceSerie, dceDate, dceValue"]
    F -- No --> H[Check error and retry]

    G --> I{Will use this DC-e<br/>in a shipment?}
    I -- Yes --> D
    I -- No --> J["Cancel DC-e<br/>POST /dce/cancelar"]

    C --> K["Create shipping label<br/>POST /ship/generate/<br/>Include xmlData in packages"]
    D --> K

    K --> L[Label generated ✓]
    J --> M[DC-e cancelled ✓]

    style A fill:#4A90D9,color:#fff
    style G fill:#2ECC71,color:#fff
    style L fill:#2ECC71,color:#fff
    style M fill:#F39C12,color:#fff
    style H fill:#E74C3C,color:#fff

Steps

  1. Choose your fiscal document — Every Brazil domestic shipment requires a fiscal declaration in xmlData. You have three options:

    • NF-e — If you already have a Nota Fiscal Eletrônica, pass its data with documentType: "nfe".
    • Own DC-e — If you already issued a DC-e externally, pass its data with documentType: "dce".
    • Generate DC-e via Envia — If you don't have a fiscal document, call POST /dce/autorizar and Envia will generate one for you through SEFAZ.
  2. Create a shipping label — Pass the fiscal document fields in the xmlData array inside each package when calling POST /ship/generate/.

  3. Cancel unused DC-e — Any DC-e generated via Envia that is not used or associated with a shipment must be cancelled via POST /dce/cancelar to avoid fiscal inconsistencies with SEFAZ.