The Webmania® REST API issues the DC-e at SEFAZ, the state tax authority. It creates the XML file and the DACE (the printed summary of the DC-e) that travels with the goods. It sends you the result by notification, and it lets you look up and cancel each declaration. To start, read the Quick guide. To issue other document types, see all the APIs.
What is the DC-e? The electronic content declaration (Declaração de Conteúdo Eletrônica) replaces the paper content declaration. It goes with goods in transport when the sender is not required to issue a tax document, such as an NF-e (electronic invoice) or an NFC-e (consumer receipt). When an invoice is required, the DC-e does not replace it:
Individuals or companies that do not pay ICMS (the state sales tax). The sender's data goes in the emitente object, and the receiver's data goes in cliente.
After SEFAZ authorizes the declaration, Webmania creates the DACE (Declaração Auxiliar de Conteúdo Eletrônica), the printed summary of the DC-e. It must travel with the goods during transport.
Brazilian tax terms you will see. They keep their Brazilian names in the payload and on the DC-e:
SEFAZ: the state tax authority. It authorizes each DC-e and answers with a status code; 100 = authorized.
ICMS: the state sales tax on goods. The DC-e is for senders that do not pay it, such as individuals.
NCM: the 8-digit product classification code of Mercosur. Field ncm of each item in itens.
CNPJ / CPF: the company ID (14 digits) and the individual taxpayer ID (11 digits) of the issuer and of the customer.
Every term in plain English: glossary of Brazilian tax terms.
Send every API request over encrypted HTTPS to the URL https://api.webmania.com.br. The /2/ prefix means that you are using version 2.0 of the API.
| URL | HTTP Verb | Function |
|---|---|---|
/2/dce/emissao | POST | Issue a DC-e |
/2/dce/emissao/csv | POST | Batch issuing by CSV |
/2/dce/consulta/{identifier} | GET | Look up a DC-e by UUID (36 characters) or by access key (44 characters) |
/2/dce/cancelar | PUT | Cancel a DC-e |
Responses are in JSON. Send Authorization: Bearer YOUR_ACCESS_TOKEN in every call, and Content-Type: application/json in calls that have a body. See Authentication.
How to integrate the DC-e:
Authorization header. /2/dce/emissao, with ambiente = 2 (sandbox) for tests. The response returns the uuid of the DC-e. Store it in your system. url_notificacao when the DC-e is authorized, rejected or canceled. Every DC-e gets a uuid as soon as the API accepts the request. From then on, it goes through the statuses below. They appear in the response, in the lookup and in the notifications:
processando and contingencia statuses are not notified and do not prove authorization. Follow the DC-e through the lookup, without issuing it again.| Status | What it means | What to do |
|---|---|---|
processando | SEFAZ has not returned the result of the DC-e yet. | Wait for the notification or look up the DC-e. Do not issue it again. |
contingencia | SEFAZ is offline. Webmania resends the DC-e automatically when SEFAZ is back, after checking with SEFAZ first. | Follow the same uuid, without issuing it again. See Contingency mode. |
aprovado | SEFAZ authorized the DC-e. The XML and the DACE are available. | Print the DACE so it travels with the goods. If the shipment does not happen, cancel it. |
reprovado | SEFAZ rejected the DC-e. motivo has the response. | Fix the data shown in motivo and issue a new DC-e. |
cancelado | SEFAZ accepted the cancellation. | Do not use this DC-e for transport. |
Take this reference to your AI assistant, integrate the API with an official SDK, or start from the ready-made modules and examples.
Send an AI the section index of this reference: it reads the index and fetches only the sections it needs, in Markdown. The Markdown is in Portuguese; the assistant can answer in English.
Official open-source SDKs on GitHub to integrate the Webmania APIs in the language of your project. Each repository includes installation, examples and the operations it covers.
Node.js / TypeScript Available
git clone https://github.com/
Python Available
git clone https://github.com/
PHP Available
git clone https://github.com/
Perl Available
git clone https://github.com/
Go Available
git clone https://github.com/
C Available
git clone https://github.com/
C++ Available
git clone https://github.com/
Lua Available
git clone https://github.com/
Dart Available
git clone https://github.com/
R Available
git clone https://github.com/
Java Available
git clone https://github.com/
Kotlin Available
git clone https://github.com/
Scala Available
git clone https://github.com/
Clojure Available
git clone https://github.com/
Ruby Available
git clone https://github.com/
.NET (C#) Available
git clone https://github.com/
PowerShell Available
git clone https://github.com/
Elixir Available
git clone https://github.com/
Rust Available
git clone https://github.com/
Haskell Available
git clone https://github.com/
Swift Available
git clone https://github.com/
Test the DC-e REST API without writing a line of code, and speed up your integration with the official Webmania® tools.
To use the API, authenticate every request with an HTTP header. Use the Authorization header in this format:
Authorization: Bearer {Access-Token} You find the Access-Token of API 2.0 in the Webmania® Panel. Include it in every request.
Keep your credentials safe. Never publish the Access Token in the source code of a website, app or system where third parties can easily read it.
For mobile apps (iOS and Android), we recommend that you call the API from your server (back end). The app only sends the request to your server, and your server does the processing.
The responses of issuing, lookup and cancellation are in JSON, without a data wrapper. Fields with a null value are left out. The XML and DACE download returns the file itself, as described in Download XML and PDF.
| Code | Meaning | Success | Description |
|---|---|---|---|
200 | OK | Response of issuing, lookup or cancellation (POST, GET and PUT). It is also the status of validation and business errors, which return error. | |
401 | Unauthorized | Authentication failed. Check the access token you sent. | |
403 | Forbidden | Access denied. You do not have permission for this operation. | |
404 | Not Found | Route or resource not found. A lookup of a DC-e that does not exist can also return HTTP 200 with error. | |
429 | Too Many Requests | Request limit exceeded. Wait the interval given in the Retry-After header, when it is present. See Request limits. |
HTTP 200 does not confirm tax authorization. How to identify each result:
| Situation | HTTP | Body |
|---|---|---|
| Missing or invalid field in the request | 200 | {"error": "…"}, without uuid |
| DC-e accepted, no result from SEFAZ yet | 200 | status equal to processando or contingencia |
| DC-e authorized | 200 | status equal to aprovado, with xml and dace |
| DC-e rejected by SEFAZ | 200 | status equal to reprovado, with the response in motivo |
Example of an HTTP 200 response to a request with a validation error (the message says that the ambiente parameter is required):
{
"error": "Parâmetro obrigatório: ambiente."
}
To keep your platform up to date, Webmania® sends an automatic notification for each result of the DC-e. With them, you do not need a routine that polls the API. Wait for the webhook and update the DC-e in your system when it arrives.
The notification is sent by POST, in JSON, to the URL given in url_notificacao when you issue the DC-e. Without this parameter, it goes to the notification URL registered for the company.
| Notified status | When it is sent |
|---|---|
aprovado | SEFAZ authorized the DC-e. The body has the chave, the xml and the dace. |
reprovado | SEFAZ rejected the DC-e. The body has the motivo (reason). |
cancelado | SEFAZ accepted the cancellation. The body has the xml_cancelamento. |
processando and contingencia statuses are not notified. In these cases, do not issue the DC-e again. Wait for the next notification or check the result in the lookup.What is the UUID? The UUID (Universally Unique Identifier) is a unique 36-character identifier, in the 8-4-4-4-12 format, that Webmania assigns to each DC-e.
It is created as soon as our API accepts the request, that is, after our validations and before anything is sent to SEFAZ. So the UUID exists whatever the status of the DC-e at SEFAZ, even when the DC-e is rejected or canceled.
Once created, the UUID is permanent. It does not change on retries, contingency mode or resending. The access key is a different field and can change. So use the UUID, not the access key, as your reference in your database.
The notification body has the same format as the DC-e lookup:
| Parameter | Type | Description |
|---|---|---|
ID | string | Control ID you sent when issuing (when you sent one). |
uuid | string | Unique identifier of the DC-e. |
chave | string | Access key of the DC-e at SEFAZ. |
serie | number | Series of the DC-e. |
numero | number | Number of the DC-e. |
status | string | Current status of the DC-e: aprovado, reprovado or cancelado. See the lifecycle. |
motivo | string | Reason for the returned status. |
modelo | string | Fixed value dce. |
xml | string | URL of the authorized XML. |
xml_cancelamento | string | URL of the cancellation XML (only when the status is cancelado). |
dace | string | URL of the DACE. |
log | object or empty array | Data of the operation (sending or cancellation). With named fields, it is an object. When empty, it is []. Its structure depends on the SEFAZ response. |
The notification is sent with the POST method, in the application/json format:
-X POST \
-header "Content-type: application/json" \ Example of a notification for an authorized DC-e:
{
"ID": "PED-123",
"uuid": "00000000-0000-0000-0000-000000000000",
"chave": "00000000000000000000000000000000000000000000",
"serie": 1,
"numero": 123,
"status": "aprovado",
"motivo": "Autorizado o uso do DC-e",
"modelo": "dce",
"xml": "https://api.webmania.com.br/xmldce/[chave]",
"dace": "https://api.webmania.com.br/dace/[chave]",
"log": {
"cStat": 100,
"xMotivo": "Autorizado o uso do DC-e"
}
} Issuing sends the declaration to SEFAZ. When SEFAZ authorizes it, Webmania creates the XML and the DACE, which travels with the goods during transport. One request issues one DC-e. To issue many at once, use batch issuing by CSV.
To issue a DC-e, send a POST request to the URL /2/dce/emissao, with a JSON body.
How to build the request:
ambiente (2 for tests in the sandbox), the url_notificacao and, if you want, your own control ID. emitente object: one single ID (cnpj, cpf or identificacao_alternativa), the name and the address. cliente object, with the same ID rule as the sender. itens, from 1 to 999 items, with description, NCM (the Mercosur product classification code), quantity and unit value. transporte.modalidade: Correios (Brazilian postal service), own transport or a carrier company. Request example:
curl -X POST https://api.webmania.com.br/2/dce/emissao \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ID": "PED-123",
"ambiente": 2,
"url_notificacao": "https://suaaplicacao.com.br/webhook/dce",
"emitente": {
"cnpj": "12345678000195",
"razao_social": "EMPRESA EMISSORA LTDA",
"logradouro": "Rua A",
"numero": "100",
"bairro": "Centro",
"codigo_municipio": "4106902",
"municipio": "Curitiba",
"uf": "PR",
"cep": "80000000"
},
"cliente": {
"cnpj": "12345678000195",
"razao_social": "CLIENTE LTDA",
"logradouro": "Rua B",
"numero": "200",
"bairro": "Centro",
"codigo_municipio": "3550308",
"municipio": "São Paulo",
"uf": "SP",
"cep": "01001000"
},
"itens": [
{
"descricao": "Frete",
"ncm": "99000000",
"quantidade": 1,
"valor_unitario": 100.00
}
],
"transporte": {
"modalidade": "0"
},
"informacoes_adicionais": "Observações gerais"
}' Example of an HTTP 200 response for an authorized DC-e. The fields are described in Notification fields. The content of log depends on the SEFAZ response:
{
"ID": "PED-123",
"uuid": "00000000-0000-0000-0000-000000000000",
"chave": "00000000000000000000000000000000000000000000",
"serie": 1,
"numero": 123,
"status": "aprovado",
"motivo": "Autorizado o uso do DC-e",
"modelo": "dce",
"xml": "https://api.webmania.com.br/xmldce/[chave]",
"dace": "https://api.webmania.com.br/dace/[chave]",
"log": {
"cStat": 100,
"xMotivo": "Autorizado o uso do DC-e"
}
} If the response returns processando or contingencia, the DC-e has no final result yet. Wait for the notification, without issuing it again. The statuses are listed in DC-e lifecycle.
Batch issuing takes a CSV file with up to 5,000 DC-e. It issues each line with the same rules as a single DC-e. Do not send dces: the API reads the list from the CSV.
To issue a batch, send a POST request to the URL /2/dce/emissao/csv, with the same Authorization header and a JSON body.
| Parameter | Required | Type | Description |
|---|---|---|---|
ambiente | Yes | number | 1 = Production; 2 = Sandbox. Applies to every line. |
csv | Yes | string | Content of the CSV file, encoded in valid Base64, with at least one valid document. |
file_name | Yes | string | File name. The API normalizes it to lowercase and replaces each run of non-alphanumeric characters (including the dot of the extension) with a hyphen. |
The response describes the batch, not each DC-e:
| Field | What it contains |
|---|---|
uuid | ID of the import. It is not the UUID of a DC-e. |
modelo | Fixed value dce_csv. |
status | Status of the batch. |
qtd_rps | Number of documents in the file. |
processado | Number already processed. |
valor_total | Sum of the documents, as text with two decimal places. |
Processing is asynchronous: an accepted batch does not mean that the DC-e were authorized. Each DC-e issued follows the lifecycle of a single DC-e.
Top-level fields of the issuing body. Fields with a link open the section of each object.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
ID | Optional | string | up to 100 | Control ID of your application, up to 100 characters. It is also accepted as id. The response and the notification use ID. |
ambiente | Required | number | 1 | Issuing environment.1 = Production |
url_notificacao | Optional | url | up to 500 | URL that receives automatic status notifications. |
origem | Optional | string | - - - | Source of the integration. Accepted values: api, webmaniabr, woocommerce, prestashop, opencart and magento. |
solicitacao | Optional | JSON string | up to 2000 | String of valid JSON with the issuing request data of the Fisco (tax authority), up to 2,000 characters. It is optional and can be null.Used only for companies set up as Fisco. For other issuer types, the field is ignored. |
emitente | Required | object | - - - | Object with the issuer's data.For companies set up with issuer type 2, the company's registered data fills the missing fields before validation. See the Issuer section for the other rules. |
cliente | Required | object | - - - | Object with the data of the customer (recipient).See the Customer section for the conditional rules. |
itens | Required | array | 1-n | List of goods transported (from 1 to 999 items).API validation limits the total of the items to R$ 100,000,000.00. This technical limit does not replace the rules of SEFAZ. |
transporte | Required | object | - - - | Object with the transport data.The |
informacoes_adicionais | Optional | string | 1-5000 | General additional information of the DC-e.See also the note parameters in the Additional information section. |
The issuer is the individual or company that sends the goods to the recipient. Send its data in the emitente object.
To identify the issuer, send only one of these options: cnpj (CNPJ, the 14-digit company ID), cpf (CPF, the 11-digit individual taxpayer ID) or identificacao_alternativa. The name field depends on the type of ID:
razao_socialnome_completo| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cnpj | Conditionally required | string | 14 | CNPJ (company ID) of the issuer.Send only one: |
cpf | Conditionally required | string | 11 | CPF (individual taxpayer ID) of the issuer, digits only.Send only one: |
identificacao_alternativa | Conditionally required | string | 2-20 | ID for issuers without a CPF or CNPJ (foreigners, Indigenous people, quilombolas, members of traditional Afro-Brazilian communities). |
razao_social | Required with CNPJ | string | 2-60 | Legal company name (company).Required when |
nome_completo | Required with CPF/alternative ID | string | 2-60 | Full name (individual).Required when |
logradouro | Required, auto-filled from the CEP | string | 2-60 | Street of the address. |
numero | Required | string | 1-60 | Street number of the address.Send |
complemento | Optional | string | 1-60 | Address complement (suite, floor, unit). |
bairro | Required, auto-filled from the CEP | string | 2-60 | Neighborhood of the address. |
codigo_municipio | Required, auto-filled from the CEP | string | 7 | IBGE city code (7 digits). |
municipio | Required, auto-filled from the CEP | string | 2-60 | City name. |
uf | Required, auto-filled from the CEP | string | 2 | State abbreviation (for example SP, RJ, MG). |
cep | Required | string | 8 | CEP (postal code) with 8 digits, without a mask. |
telefone | Optional | string | 7-12 | Phone number with area code, digits only. |
Auto-fill from the CEP: the API fills in logradouro, bairro, codigo_municipio, municipio and uf automatically when the cep you send is valid and can be found.
Example of a company issuer:
{
"emitente": {
"cnpj": "00000000000000",
"razao_social": "Empresa Logistica Ltda",
"logradouro": "Avenida Paulista",
"numero": "1000",
"bairro": "Bela Vista",
"codigo_municipio": "3550308",
"municipio": "Sao Paulo",
"uf": "SP",
"cep": "01310100",
"telefone": "1130000000"
}
} The customer is the recipient of the goods. Send its data in the cliente object.
The ID rule is the same as for the issuer: send only one of the options (cnpj, cpf or identificacao_alternativa), with the matching name field.
Customer outside Brazil: send a codigo_pais other than 1058 and the country name in pais. The API then sets codigo_municipio = 9999999, cep = 99999999 and uf = EX automatically. For Brazil, EX and the city code 9999999 are rejected.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cnpj | Conditionally required | string | 14 | CNPJ (company ID) of the customer.Send only one: |
cpf | Conditionally required | string | 11 | CPF (individual taxpayer ID) of the customer, digits only.Send only one: |
identificacao_alternativa | Conditionally required | string | 2-20 | ID for recipients without a CPF or CNPJ (foreigners, Indigenous people, quilombolas). |
razao_social | Required with CNPJ | string | 2-60 | Legal company name (company).Required when |
nome_completo | Required with CPF/alternative ID | string | 2-60 | Full name (individual).Required when |
email | Optional | up to 80 | Email of the recipient, to receive the document. | |
logradouro | Required, auto-filled from the CEP | string | 2-60 | Street of the address. |
numero | Required | string | 1-60 | Street number of the address.Send |
complemento | Optional | string | 1-60 | Address complement (suite, floor, unit). |
bairro | Required, auto-filled from the CEP | string | 2-60 | Neighborhood of the address. |
codigo_municipio | Required, auto-filled from the CEP | string | 7 | IBGE city code (7 digits). |
municipio | Required, auto-filled from the CEP | string | 2-60 | City name. |
uf | Required, auto-filled from the CEP | string | 2 | State abbreviation. For transactions with other countries, send EX. |
cep | Required | string | 8 | CEP (postal code) with 8 digits, without a mask. |
telefone | Optional | string | 7-12 | Phone number with area code, digits only. |
codigo_pais | Optional, with an automatic default | string | 1-4 | Country code. Default: 1058 (Brazil). |
pais | Optional, with an automatic default | string | 2-60 | Country name. Default: Brasil. |
Auto-fill from the CEP: the API fills in logradouro, bairro, codigo_municipio, municipio and uf automatically when the cep you send is valid and can be found.
Example of a company customer:
{
"cliente": {
"cnpj": "00000000000000",
"razao_social": "Empresa Comercial Ltda",
"email": "fiscal@empresacomercial.com.br",
"logradouro": "Rua da Bahia",
"numero": "550",
"bairro": "Centro",
"codigo_municipio": "3106200",
"municipio": "Belo Horizonte",
"uf": "MG",
"cep": "30160011",
"telefone": "3130000000"
}
} The items are the goods transported. Send them as an array in the itens parameter, with at least 1 and at most 999 items.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
descricao | Required | string | 1-120 | Description of the product or goods. |
ncm | Required | string | 2 or 8 | NCM code (Nomenclatura Comum do Mercosul), the product code based on the international HS code.Send the 2-digit chapter or the full 8-digit code, digits only. |
quantidade | Required | number | 11v4 | Item quantity, from 0 to 99999999999.9999, with up to 4 decimal places. |
valor_unitario | Required | number | 13v8 | Unit value of the item, from 0 to 9999999999999.99999999, with up to 8 decimal places. |
informacoes_adicionais | Optional | string | 1-500 | Extra information about the item (for example batch or expiry date). |
The API calculates the totals, with two limits:
| Limit | Maximum |
|---|---|
| Value of each item (quantity × unit value) | R$ 10,000,000.00 |
| Sum of all items | R$ 100,000,000.00 |
These limits come from API validation. Staying within them does not guarantee authorization, which also depends on the rules of SEFAZ.
Example with two items:
{
"itens": [
{
"descricao": "Cafe torrado e moido 500g",
"ncm": "09012100",
"quantidade": 120,
"valor_unitario": 18.9,
"informacoes_adicionais": "Lote 202603A"
},
{
"descricao": "Filtro de papel tamanho 103 com 30 unidades",
"ncm": "48232099",
"quantidade": 80,
"valor_unitario": 6.5
}
]
} Describe how the goods are transported in the transporte object.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
modalidade | Required | string | 1 | Transport method. 0 = Correios (Brazilian postal service) |
cnpj_transportadora | Optional | string | 14 | CNPJ (company ID) of the carrier, digits only.API validation also accepts an 11-digit CPF, but the document expects the carrier's CNPJ: always send the CNPJ. |
Example of transport by a carrier company:
{
"transporte": {
"modalidade": "2",
"cnpj_transportadora": "19131243000197"
}
} All fields in this section are optional. They let you add extra notes to the document. For companies set up with issuer type 2, the API moves informacoes_adicionais and observacoes to the matching fields with the _emitente suffix, when those fields are empty. The DC-e has two levels of additional information:
informacoes_adicionais and observacoes): visible to the recipient and to the tax authority.informacoes_adicionais_emitente and observacoes_emitente): for the issuer's own use.| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
informacoes_adicionais | Optional | string | 1-5000 | Free text with general notes on the document. |
observacoes | Optional | array | 1-10 | List of structured notes (field/text).See the item structure. |
informacoes_adicionais_emitente | Optional | string | 1-5000 | Free text with notes for the issuer's own use. |
observacoes_emitente | Optional | array | 1-10 | List of structured notes of the issuer (field/text).See the item structure. |
Each item of the observacoes and observacoes_emitente arrays must have the campo and texto fields:
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
campo | Required when you send observacoes or observacoes_emitente | string | 1-20 | Name of the field.Example: PEDIDO, ROTA, REFERENCIA. |
texto | Required when you send observacoes or observacoes_emitente | string | 1-60 | Content of the note. |
Example with every additional information field:
{
"informacoes_adicionais": "Entrega agendada para o periodo da manha.",
"observacoes": [
{
"campo": "PEDIDO",
"texto": "Pedido interno 78954"
},
{
"campo": "CONTATO",
"texto": "Recebimento com Joao"
}
],
"informacoes_adicionais_emitente": "Documento emitido para controle logistico.",
"observacoes_emitente": [
{
"campo": "ORDEM",
"texto": "Ordem de coleta 45678"
}
]
} The XML and the PDF of each document are at the URLs returned in the response, in the lookup and in the notification. For security, Webmania restricts access to these files.
The tax document is protected with a password. It opens only after you confirm the CPF/CNPJ (tax ID) of the document recipient, or with one of the access methods below: Access credentials, Token, Issuing IP or Webmania® Panel.
Ways to access the files:
| Authentication | Access allowed | Password required? | Description |
|---|---|---|---|
Access credentials | ✅ | No | Send the company's access credentials in the request HEADER to access every tax document issued by the company. Authorization: Bearer YOUR_ACCESS_TOKEN |
Token | ✅ | No | Send the encrypted token in the URL to open the tax document for 24 hours without a password. Ideal for sharing a link.?token=[TOKEN]The token is not available for tax documents without a recipient. |
Issuing IP | ✅ | No | When you issue an invoice, the IP address of the computer or server is permanently registered as authorized. That IP can access every tax document issued by the companies it has access to. IPs authorized automatically |
Webmania® Panel | ✅ | No | When you log in to the Webmania® Panel, you can access every tax document issued by the companies of your account. Access lasts while you are logged in to the Webmania® Panel.Access while you are logged in |
No authentication | ❌ | Yes | When the URL is opened publicly, without authentication, the tax documents are protected with a password. To open them, enter the CPF/CNPJ of the document recipient (numbers only, no punctuation).PDF = password-protected PDF fileAccess without authentication is not available for tax documents without a recipient. |
To download the files to your server, use the Access credentials. To give your customer a link without a password, use the Token.
With the company's access credentials in the request header, you can download every tax document issued by the company.
To download a file, send a GET request to the URL of the XML or the PDF, with the credentials in the header. Example with the PDF:
curl -X GET \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
https://api.webmania.com.br/dace/00000000000000000000000000000000000000000000The response is the file itself, as application/pdf or text/xml.
The token opens the XML and the PDF without a password for 24 hours, so you can share the link with your customer safely.
To share the file, generate the token encrypted with AES-256-CBC and send it in the token parameter of the file URL:
https://api.webmania.com.br/dace/00000000000000000000000000000000000000000000?token=[TOKEN]The step-by-step guide to generate the token, with functions in PHP, Python, Java, C# and Ruby, is on the Webmania GitHub (in Portuguese): https://github.com/webmaniabr/DFeToken.
The lookup returns the current status of a DC-e of the authenticated company, even while it is in processando or contingencia. Use the notifications for day-to-day tracking. Use the lookup to check one DC-e when you need to.
To look up a DC-e, send a GET request to the URL /2/dce/consulta/{identifier}. Replace {identifier} with the uuid (36 characters) or the chave (access key, 44 characters) of the DC-e.
curl -X GET \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
https://api.webmania.com.br/2/dce/consulta/00000000000000000000000000000000000000000000 Example of an HTTP 200 response. The fields are described in Notification fields:
{
"ID": "PED-123",
"uuid": "00000000-0000-0000-0000-000000000000",
"chave": "00000000000000000000000000000000000000000000",
"serie": 1,
"numero": 123,
"status": "aprovado",
"motivo": "Autorizado o uso do DC-e",
"modelo": "dce",
"xml": "https://api.webmania.com.br/xmldce/[chave]",
"dace": "https://api.webmania.com.br/dace/[chave]",
"log": {
"cStat": 100,
"xMotivo": "Autorizado o uso do DC-e"
}
} Cancellation registers an event at SEFAZ that voids an authorized DC-e, for example when the goods are not shipped. After cancellation, the DC-e cannot be used for transport.
To cancel a DC-e, send a PUT request to the URL /2/dce/cancelar, with the uuid or the chave of the DC-e and the justificativa (reason) for the cancellation.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
uuid | Required without chave | string | 36 | UUID of the DC-e. Do not send it together with chave. |
chave | Required without uuid | string | 44 | Access key of the DC-e. Do not send it together with uuid. |
justificativa | Required | string | 15-255 | Reason for the cancellation. |
curl -X PUT \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"chave": "00000000000000000000000000000000000000000000",
"justificativa": "Cancelamento por erro operacional no lançamento"
}' \
https://api.webmania.com.br/2/dce/cancelar The response has status, motivo, xml, xml_cancelamento and log:
| Situation | Response | What to do |
|---|---|---|
| Cancellation accepted by SEFAZ | status = cancelado | Store the xml_cancelamento. Webmania also sends the cancelado notification. |
| Cancellation not accepted | status = reprovado | The DC-e stays authorized. Read the motivo before you try again. |
Example of an HTTP 200 response for an accepted cancellation:
{
"status": "cancelado",
"motivo": "Evento registrado e vinculado",
"xml": "https://api.webmania.com.br/xmldce/[chave]",
"xml_cancelamento": "https://api.webmania.com.br/xmldce/[chave]/cancelamento",
"log": {}
} Example of an HTTP 200 response when SEFAZ does not accept the cancellation:
{
"status": "reprovado",
"motivo": "Falha no cancelamento",
"log": {}
} Webmania® detects automatically when SEFAZ is down or has not returned a result yet. It completes the DC-e without your application having to resend anything:
| Situation | Status | What Webmania does |
|---|---|---|
| SEFAZ received the DC-e but has not answered yet | processando | Checks with SEFAZ automatically until it gets the result. |
| SEFAZ is offline | contingencia | Keeps the DC-e in a queue and resends it when communication is back. Before resending, it checks with SEFAZ so the same DC-e is not issued twice. |
processando and contingencia statuses are not notified and do not prove authorization. The url_notificacao receives the final result; until then, follow the DC-e through the lookup, without issuing it again.The final result, aprovado or reprovado, arrives by notification and is available in the lookup. Until then, do not issue the same DC-e again.
The Webmania® API runs on Amazon AWS, the global leader in cloud computing, in the us-east-1 region (US East), with a point of presence in sa-east-1 (São Paulo). The entry point is anycast and highly available: from anywhere in the world, your request goes to the server closest to you.
The same entry IPs serve the whole world. Your request goes to the server closest to you, with no setup on your side.
us-east-1 (US East) and sa-east-1 (São Paulo). Keep your infrastructure close to one of them for a shorter response time.
Fixed IPs for inbound and outbound traffic: allow them in your firewall and check the source of the notifications you receive.
13.248.145.9076.223.17.24034.196.69.3844.219.142.86The Webmania® API limits the number of requests per second to keep every integration stable and fast. Each limit is counted per second, separately for each HTTP method and each endpoint.
Reading: lookups and lists.
Creating: issuing and other submissions. See the specific limits below.
Changing and removing resources.
Some endpoints have a lower limit, which applies instead of the method's limit:
| Request | Limit | Reason |
|---|---|---|
| Issuing in the sandbox (homologação) | 1 request per second | Test environment for your integration. |
Need a higher request volume? Contact us and we will review it.
A request over the limit is refused with HTTP 429 (Too Many Requests) before it is processed. Nothing is issued, changed or canceled, and you can safely resend the same request.
| Header | Example | Description |
|---|---|---|
Retry-After | 1 | Seconds to wait before you resend the request. If the response does not include this header, wait 1 second. |
Example of an HTTP 429 response. The API sends the message in Portuguese; it means “Request limit reached. Try again in a few seconds.”:
{
"error": "Limite de requisições atingido. Tente novamente em alguns segundos."
}
429, not by the text of the error field: the message can change from one endpoint to another.Retry-After header, or 1 second if the header is missing.Receive the API results at your notification URL instead of polling in a loop. When a result arrives, update your database and download the PDF and the XML.
Spread your requests through a queue that respects the per-second limit of each method, instead of sending everything at once.
The endpoints require valid access credentials in the request header. Sending them incorrectly is treated as misuse of the API.
By default, the firewall blocks servers in regions with a high rate of attacks or a poor reputation. If a GET to https://webmania.com.br/api/ or https://api.webmania.com.br returns 403 Forbidden by mistake, contact us and we will allow your IP.
The contingency section now has a flowchart from the request to the final result, with the contingency queue and the automatic resend.
Changed section: contingencia
The documentation is now LLM-ready: copy the page or each section as Markdown, a section index and llms.txt.