The Webmania® REST API issues the MDF-e at SEFAZ, the state tax authority. It creates the XML file and the DAMDFE (the printed summary of the manifest) and sends the result by notification. You can also look up, close and cancel each manifest, and add a driver to it. To start, read the Quick guide. To issue other document types, see all the APIs.
What is the MDF-e? The MDF-e (Manifesto Eletrônico de Documentos Fiscais) is the electronic cargo manifest. It lists the invoices (NF-e) or freight bills (CT-e) of the cargo that one vehicle carries on one trip. SEFAZ must authorize it before the trip starts, and you close it when the trip ends. It also records the transport mode, the cities of loading and unloading, and the route:
The company that carries the cargo: a carrier that sells the transport service, or a company that carries its own goods. Set it in emitente.
The tax documents of the cargo (NF-e, CT-e or MDF-e), grouped by city of unloading in descarregamento.
After authorization, the DAMDFE travels with the vehicle. When the trip ends and the cargo is delivered, you close the MDF-e.
Brazilian tax terms you will see. They keep their Brazilian names in the payload and on the MDF-e:
SEFAZ: the state tax authority. It authorizes each MDF-e and answers with a status code; 100 = authorized.
DAMDFE: the printable summary of the MDF-e that travels with the vehicle; the legal document is the XML.
Chave de acesso: the 44-digit access key of each NF-e, CT-e or MDF-e in the cargo. Sent in descarregamento, in documentos_fiscais.
CIOT: the code ANTT generates for a paid road freight operation. Array ciot of the road mode.
RNTRC / ANTT: the carrier's registration with ANTT, the national land transport agency. Field rntrc of the road mode.
NCM: the 8-digit product classification code of Mercosur. Field ncm of the predominant product.
CNPJ / CPF / IE: the company ID (14 digits), the individual taxpayer ID (11 digits) and the state registration.
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 you are using version 2.0 of the API.
| URL | HTTP Verb | Function |
|---|---|---|
/2/mdfe/emissao | POST | Issue an MDF-e |
/2/mdfe/consulta/{key} | GET | Look up an MDF-e by its UUID (36 characters) or its access key (44 characters) |
/2/mdfe/encerrar | PUT | Close an MDF-e |
/2/mdfe/cancelar | PUT | Cancel an MDF-e |
/2/mdfe/condutor | PUT | Add a driver to an MDF-e (road transport only) |
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 and Response format.
How to integrate the MDF-e:
Authorization header. /2/mdfe/emissao. Use ambiente = 2 (sandbox) for tests, and send the object of the trip's transport mode. The response returns the uuid of the MDF-e; store it in your system. url_notificacao when the MDF-e is authorized, rejected, denied, closed or canceled. An MDF-e describes one trip in one of four transport modes: road, air, water or rail. Send the mode code in modalidade. Send the trip data in the object of the same mode, which then becomes required:
| Transport mode | modalidade | Object | What goes in the object |
|---|---|---|---|
| Road | 1 | rodoviario | Tractor vehicle and trailers, drivers and, when they apply, CIOT, toll voucher, hiring parties and freight payment. |
| Air | 2 | aereo | Aircraft, flight number and date, and departure and destination airfields. |
| Water | 3 | aquaviario | Vessel, voyage, ports of departure and destination and, when they apply, terminals, convoy and empty units. |
| Rail | 4 | ferroviario | Train and wagons. |
In road transport, produto_predominante is also required when emitente is 1 or 3. Road is also the only mode that allows you to add a driver after authorization.
Every MDF-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 are not notified and do not prove authorization. Follow the MDF-e through the lookup and do not issue it again. Closing, canceling and adding a driver are only accepted while the MDF-e is aprovado.| Status | What it means | What to do |
|---|---|---|
processando | SEFAZ has not returned the result of the MDF-e yet. | Wait for the notification or look up the MDF-e. Do not issue it again. |
contingencia | SEFAZ is unavailable. Webmania sends the MDF-e again automatically, after checking SEFAZ. | Follow the same uuid and do not issue it again. See Contingency mode. |
aprovado | SEFAZ authorized the MDF-e. The XML and the DAMDFE are available. | Print the DAMDFE to travel with the cargo. At the end of the route, close it. If the trip does not happen, cancel it. |
reprovado | SEFAZ rejected the MDF-e. motivo holds the reply. | Fix the data shown in motivo and issue a new MDF-e. |
denegado | SEFAZ denied use of the MDF-e. motivo holds the reply. | Do not use this MDF-e for transport. Read the motivo before you issue another one. |
encerrado | The closing was registered at SEFAZ. | Nothing to do. The MDF-e no longer accepts cancellation or new drivers. |
cancelado | The cancellation was registered at SEFAZ. | Do not use this MDF-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 MDF-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 API 2.0 Access-Token in the Webmania® Panel. Include it in every request. Send the request body in JSON, with the Content-Type and Accept headers set to application/json.
Keep your credentials safe. Never publish the Access Token in the source code of a website, app or system where others can easily read it.
For mobile apps (iOS and Android), we recommend that you issue documents on your server (back end). The app code should only send the issuing request. The processing should run on your server.
The responses for issuing, lookup, closing, cancellation and adding a driver are in JSON. Downloading the XML and the DAMDFE returns the file itself, as described in Download XML and PDF.
An HTTP 2xx status does not confirm that SEFAZ authorized the MDF-e. Also check the JSON body:
| Situation | How to identify it |
|---|---|
| Business or validation error | HTTP 200 with the error field. Request validation failures can return HTTP 422 with error and errors. |
| Token missing or invalid | HTTP 401 with the error field. |
| MDF-e accepted by the API | The status field gives the tax status of the document. See the MDF-e lifecycle. |
Example of an HTTP 401 response when the token is missing or invalid (the message means "Restricted access. Token missing or invalid."):
{
"error": "Acesso restrito. Token não informado ou inválido."
} To keep your platform up to date, Webmania® sends automatic notifications for each result of the MDF-e. With them, you do not need a routine that polls for results: wait for the webhook and update the MDF-e in your system when it arrives.
The notification is sent by POST, in JSON, to the URL set in url_notificacao when you issue the document. If you do not send this parameter, it goes to the notification URL saved in the company's settings.
| Notified status | When it is sent |
|---|---|
aprovado | SEFAZ authorized the MDF-e. The body includes the chave, the xml and the damdfe. |
reprovado | SEFAZ rejected the MDF-e. The body includes the motivo. |
denegado | SEFAZ denied use of the MDF-e. The body includes the motivo. |
encerrado | The closing was registered at SEFAZ. |
cancelado | The cancellation was registered at SEFAZ. |
processando and contingencia are not notified. In these cases, do not issue the MDF-e again: wait for the next notification or check the result in the lookup. Adding a driver does not send a notification either: the result comes in the response to the request.What is the UUID? The UUID (Universally Unique Identifier) is a unique 36-character ID, in the format 8-4-4-4-12, that Webmania assigns to each MDF-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 MDF-e at SEFAZ: it applies to aprovado, reprovado, cancelado, encerrado, processando, contingencia and denegado.
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 MDF-e lookup:
| Parameter | Type | Description |
|---|---|---|
uuid | string | Unique ID of the MDF-eUse the UUID to receive the notification and identify the MDF-e in your system. |
chave | string | Access key that identifies the MDF-e at SEFAZ |
serie | integer or null | Issuing series, or null when it cannot be determined. |
mdfe | integer | MDF-e number Managed automatically by the issuer. |
status | string | Status of the MDF-e: aprovado, reprovado, denegado, encerrado or cancelado in the notification. The lookup can also return processando or contingencia. See the lifecycle. |
motivo | string or null | Reason for the status, when availableE.g.: Autorizado o uso da MDF-e (use of the MDF-e authorized) |
xml | string | URL of the MDF-e XML |
damdfe | string | URL of the DAMDFE |
log | object or array | Reply log from SEFAZ |
The notification is sent with the POST method, in application/json format:
-X POST \
-header "Content-type: application/json" \ Example of a notification for an authorized MDF-e:
{
"uuid": "00000000-0000-0000-0000-000000000000",
"chave": "00000000000000000000000000000000000000000000",
"serie": 1,
"mdfe": 123,
"status": "aprovado",
"motivo": "Autorizado o uso da MDF-e",
"xml": "https://api.webmania.com.br/xmlmdfe/[chave]",
"damdfe": "https://api.webmania.com.br/damdfe/[chave]",
"log": { ... }
} Issuing sends the MDF-e (cargo manifest) to SEFAZ, the state tax authority. When SEFAZ authorizes it, the API generates the XML file and the DAMDFE, the printed manifest summary that travels with the cargo. Each transport mode has its own object for its fields: see Which transport mode to use.
To issue an MDF-e, send a POST request to the URL /2/mdfe/emissao, with a JSON body.
How to build the request:
ambiente (environment: 2 for tests in the sandbox), the emitente (issuer) type, the modalidade (transport mode), the states, the cargo value and weight and, if you want, the url_notificacao and your own control ID. carregamento, from 1 to 50 cities, each with its IBGE code (the official 7-digit city code). descarregamento, each city with its documentos_fiscais: the access key of each NF-e, CT-e or MDF-e in the cargo. modalidade: rodoviario, aereo, aquaviario or ferroviario. produto_predominante, required for road transport when emitente is 1 or 3. seguro, with the responsible party and the insurer. Request example:
curl -X POST \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ambiente": 1,
"modalidade": 1,
"emitente": 2,
...
}' \
https://api.webmania.com.br/2/mdfe/emissao Example of the full body of a road MDF-e:
{
"ambiente": 1,
"emitente": 2,
"transportador": 1,
"modalidade": 1,
"uf_carregamento": "GO",
"uf_descarregamento": "PR",
"valor_carga": "500.00",
"unidade": "01",
"peso_bruto": "50.0000",
"carregamento": [
{
"codigo_municipio": "5208707",
"nome_municipio": "Goiânia"
},
{
"codigo_municipio": "5201405",
"nome_municipio": "Aparecida de Goiânia"
}
],
"descarregamento": [
{
"codigo_municipio": "4106902",
"nome_municipio": "Curitiba",
"documentos_fiscais": [
{
"chave": "00000000000000000000000000000000000000000000"
}
]
}
],
"percurso": ["MG", "SP"],
"rodoviario": {
"rntrc": "12345678",
"veiculo_tracao": {
"placa": "AB12E4R",
"tara": "20",
"uf_licenciamento": "GO",
"tipo_rodado": "01",
"tipo_carroceria": "00",
"proprietario": {
"cnpj": "00.000.000/0000-00",
"razao_social": "Proprietário 1",
"rntrc": "12345678",
"ie": "00000",
"uf": "GO",
"tipo_proprietario": "2"
}
},
"condutor": [
{
"cpf": "000.000.000-00",
"nome": "Condutor 1"
}
],
"ciot": [
{
"codigo_ciot": "000000000000",
"cpf_responsavel": "000.000.000-00"
}
]
},
"seguro": [
{
"responsavel": {
"tipo_responsavel": "1"
},
"seguradora": {
"cnpj": "00.000.000/0000-00",
"nome_seguradora": "Seguradora 1"
}
}
],
"produto_predominante": {
"tipo_carga": "01",
"nome": "Produto 1",
"lotacao": {
"carregamento": {
"cep": "00000-000"
},
"descarregamento": {
"cep": "00000-000"
}
}
}
} Example of an HTTP 200 response for an authorized MDF-e. The fields are described in Notification fields. The content of log depends on the SEFAZ response:
{
"uuid": "90d30c80-d0be-4c8f-a749-a818989222ca", // Unique identification number
"chave": "00000000000000000000000000000000000000000000", // Access key at SEFAZ
"serie": 1, // MDF-e series
"mdfe": 123, // MDF-e number
"status": "aprovado", // aprovado, reprovado, cancelado, encerrado, processando, contingencia or denegado
"motivo": "Autorizado o uso da MDF-e", // Reason for the status (SEFAZ message)
"xml": "https://api.webmania.com.br/xmlmdfe/[chave]",
"damdfe": "https://api.webmania.com.br/damdfe/[chave]",
"log": { ... } // SEFAZ response log
} If the response returns processando or contingencia, the MDF-e has no final result yet: wait for the notification and do not issue it again. The statuses are explained in MDF-e lifecycle.
Top-level fields of the issuing body. Fields with a link open the section of their object. The transport mode code goes in modalidade, and the mode data goes in the object with the same name; see Which transport mode to use.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
ID | string | 1-15 | Purchase order number or processing ID Tracks issuing requests by order or processing ID. Learn more (in Portuguese) | |
ambiente | integer | 1 | SEFAZ environment 1 - Production | |
url_notificacao | string | --- | URL that receives the MDF-e notifications. Without it, Webmania uses the notification URL saved for the company. | |
emitente | integer | 1 | Issuer type of the MDF-e 1 - Transport service provider Note: Use 2 for NF-e issuers and for carriers that transport their own cargo. Use 3 for the cargo carrier that will later issue a CT-e Globalizado that lists the NF-e. | |
transportador | integer | 1 | Carrier type of the MDF-e 1 - ETC (cargo transport company) | |
modalidade | integer | 1 | Transport mode 1 - Road | |
uf_carregamento | string | 2 | Code of the state (UF) where the cargo is loaded | |
uf_descarregamento | string | 2 | Code of the state (UF) where the cargo is unloaded | |
valor_carga | string | 13v2 | Total value of the cargo/goods carried | |
unidade | string | 2 | Unit of measure code of the gross weight of the cargo/goods carried 01 – KG | |
peso_bruto | string | 11v4 | Total gross weight of the cargo/goods carried | |
data_inicio_viagem | string | 19 | Planned date and time of the trip start Format: Y-m-d H:i:s | |
percurso | array of strings | 0-25 | Codes of the states (UF) on the route, without repeating the loading and unloading states. | |
ind_canal_verde | integer | 1 | Indicates participation in the Canal Verde (green channel) program. 0 - No | |
informacoes_fisco | string | 1-2000 | Additional information for the tax authorities. | |
informacoes_complementares | string | 1-5000 | Complementary information of interest to the taxpayer. | |
carregamento | array | 1-50 | Information on the loading cities | |
descarregamento | array | 1-1000 | Information on the unloading cities and their tax documents | |
produto_predominante | object | --- | Information on the predominant product of the cargo. *Required for road transport with emitente 1 or 3. | |
seguro | array | 0-n | Cargo insurance information | |
rodoviario | object | --- | Road transport information. *Required for road transport. | |
aereo | object | --- | Air transport information. *Required for air transport. | |
aquaviario | object | --- | Water transport information. *Required for water transport. | |
ferroviario | object | --- | Rail transport information. *Required for rail transport. |
List the cities where the cargo is loaded in the carregamento array, one item per city, from 1 to 50.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
nome_municipio | string | 2-60 | Name of the loading city | |
codigo_municipio | string | 7 | IBGE code of the loading city, with 7 digits. Required for each city, even when nome_municipio is sent. |
Loading example:
{
...
"carregamento": [
{
"nome_municipio": "Curitiba",
"codigo_municipio": "4106902"
},
{
"nome_municipio": "Maringá",
"codigo_municipio": "4115200"
}
],
...
}List the cities where the cargo is unloaded in the descarregamento array, one item per city. Each city lists, in documentos_fiscais, the tax documents (NF-e, CT-e or MDF-e) of the cargo unloaded there.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
nome_municipio | string | 2-60 | Name of the unloading city | |
codigo_municipio | string | 7 | IBGE code of the unloading city, with 7 digits. Required for each city, even when nome_municipio is sent. | |
documentos_fiscais | array | 1-n | Tax documents of the goods unloaded in the city NF-e, CT-e or MDF-e. The XML layout accepts up to 20,000 documents of each type per city. |
Unloading example:
{
...
"descarregamento": [
{
"nome_municipio": "São Paulo",
"codigo_municipio": "3550308",
"documentos_fiscais": [...]
}
],
...
}Each item of the documentos_fiscais array is one tax document of the cargo, identified by its access key: NF-e, CT-e or MDF-e.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
chave | string | 44 | Access key | |
codigo_barra | string | 36 | Second barcode, with 36 digits, for NF-e or CT-e. | |
indicador_reentrega | integer | 1 | Redelivery indicator. Send 1 to flag a redelivery; otherwise, leave the field out. | |
unidade_transporte | array | 0-n | Information on the transport units (semi-trailer/trailer/wagon) | |
periculosidade | array | 0-n | Dangerous goods carried under this tax document. See the fields in Dangerous goods. | |
entrega_parcial | object | --- | Partial delivery (flight cut), for CT-e only. It belongs to the tax document, not to a dangerous goods item. When sent, it requires quantidade_total and quantidade_parcial as numbers, not empty, with up to 4 decimal places. |
Tax documents example:
{
...
"documentos_fiscais": [
{
"chave": "00000000000000000000000000000000000000000000"
},
{
"chave": "00000000000000000000000000000000000000000000"
},
{
"chave": "00000000000000000000000000000000000000000000"
}
],
...
}List the transport units of the document (semi-trailer, trailer, wagon) in the unidade_transporte array, one item per unit.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
tipo | integer | 1 | Transport unit type 1 - Road tractor | |
identificacao | string | 1-20 | Transport unit identification Send the identification that matches the transport unit type. For example, for a road tractor or trailer, send the vehicle license plate. | |
lacres | array (string) | 0-n | Seals of the transport units. Each element must be a string of 1 to 20 characters. | |
quantidade_rateada | string | 3v2 | Apportioned quantity (weight/volume), as a numeric string from 0 to 999.994, with up to 2 decimal places. Non-numeric values or values outside this range are left out. | |
unidade_carga | array | 0-n | Information on the cargo units (containers/ULD/other) |
Transport unit example:
{
...
"unidade_transporte": [
{
"tipo": 1,
"identificacao": "Placa ABCXXXX",
"lacres": [
"00000000", "00000000"
],
"unidade_carga": [...]
}
],
...
}List the cargo units of each transport unit (container, ULD, pallet) in the unidade_carga array, one item per unit.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
tipo | integer | 1 | Cargo unit type 1 - Container | |
identificacao | string | 1-20 | Cargo unit identification Send the identification of the cargo unit, for example the container number. | |
lacres | array (string) | 0-n | Seals of the cargo units. Each element must be a string of 1 to 20 characters. | |
quantidade_rateada | string | 3v2 | Apportioned quantity (weight/volume), as a numeric string from 0 to 999.994, with up to 2 decimal places. Non-numeric values or values outside this range are left out. |
Cargo unit example:
{
...
"unidade_carga": [
{
"tipo": 1,
"identificacao": "Container 00000",
"lacres": [
"00000000", "00000000"
]
}
],
...
}When the tax document carries products that the UN classifies as dangerous, list each product in the periculosidade array, one item per product.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
numero_onu | string | 4 | UN number | |
quantidade_total | string | 1-20 | Total quantity per product | |
nome_embarque | string | 1-150 | Proper shipping name of the product | |
classe_risco | string | 1-40 | Class or subclass/division, and subsidiary/secondary risk | |
grupo_embalagem | string | 1-6 | Packing group | |
quantidade_volumes | string | 1-60 | Quantity and type of packages |
Dangerous goods example:
{
...
"periculosidade": [
{
"numero_onu": "XXXX",
"nome_embarque": "Produto Perigoso 1",
"classe_risco": "Classe de Risco XX",
"grupo_embalagem": "XXXXXX",
"quantidade_total": "40000",
"quantidade_volumes": "20 tambores"
}
],
...
}Describe the product that makes up most of the cargo in the produto_predominante object. It is required for road transport when emitente is 1 or 3.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
tipo_carga | string | 2 | Cargo type 01-Solid bulk | |
nome | string | 1-120 | Name/description of the predominant product | |
gtin | string | 8, 12-14 | GTIN (Global Trade Item Number) of the product, formerly the EAN code or barcode. The layout accepts 8, 12, 13 or 14 digits, or SEM GTIN (no GTIN). | |
ncm | string | 8 | NCM of the product: the 8-digit product classification code of Mercosur, based on the international HS code. Required for road transport with only one tax document when emitente is 1 or 3, or when it is 2 and transportador is sent. In the other cases, it is validated when sent. | |
lotacao | object | --- | Full load information. Required for road transport with emitente 1 or 3 and only one tax document. |
Predominant product example:
{
...
"produto_predominante": {
"tipo_carga": "02",
"nome": "Produto X",
"gtin": "00000000000000",
"ncm": "00000000",
"lotacao": {
...
}
},
...
}For a full load (lotação), send the loading and unloading places in the lotacao object, in the carregamento and descarregamento objects, each with the fields below. The CEP (postal code) is required in both. Latitude and longitude do not replace the CEP, and they do not go into the XML when the CEP is sent.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cep | string | 8 digits | Postal code (CEP) of the loading/unloading place, with 8 digits, with or without mask. | |
latitude | string | 2v6 | Latitude of the loading/unloading place | |
longitude | string | 3v6 | Longitude of the loading/unloading place |
Full load example:
{
...
"lotacao": {
"carregamento": {
"cep": "00000-000",
"latitude": "00.000",
"longitude": "00.000"
},
"descarregamento": {
"cep": "00000-000",
"latitude": "00.000",
"longitude": "00.000"
}
},
...
}Send the cargo insurance in the seguro array, one item per insurance, with the responsible party and the insurer.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
responsavel | object | --- | Information on the party responsible for the cargo insurance | |
seguradora | object | --- | Insurer information | |
numero_apolice | string | 1-20 | Policy number | |
numero_averbacao | array | 0-n | Insurance endorsement numbers (averbação). Each element must be a string with up to 40 characters. |
Cargo insurance example:
{
...
"seguro": [
{
"responsavel": {
"tipo_responsavel": 2,
"cnpj": "00.000.000/0000-00"
},
"seguradora": {
"nome_seguradora": "Seguradora 1",
"cnpj": "00.000.000/0000-00"
},
"numero_apolice": "00000000000000",
"numero_averbacao": ["000000", "000000"]
},
{
"responsavel": {
"tipo_responsavel": 1
},
"seguradora": {
"nome_seguradora": "Seguradora 2",
"cnpj": "00.000.000/0000-00"
},
"numero_apolice": "00000000000000",
"numero_averbacao": ["000000", "000000"]
}
],
...
}Identify who took out the insurance in the responsavel object.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
tipo_responsavel | integer | 1 | Party responsible for the insurance 1 - Issuer of the MDF-e | |
cpfIndividual | string | 11 | CPF, the 11-digit individual taxpayer ID Send a CPF or a CNPJ when tipo_responsavel is 2. It is not needed when it is 1 (issuer of the MDF-e). 000.000.000-00 | |
cnpjCompany | string | 14 | CNPJ, the 14-digit company ID (each branch has its own) Send a CPF or a CNPJ when tipo_responsavel is 2. It is not needed when it is 1 (issuer of the MDF-e). 00.000.000/0000-00 |
Identify the insurer in the seguradora object.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
nome_seguradora | string | 1-30 | Insurer name | |
cnpj | string | 14 | CNPJ00.000.000/0000-00 |
Road transport describes carriage by a cargo vehicle: the tractor vehicle and the trailers, the drivers and, when they apply, the CIOT, the toll voucher, the hiring parties and the freight payment. Send the data in the rodoviario object, required when modalidade is 1.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
rntrc | string | 8 | RNTRC, the carrier registration with ANTT, the national land transport agency (Registro Nacional de Transportadores Rodoviários de Carga). When sent, it has 8 digits, with or without mask. | |
combinacao_veicular | string | 2 | Vehicle combination category *Required when vale_pedagio is set 02-Commercial vehicle, 2 axles | |
veiculo_tracao | object | --- | Tractor vehicle information | |
veiculo_reboque | array | 0-3 | Trailer vehicle information | |
condutor | array | 1-10 | Drivers of the vehicle | |
ciot | array | 0-n | CIOT data (Código Identificador da Operação de Transporte, the road freight registration code) | |
vale_pedagio | array | 0-n | Toll voucher information *Required when combinacao_veicular is set | |
contratante | array | 0-n | Information on the hiring parties of the transport service | |
pagamento_frete | array | 0-n | Freight payment information. Required for road transport with only one tax document when emitente is 1 or 3, or when it is 2 with transportador sent. Also required when the issuer or an owner has an RNTRC and one of these conditions applies: transportador equal to 2 (TAC), or an owner with tipo_proprietario 0 or 1. | |
lacres | array (string) | 0-n | Seals of the road transport. Each element must be a string with up to 20 characters. |
Road transport example:
{
...
"rodoviario": {
"rntrc": "00000000",
"veiculo_tracao": {...},
"condutor": [...]
}
...
}Send the tractor vehicle in the veiculo_tracao object and the trailers, up to 3, in the veiculo_reboque array. Both use the fields below.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
codigo_interno | string | 1-10 | Internal code of the vehicle | |
placa | string | 7 | License plate of the vehicle | |
renavam | string | 9-11 | RENAVAM (national vehicle registration number) of the vehicle | |
tara | string | 1-6 | Tare weight in KG | |
capacidade_kg | string | 1-6 | Capacity of the vehicle in KG *Required for a trailer vehicle | |
capacidade_m3 | string | 1-3 | Capacity of the vehicle in m3 | |
tipo_rodado | string | 2 | Wheel set type Note: send only for the tractor vehicle 01 - Truck (rigid truck, double rear axle) | |
tipo_carroceria | string | 2 | Body type 00 - not applicable | |
uf_licenciamento | string | 2 | Code of the state (UF) where the vehicle is licensed | |
proprietario | object | --- | Owner of the vehicleFill in only when the vehicle does not belong to the company that issues the MDF-e. |
Tractor and trailer vehicle example:
{
...
"veiculo_tracao": {
"codigo_interno": "XX123",
"placa": "ABC67H2",
"renavam": "000000000",
"tara": "30",
"tipo_rodado": "01",
"tipo_carroceria": "00",
"uf_licenciamento": "SP",
"proprietario": {
"cnpj": "00.000.000/0000-00",
"razao_social": "Proprietário 1",
"rntrc": "00000000",
"ie": "12345",
"uf": "SP",
"tipo_proprietario": "0"
}
},
"veiculo_reboque": [
{
"codigo_interno": "XX456",
"placa": "DEF22H1",
"renavam": "000000000",
"tara": "20",
"capacidade_kg": "50",
"tipo_carroceria": "00",
"uf_licenciamento": "SP",
"proprietario": {
"cnpj": "00.000.000/0000-00",
"razao_social": "Proprietário 2",
"rntrc": "00000000",
"ie": "67890",
"uf": "SP",
"tipo_proprietario": "0"
}
}
]
...
}When the vehicle does not belong to the company that issues the MDF-e, send its owner in the proprietario object. Identify the owner by CPF and name (individual) or by CNPJ and company name (company), without mixing the two. The other required fields apply when the owner is sent.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cpfIndividual | string | 11 | CPF number (individual taxpayer ID)000.000.000-00 | |
cnpjCompany | string | 14 | CNPJ (company ID)00.000.000/0000-00 | |
nomeIndividual | string | 1-60 | Full name. At least 2 characters for the owner of the tractor vehicle and 1 for the owner of a trailer. | |
razao_socialCompany | string | 1-60 | Company name (razão social). At least 2 characters for the owner of the tractor vehicle and 1 for the owner of a trailer. | |
ie | string | 0-14 | IE (Inscrição Estadual), the state taxpayer registration of the owner | |
rntrc | string | 8 | RNTRC of the owner | |
uf | string | 2 | Code of the owner's state (UF) | |
tipo_proprietario | string | 1 | Owner type 0-TAC – Agregado (independent driver contracted to one carrier) |
List the drivers of the vehicle in the condutor array, from 1 to 10. To add a driver to an MDF-e that is already authorized, use Add a driver to an MDF-e.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cpf | string | 11 | CPF number 000.000.000-00 | |
nome | string | 2-60 | Full name |
Drivers example:
{
...
"condutor": [
{
"cpf": "000.000.000-00",
"nome": "Condutor 1"
},
{
"cpf": "000.000.000-00",
"nome": "Condutor 2"
}
],
...
}Send the CIOT of the trip in the ciot array, one item per CIOT. The CIOT (Código Identificador da Operação de Transporte) is the road freight registration code of ANTT, the national land transport agency. For each item, send cpf_responsavel or cnpj_responsavel, never both.
Who can issue the CIOT? The MDF-e only reuses a CIOT that was already generated; it does not change who is allowed to generate it. In this beta phase, direct issuing through Webmania is available to an ETC not treated as a TAC (a cargo transport company without the status of an independent driver), in its own name, with an active RNTRC, using its own e-CNPJ A1 certificate whose CNPJ matches the one sent in cpf_cnpj_contratado. For a TAC (independent truck driver), a TAC-equiparado (treated as a TAC, including an ETC with up to 3 vehicles registered in the RNTRC) and a CTC (cargo transport cooperative), the code is generated by a partner Instituição de Pagamento Eletrônico de Frete (IPEF), an electronic freight payment institution. Contact Webmania to enable this channel for your company.
cpf_cnpj_contratado).To issue the CIOT directly through Webmania, see the CIOT / PEF (ANTT) API documentation.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
codigo_ciot | string | 12 | CIOT code | |
cpf_responsavelIndividual | string | 11 | CPF number of the party responsible for generating the CIOT000.000.000-00 | |
cnpj_responsavelCompany | string | 14 | CNPJ of the party responsible for generating the CIOT00.000.000/0000-00 |
CIOT example:
{
...
"ciot": [
{
"codigo_ciot": "000000000000",
"cpf_responsavel": "000.000.000-00"
},
{
"codigo_ciot": "000000000000",
"cnpj_responsavel": "00.000.000/0000-00"
}
],
...
}List the toll vouchers (vale-pedágio) of the trip in the vale_pedagio array, one item per receipt. For each item, send cpf_responsavel or cnpj_responsavel, never both. With a toll voucher, combinacao_veicular is also required.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cnpj_fornecedor | string | 14 | CNPJ of the toll voucher supplier 00.000.000/0000-00 | |
cpf_responsavelIndividual | string | 11 | CPF number of the party responsible for paying the toll voucher000.000.000-00 | |
cnpj_responsavelCompany | string | 14 | CNPJ of the party responsible for paying the toll voucher00.000.000/0000-00 | |
comprovante | string | 1-20 | Purchase receipt number | |
valor | string | 13v2 | Toll voucher value | |
tipo | string | 2 | Toll voucher type 01-TAG |
Toll voucher example:
{
...
"vale_pedagio": [
{
"cnpj_fornecedor": "00.000.000/0000-00",
"cpf_responsavel": "000.000.000-00",
"comprovante": "00000",
"valor": "15.00",
"tipo": "01"
},
{
"cnpj_fornecedor": "00.000.000/0000-00",
"cnpj_responsavel": "00.000.000/0000-00",
"comprovante": "00000",
"valor": "12.00",
"tipo": "01"
}
],
...
}List who hired the transport service in the contratante array. For each item, send cpf or cnpj, never both.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cpfIndividual | string | 11 | CPF number000.000.000-00 | |
cnpjCompany | string | 14 | CNPJ00.000.000/0000-00 |
Hiring parties example:
{
...
"contratante": [
{
"cpf": "000.000.000-00"
},
{
"cnpj": "00.000.000/0000-00"
}
],
...
}Send the freight payment in the pagamento_frete array, one item per party responsible for the payment.
Identify the responsible party by cpf, cnpj or id_estrangeiro, only one of them. With a CNPJ, the CPF, foreign ID and name fields are discarded. With a CPF and no CNPJ, the foreign ID and the company name are discarded.
The sum of the values in componentes_pagamento_frete must match valor_contrato, with a tolerance of R$ 0.01.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
cpfIndividual | string | 11 | CPF number000.000.000-00 | |
nomeIndividual Foreign party | string | 2-60 | Name of the party responsible for the payment | |
cnpjCompany | string | 14 | CNPJ00.000.000/0000-00 | |
razao_socialCompany | string | 2-60 | Company name (razão social) of the party responsible for the payment | |
id_estrangeiroForeign party | string | 5-20 | ID of the party responsible for the payment, when it is a foreign party | |
valor_contrato | string | 13v2 | Total value of the contract | |
forma_pagamento | string | 1 | Payment method indicator:0 - Payment in full (à vista) | |
operacao_alto_desempenho | boolean | --- | Transport operation that uses vehicles from dedicated or retained fleets | |
valor_adiantamento | string | 13v2 | Advance amount Use only with installment payment | |
antecipar_adiantamento | boolean | --- | Indicator that declares agreement to bring forward the advanceSend only if bringing forward the advance is authorized | |
permissao_antecipacao_parcela | string | 1 | Permission type for bringing forward the installments:0 - Does not allow bringing forward | |
componentes_pagamento_frete | array | 1-n | Freight payment components | |
informacoes_bancarias | object | 1 | Bank details | |
informacoes_pagamento_prazo | array | 0-n | Installment payment information Required when forma_pagamento is 1 and emitente is 1 or 3, or when emitente is 2 with transportador sent. Discarded for payment in full. |
Freight payment example:
{
...
"pagamento_frete": [
{
"nome": "João Silva",
"cpf": "000.000.000-00",
"valor_contrato": 173.56,
"forma_pagamento": "1",
"valor_adiantamento": 50.45,
"componentes_pagamento_frete": [...],
"informacoes_bancarias": {...},
"informacoes_pagamento_prazo": [...]
},
{
"nome": "Noah Oliver",
"id_estrangeiro": "JAU2874HBDJ",
"valor_contrato": 1084.13,
"forma_pagamento": "0",
"componentes_pagamento_frete": [...],
"informacoes_bancarias": {...}
}
],
...
}Break down the contract value in the componentes_pagamento_frete array, one item per component: toll voucher, taxes, expenses, freight or other.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
tipo_componente | string | 2 | Component type: 01 - Toll voucher | |
valor_componente | string | 13v2 | Component value | |
descricao_componente | string | 2-60 | Component descriptionSend only if the component type is 99 – Other |
Freight payment components example:
{
...
"componentes_pagamento_frete": [
{
"tipo_componente": "01",
"valor_componente": 976.34
},
{
"tipo_componente": "99",
"valor_componente": 80.54,
"descricao_componente": "Taxa de estadia"
}
],
...
}Send how the freight will be received in the informacoes_bancarias object: bank and branch, the CNPJ of the electronic freight payment institution (IPEF) or a Pix key (Pix is Brazil's instant payment system), according to tipo_informacao_bancaria. Send only the fields of the chosen type: the fields of the other types are discarded.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
tipo_informacao_bancaria | string | 1 | Bank information type1 - Bank and branch | |
numero_banco | string | 3-5 | Bank numberRequired if the bank information type is 1 - Bank and branch | |
numero_agencia | string | 1-10 | Bank branch numberRequired if the bank information type is 1 - Bank and branch | |
cnpj_ipef | string | 14 | CNPJ of the electronic freight payment institution (IPEF)Required if the bank information type is 2 - CNPJ of the electronic freight payment institution | |
pix | string | 2-60 | Pix key to receive the freight: email, valid CPF/CNPJ, random key (UUID) or phone number with area code (DDD), without the +55 prefix.Required if tipo_informacao_bancaria is 3. |
Bank details examples, by bank and branch and by Pix key:
{
...
"informacoes_bancarias": {
"tipo_informacao_bancaria": "1",
"numero_banco": "091",
"numero_agencia": "001"
},
...
}
{
...
"informacoes_bancarias": {
"tipo_informacao_bancaria": "3",
"pix": "frete@example.com"
},
...
}For installment payment, list the installments in the informacoes_pagamento_prazo array. The installments are numbered automatically from 001, in the order of the array. The group is required when forma_pagamento is 1 and emitente is 1 or 3, or when emitente is 2 with transportador sent. For payment in full, it is discarded.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
data_vencimento_parcela | string | 10 | Installment due dateFormat Y-m-d | |
valor_parcela | string | 13v2 | Installment value |
Installment payment example:
{
...
"informacoes_pagamento_prazo": [
{
"data_vencimento_parcela": "2004-01-02",
"valor_parcela": 976.34
}
],
...
} The air mode describes transport by airplane: the aircraft, the flight and the departure and destination airfields. Send the data in the aereo object, which is required when modalidade is 2.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
nacionalidade_aeronave | string | 1-4 | Nationality mark of the aircraft | |
matricula_aeronave | string | 1-6 | Registration mark of the aircraft | |
numero_voo | string | 5-9 | Flight number Format = AB1234, where AB is the airline code and 1234 is the flight number. When this is not possible, use the nationality and registration marks without a hyphen. | |
aerodromo_embarque | string | 3-4 | Departure airfield Enter the three-letter IATA code of the departure airport first. When this is not possible, use the ICAO code. | |
aerodromo_destino | string | 3-4 | Destination airfield Enter the three-letter IATA code of the destination airport first. When this is not possible, use the ICAO code. | |
data_voo | string | 10 | Flight date Format Y-m-d |
Example of the air mode:
{
...
"aereo": {
"nacionalidade_aeronave": "XXXX",
"matricula_aeronave": "XXXXXX",
"numero_voo": "AB1234",
"aerodromo_embarque": "AB1",
"aerodromo_destino": "AB2",
"data_voo": "2022-07-11"
}
...
} The water mode describes transport by vessel: the ship, the voyage, the ports and, when they apply, the terminals, the convoy and the empty units. Send the data in the aquaviario object, which is required when modalidade is 3.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
irin | string | 1-10 | IRIN of the ship (its international radio identification) | |
tipo_embarcacao | string | 2 | Vessel type code Use a code from the Vessel Type Table defined by the Brazilian Ministry of Transport | |
codigo_embarcacao | string | 1-10 | Vessel code | |
nome_embarcacao | string | 1-60 | Vessel name | |
numero_viagem | string | 1-10 | Voyage number. Send 1 to 10 digits, with no leading zero. | |
codigo_porto_embarque | string | 1-5 | Port of departure code Use the Port Table defined by the Brazilian Ministry of Transport | |
codigo_porto_destino | string | 1-5 | Port of destination code Use the Port Table defined by the Brazilian Ministry of Transport | |
porto_transbordo | string | 1-60 | Transshipment port | |
tipo_navegacao | number | 1 | Navigation type 0 - Inland | |
mmsiNEW | string | 9 | Maritime Mobile Service Identity (MMSI). Send all 9 digits and keep leading zeros. | |
terminal_carregamento | array | 0-5 | Information about the loading terminals | |
terminal_descarregamento | array | 0-5 | Information about the unloading terminals | |
embarcacao_comboio | array | 0-30 | Information about the convoy vessels | |
carga_vazia | array | 0-n | Information about the empty cargo units | |
transporte_vazio | array | 0-n | Information about the empty transport units |
Example of the water mode:
{
...
"aquaviario": {
"irin": "XXXX12345",
"tipo_embarcacao": "01",
"codigo_embarcacao": "AB12345",
"nome_embarcacao": "Embarcação 1",
"numero_viagem": "12345",
"codigo_porto_embarque": "XXXXX",
"codigo_porto_destino": "XXXXX",
"terminal_carregamento": [
{
"codigo": "TC1",
"nome": "Terminal Carregamento 1"
}
],
"terminal_descarregamento": [
{
"codigo": "TD1",
"nome": "Terminal Descarregamento 1"
}
],
"embarcacao_comboio": [
{
"codigo": "EC1",
"identificador_balsa": "Balsa 1"
}
],
"carga_vazia": [
{
"identificador": "UCV1",
"tipo_unidade": 1
}
],
"transporte_vazio": [
{
"identificador": "UTV1",
"tipo_unidade": 1
}
]
}
...
}Send the terminals in the terminal_carregamento and terminal_descarregamento arrays, up to 5 in each. Both use the fields below.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
codigo | string | 1-8 | Terminal code Use the Loading/Unloading Terminals Table. The code of each port is defined by the Brazilian Ministry of Transport. | |
nome | string | 1-60 | Terminal name |
Send the vessels of the convoy in the embarcacao_comboio array, up to 30.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
codigo | string | 1-10 | Code of the convoy vessel | |
identificador_balsa | string | 1-60 | Barge ID |
Send the empty cargo units in the carga_vazia array, one item per unit.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
identificador | string | 1-20 | Unit ID | |
tipo_unidade | number | 1 | Unit type 1 - Container |
Send the empty transport units in the transporte_vazio array, one item per unit.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
identificador | string | 1-20 | Unit ID | |
tipo_unidade | number | 1 | Unit type 1 - Road tractor (truck) |
The rail mode describes transport by train: the train consist and the wagons. Send the data in the ferroviario object, which is required when modalidade is 4.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
trem | object | --- | Information about the train consist | |
vagoes | array | 1-999 | Information about the wagons. The quantity is calculated from the array. |
Example of the rail mode:
{
...
"ferroviario": {
"trem": {
"prefixo": "ABC123",
"data_liberacao": "2022-07-11 10:00:00",
"origem": "A12",
"destino": "B34"
},
"vagoes": [
{
"peso_bc": "0.000",
"peso_real": "0.000",
"tipo_vagao": "ABC",
"serie": "XYZ",
"numero": "110",
"sequencia_vagao": "1",
"tonelada_util": "0.000"
},
{
"peso_bc": "0.000",
"peso_real": "0.000",
"tipo_vagao": "ABC",
"serie": "XYZ",
"numero": "120",
"sequencia_vagao": "2",
"tonelada_util": "0.000"
}
]
}
...
}Send the train consist in the trem object.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
prefixo | string | 1-10 | Train prefix (train ID) | |
data_liberacao | string | 19 | Date and time the train was released at the origin Format Y-m-d H:i:s | |
origem | string | 1-3 | Code of the train's origin station | |
destino | string | 1-3 | Code of the train's destination station |
Send the wagons of the train in the vagoes array, from 1 to 999 items.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
peso_bc | string | 3v3 | Weight used to calculate the freight, in tonnes. Accepts a number or a numeric string up to 999.999. The value is rounded to an integer when the XML is generated. | |
peso_real | string | 3v3 | Actual weight in tonnes. Accepts a number or a numeric string up to 999.999. The value is rounded to an integer when the XML is generated. | |
tipo_vagao | string | 3 | Wagon type | |
serie | string | 3 | Identification series | |
numero | string | 1-8 | Identification number | |
sequencia_vagao | string | 1-3 | Position in the train consist | |
tonelada_util | string | 3v3 | Payload in tonnes |
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 recipient or, if there is none, of the issuer, 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]For the MDF-e, the password used to generate the token is the CPF/CNPJ of the recipient or, if there is none, of the issuer. |
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 recipient or, if there is none, of the issuer (numbers only, no punctuation).PDF = password-protected PDF fileFor the MDF-e, the password is the CPF/CNPJ of the recipient or, if there is none, of the issuer, with no punctuation and with capital letters (alphanumeric CNPJ). |
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/damdfe/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/damdfe/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 an MDF-e of the authenticated company, including while it is processando or contingencia. Use the notifications to follow your documents day to day. Use the lookup to check one MDF-e when you need to.
To look up an MDF-e, send a GET request to the URL /2/mdfe/consulta/{key}. Replace {key} with the UUID (36 characters) or the access key (44 characters) of the MDF-e. Do not send a request body.
Request example:
curl -X GET \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
https://api.webmania.com.br/2/mdfe/consulta/00000000000000000000000000000000000000000000 Example of an HTTP 200 response. The fields are described in Notification fields. serie and motivo can be null, and log is an object or array, not a JSON string. When the MDF-e is not found, the body includes error.
{
"uuid": "90d30c80-d0be-4c8f-a749-a818989222ca", // Unique ID
"chave": "00000000000000000000000000000000000000000000", // Access key at SEFAZ
"status": "aprovado", // aprovado, reprovado, cancelado, encerrado, processando, contingencia or denegado
"motivo": "Autorizado o uso da MDF-e", // Reason for the status
"serie": 1, // MDF-e series
"mdfe": 123, // MDF-e number
"xml": "https://api.webmania.com.br/xmlmdfe/[chave]",
"damdfe": "https://api.webmania.com.br/damdfe/[chave]",
"log": {} // Sample object; reply content from SEFAZ
} Closing registers the end of the transport at SEFAZ. Close the MDF-e every time a delivery is complete: this is how the end of the transport service is recognized. Only an MDF-e with status aprovado can be closed. A closed MDF-e no longer accepts cancellation or new drivers.
To close an MDF-e, send a PUT request to the URL /2/mdfe/encerrar. Send the uuid or the chave of the MDF-e and the place where the trip ended: uf and municipio together, or codigo_municipio. When you send the code, it takes priority to identify the city.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
uuid | chave | string | 36 | 44 | Send at least one identifier: the UUID (36 characters) or the access key (44 characters). If you send both, the access key takes priority. | |
uf | string | 2 | Two-letter code of the state where the trip ended. Required when codigo_municipio is not sent. | |
municipio | string | 2-60 | City where the trip ended. Required when codigo_municipio is not sent. | |
codigo_municipio | string | 7 | 7-digit IBGE code (official city code) of the city where the trip ended. Required when uf or municipio is not sent. It replaces the city name and state pair. |
Request example:
curl -X PUT \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"chave": "00000000000000000000000000000000000000000000",
"uf": "PR",
"municipio": "Curitiba"
}' \
https://api.webmania.com.br/2/mdfe/encerrar The response includes status, motivo and log. When the closing is registered, it also includes the xml. For the other data of the document, use the lookup.
| Situation | Response | What to do |
|---|---|---|
| Closing registered | status = encerrado | The MDF-e is closed. Webmania also sends the encerrado notification. |
| Closing rejected by SEFAZ | status = reprovado, no xml | The MDF-e keeps the status aprovado. Read the motivo before you try again. |
| Request not processed by SEFAZ | error | Read the error message, fix what it points to and try again. |
Example of an HTTP 200 response for a registered closing. The content of motivo comes from the SEFAZ reply; this example is for illustration only:
{
"status": "encerrado",
"motivo": "Evento registrado e vinculado ao MDF-e",
"xml": "https://api.webmania.com.br/xmlmdfe/[chave]/",
"log": {} // Sample object; reply content from SEFAZ
} Cancellation registers an event at SEFAZ that voids an authorized MDF-e, for example when the trip does not happen. Once canceled, the MDF-e cannot be used for transport. Only an MDF-e with status aprovado can be canceled: a closed MDF-e does not accept cancellation.
To cancel an MDF-e, send a PUT request to the URL /2/mdfe/cancelar, with the uuid or the chave of the MDF-e and the justificativa (reason) for the cancellation.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
uuid | chave | string | 36 | 44 | Send at least one identifier: the UUID (36 characters) or the access key (44 characters). If you send both, the access key takes priority. | |
justificativa | string | 15-255 | Reason for the cancellation |
Request example:
curl -X PUT \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"chave": "00000000000000000000000000000000000000000000",
"justificativa": "Cancelado por motivos administrativos."
}' \
https://api.webmania.com.br/2/mdfe/cancelar The response includes status, motivo and log. When the cancellation is registered, it also includes the xml. For the other data of the document, use the lookup.
| Situation | Response | What to do |
|---|---|---|
| Cancellation registered | status = cancelado | Do not use this MDF-e for transport. Webmania also sends the cancelado notification. |
| Cancellation rejected by SEFAZ | status = reprovado, no xml | The MDF-e keeps the status aprovado. Read the motivo before you try again. |
| Request not processed by SEFAZ | error | Read the error message, fix what it points to and try again. |
Example of an HTTP 200 response for a registered cancellation. The content of motivo comes from the SEFAZ reply, not from the reason you sent; this example is for illustration only:
{
"status": "cancelado",
"motivo": "Evento registrado e vinculado ao MDF-e",
"xml": "https://api.webmania.com.br/xmlmdfe/[chave]/",
"log": {} // Sample object; reply content from SEFAZ
} Adding a driver registers a new driver at SEFAZ on an authorized road transport MDF-e. The MDF-e keeps the status aprovado. A driver can only be added while the MDF-e is not closed or canceled.
To add a driver, send a PUT request to the URL /2/mdfe/condutor, with the uuid or the chave of the MDF-e and the nome (name) and cpf of the new driver.
| Parameter | Required | Type | Size | Description |
|---|---|---|---|---|
uuid | chave | string | 36 | 44 | Send at least one identifier: the UUID (36 characters) or the access key (44 characters). If you send both, the access key takes priority. | |
cpf | string | 11 | Valid CPF (individual taxpayer ID) of the driver. Send the 11 digits without punctuation: the value goes to the event as sent, and any formatting is not removed. | |
nome | string | 1-60 | Name of the driver. Required, up to 60 characters. |
Request example:
curl -X PUT \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"chave": "00000000000000000000000000000000000000000000",
"cpf": "00000000000",
"nome": "Novo Condutor"
}' \
https://api.webmania.com.br/2/mdfe/condutor The response includes status, motivo and log. When the driver is added, it also includes the xml. Here, status is the result of the event:
| Situation | Response | What to do |
|---|---|---|
| Driver added | status = aprovado | The driver was registered and the MDF-e is still authorized. Adding a driver does not send a notification: store this response. |
| Driver rejected by SEFAZ | status = reprovado, no xml | The driver was not added. Read the motivo before you try again. |
| Request not processed by SEFAZ | error | Read the error message, fix what it points to and try again. |
Example of an HTTP 200 response for an added driver. The content of motivo comes from the SEFAZ reply; this example is for illustration only:
{
"status": "aprovado",
"motivo": "Evento registrado e vinculado ao MDF-e",
"xml": "https://api.webmania.com.br/xmlmdfe/[chave]/",
"log": {} // Sample object; reply content from SEFAZ
} Webmania® detects automatically when SEFAZ is offline or has not returned a result yet. It completes the MDF-e without your application having to send anything again:
| Situation | Status | What Webmania does |
|---|---|---|
| SEFAZ has not returned the result yet | processando | Checks SEFAZ automatically until it gets the result. |
| SEFAZ is unavailable | contingencia | Keeps the MDF-e in a queue and sends it again automatically. Before sending it again, it checks SEFAZ so the same MDF-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 MDF-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 MDF-e again.
The MDF-e is sent to SEFAZ synchronously, but a temporary reply can keep the status processando. This status does not mean authorization. Follow the same document through the lookup before you request a new issue.
The status contingencia also does not prove that SEFAZ authorized the document. It does not mean the document was authorized in an alternative environment either. Neither status is notified; your url_notificacao receives the final result. See Notifications.
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 processing and contingency sections now have a flowchart from the request to the final result, with the statuses that are not final 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.