---
title: "Generate DC-e"
method: POST
path: "/dce/autorizar"
tags: ["DC-e"]
---

# Generate DC-e

`POST /dce/autorizar`

## Request

- Base URL: `https://queries.test.envia.com`
- URL: `https://queries.test.envia.com/dce/autorizar`
- Auth: HTTP bearer

Authorize a DC-e with the /dce/autorizar endpoint and see request and response examples.

## Request body

- object
  - `ide` object: DC-e identification. Provide the emitter's state using either `uf` (abbreviation) or `cUF` (numeric IBGE code)
    - `uf` string: State abbreviation of the emitter. Converted to numeric IBGE code internally. Either `uf` or `cUF` must be provided
    - `cUF` string: Numeric IBGE state code of the emitter (2 digits). Alternative to `uf`
  - `emit` object, required: Emitter (sender) information — the person or company shipping the package
    - `CNPJ` string: Emitter CNPJ (14 digits). Dots, slashes, and dashes are removed automatically. Required if CPF is not provided
    - `CPF` string: Emitter CPF for individuals (11 digits). Required if CNPJ is not provided
    - `xNome` string, required: Emitter legal name or full name (2-60 chars). Must not have leading or trailing spaces — SEFAZ rejects with cStat=215
    - `endereco` object: Emitter address. If not provided, the address will be reported to FAZENDA as N/A
      - `logradouro` string, required: Street name (2-60 chars)
      - `numero` string, required: Street number (1-60 chars)
      - `complemento` string: Address complement — apartment, suite, etc. (1-60 chars)
      - `bairro` string, required: Neighborhood (2-60 chars). Use 'N/A' if not applicable — cannot be empty
      - `municipio` string: Municipality name. Resolved to IBGE code automatically. Required if `cod_municipio` is not provided
      - `cod_municipio` string: 7-digit IBGE municipality code. Required if `municipio` is not provided
      - `uf` string, required: State abbreviation (2 chars)
      - `cep` string, required: Postal code (CEP, 8 digits, no dashes)
      - `telefone` string: Phone number with area code (6-14 chars)
  - `dest` object, required: Recipient information
    - `CNPJ` string: Recipient CNPJ (14 digits). Required if CPF is not provided
    - `CPF` string: Recipient CPF for individuals (11 digits). Required if CNPJ is not provided
    - `xNome` string: Recipient name (2-60 chars). In homologation (tpAmb=2) SEFAZ overrides this with 'DCE EMITIDA EM AMBIENTE DE HOMOLOGACAO'
    - `endereco` object: Recipient address. Same structure as emit.endereco. If not provided, the address will be reported to FAZENDA as N/A
      - `logradouro` string, required: Street name (2-60 chars)
      - `numero` string, required: Street number (1-60 chars)
      - `complemento` string: Address complement — apartment, suite, etc. (1-60 chars)
      - `bairro` string, required: Neighborhood (2-60 chars)
      - `municipio` string: Municipality name. Resolved to IBGE code automatically
      - `cod_municipio` string: 7-digit IBGE municipality code
      - `uf` string, required: State abbreviation (2 chars)
      - `cep` string, required: Postal code (CEP, 8 digits, no dashes)
      - `telefone` string: Phone number with area code (6-14 chars)
  - `produtos` object[], required: List of declared products (min 1, max 999)
    - `xProd` string, required: Product description (1-120 chars). Avoid special characters like apostrophes
    - `NCM` string, required: NCM code (Nomenclatura Comum do Mercosul). 2 digits for chapter or 8 digits for full code, no dots. SEFAZ validates against MDIC table. If you don't know the NCM code, you can use the [Classify HS code](https://docs.envia.com/reference/classify-hs-code) endpoint to look it up from a product description
    - `qCom` string, required: Product quantity (up to 11 integer digits, 0-4 decimal places)
    - `vUnCom` string, required: Unit price (up to 11 integer digits, 0-4 decimal places). Use dot as decimal separator
    - `vProd` string, required: Total product value (qCom x vUnCom). Exactly 2 decimal places. Max per item R$100,000. Total DC-e max R$200,000
  - `transp` object, required: Transport information
    - `carrierName` string, required: Carrier name as registered in the envia.com catalog. Case-insensitive lookup
  - `infAdic` string: Additional information for the DC-e (1-5000 chars)

## Response `200`

Successful DC-e authorization

- object
  - `success` boolean: Whether the authorization was successful
  - `cStat` string: Status code returned by SEFAZ. 100 = Authorization approved
  - `xMotivo` string: Human-readable description of the authorization result
  - `documentType` string: Type of the returned document
  - `dceNumber` string: Generated DC-e number
  - `dceSerie` string: DC-e series number
  - `dceDate` string, date-time: DC-e emission date and time
  - `dceKey` string: 44-digit DC-e access key
  - `dceValue` string: Total value of the DC-e document
  - `nProt` string: Authorization protocol number from SEFAZ
  - `dhRecbto` string, date-time: Date and time when SEFAZ received and processed the authorization
  - `xml` string: Complete signed XML of the authorized DC-e document. Shown abbreviated in documentation for readability

---

[API](https://skmtc.dev/envia/apis/envia-queries-api.md) - [All operations](https://skmtc.dev/envia/apis/envia-queries-api/llms.txt) - [OpenAPI document](https://skmtc.dev/envia/apis/envia-queries-api/revisions/56f601a52f3f?raw)
