Query Fiscal Information for Shipment

Introduction

This API aims to provide fiscal data to carriers involved in the transportation process who want to access CT-e, DC-e, and NF-e data from Mercado Livre. When querying fiscal information by Shipment, it is possible to obtain fiscal data such as the electronic Invoice (NF-e) or the electronic Declaration of Content (DC-e).

Important: Make sure you have a valid application and token, and that you are authorized to use this endpoint. OAuth will be used for security.

Request

bash
1GET https://api.mercadolibre.com/shipments/{ShipmentID}/fiscal-info?access_token={token}

Response (NF-e)

json
1{ 2 "_links": { 3 "base": "https://api.mercadolibre.com", 4 "context": "", 5 "next": "", 6 "self": "/shipments/41591835367/fiscal-info?offset=0&limit=50" 7 }, 8 "limit": 50, 9 "offset": 0, 10 "id": 41591835367, 11 "receiver_identification": { 12 "number": "06163421957", 13 "type": "CPF" 14 }, 15 "fiscal_data": [ 16 { 17 "sender_identification": { 18 "number": "03007331001032", 19 "type": "CNPJ", 20 "state_tax_id": "0038450760305" 21 }, 22 "invoice": { 23 "key": "31220803007331001032550010056003661265933030", 24 "number": 5600366, 25 "serie": 1, 26 "amount": 249.9, 27 "date": "2022-08-17T09:22:04-03:00", 28 "cfop": 6108, 29 "document": { 30 "type": "nfe_document", 31 "href": "https://api.mercadolibre.com/shipping-tax-production/gateway/shipments/41591835367/dce/31220803007331001032550010056003661265933030?doctype=xml", 32 "format": "xml" 33 } 34 }, 35 "tax": { 36 "cte_key": "41210555555555555555555555555555555555555555", 37 "type": "ICMS", 38 "document": { 39 "type": "cte_document", 40 "href": "https://api.mercadolibre.com/shipping-tax-develop/gateway/cte/fiscal/41210555555555555555555555555555555555555555/download?doctype=xml", 41 "format": "xml" 42 } 43 } 44 } 45 ] 46}

The response is an array with the detailed fiscal data described below.

Response Fields

Name
Data Type
Description
Type
_linksobjectPagination data
_links.baseStringBase URL for API calls
_links.contextStringAdditional context for the base URL
_links.nextStringURL for the next set of results in pagination
_links.selfstringURL for the current set of results
limitintMaximum number of items to return
offsetintNumber of items to skip before returning results
idintDispatch ID
receiver_identification.numberstringReceiver's identification number (CPF/CNPJ)
receiver_identification.typestringReceiver's identification type (CPF or CNPJ)
fiscal_dataobjectFiscal data for the dispatch
fiscal_data.sender_identification.numberstringSender's identification number (CNPJ)
fiscal_data.sender_identification.typestringSender's identification type (CNPJ)
fiscal_data.sender_identification.state_tax_idstringSender's state tax ID
fiscal_data.invoiceobjectData related to the Invoice or Declaration of Content
fiscal_data.invoice.keystringInvoice or Declaration of Content key
fiscal_data.invoice.number*intInvoice number (this parameter exists only in NF-e)
fiscal_data.invoice.serie*intInvoice series (this parameter exists only in NF-e)
fiscal_data.invoice.amountdecimalTotal value of the Invoice or Declaration of Content
fiscal_data.invoice.datedatetimeInvoice or Declaration of Content issuance date
fiscal_data.invoice.cfop*stringTax Operations and Services Code — CFOP (this parameter exists only in NF-e)
fiscal_data.invoice.document.typestringDocument type (possible values: nfe_document or dce_document)
fiscal_data.invoice.document.hrefstringURL for the Invoice or Declaration of Content document
fiscal_data.invoice.document.formatstringDocument format (XML)
fiscal_data.taxobjectFiscal data
fiscal_data.tax.cte_keystringKey of the associated CT-e
fiscal_data.tax.typestringTax type (possible values: ICMS or ISS)
fiscal_data.tax.document.typestringFiscal document type (cte_document)
fiscal_data.tax.document.hrefstringURL for the CT-e document
fiscal_data.tax.document.formatstringDocument format (XML)

The _links object controls pagination data for fiscal-info elements, based on the offset field passed in the request parameters. The next field indicates the endpoint for the next page, and is left empty when no further pagination is needed. The next page URL is formed by: _links.base + _links.context + _links.next + security parameters.

DC-e Example

The example below shows an electronic Declaration of Content (DC-e) with the XML tags that will be returned. For more details, refer to the contract specified by CONFAZ for the DC-e.

DC-e XML Example

xml
1<?xml version="1.0" encoding="UTF-8"?> 2<DCe xmlns="http://www.portalfiscal.inf.br/dce"> 3 <infDCe> 4 <versao> </versao> 5 <id> </id> 6 <ide> 7 <cUF> </cUF> 8 <cDC> </cDC> 9 <mod> </mod> 10 <serie> </serie> 11 <nDC> </nDC> 12 <dhEmis> </dhEmis> 13 <tpEmis> </tpEmis> 14 <tpEmit> </tpEmit> 15 <nSiteAutoriz> </nSiteAutoriz> 16 <cDV> </cDV> 17 <tpAmb> </tpAmb> 18 <verProc> </verProc> 19 </ide> 20 <emit> 21 <cnpj> </cnpj> 22 <ie> </ie> 23 <cpf> </cpf> 24 <xNome> </xNome> 25 <idOutros> </idOutros> 26 <enderEmit> 27 <xLgr> </xLgr> 28 <nro> </nro> 29 <xCpl> </xCpl> 30 <xBairro> </xBairro> 31 <cMun> </cMun> 32 <xMun> </xMun> 33 <UF> </UF> 34 <CEP> </CEP> 35 <cPais> </cPais> 36 <xPais> </xPais> 37 <fone> </fone> 38 </enderEmit> 39 </emit> 40 <dest> 41 <cnpj> </cnpj> 42 <ie> </ie> 43 <cpf> </cpf> 44 <xNome> </xNome> 45 <idOutros> </idOutros> 46 <enderDest> 47 <xLgr> </xLgr> 48 <nro> </nro> 49 <xCpl> </xCpl> 50 <xBairro> </xBairro> 51 <cMun> </cMun> 52 <xMun> </xMun> 53 <UF> </UF> 54 <CEP> </CEP> 55 <cPais> </cPais> 56 <xPais> </xPais> 57 <fone> </fone> 58 <email> </email> 59 </enderDest> 60 </dest> 61 <det> 62 <nItem> </nItem> 63 <prod> 64 <xProd> </xProd> 65 <NCM> </NCM> 66 <qCom> </qCom> 67 <vUnitCom> </vUnitCom> 68 <vProd> </vProd> 69 </prod> 70 <infAdProd> </infAdProd> 71 </det> 72 <total> 73 <vDC> </vDC> 74 </total> 75 <transp> 76 <modTrans> </modTrans> 77 <CNPJTransp> </CNPJTransp> 78 <IETransp> </IETransp> 79 </transp> 80 </infDCe> 81</DCe>

HTTP Status Code Examples

If an error occurs, the API will return an HTTP status other than 200, an error message, the error, its cause, and the content-type will be application/json.

400 (NOT_OK)

json
1{ 2 "message": "description", 3 "error": "bad_request", 4 "status": 400, 5 "cause": [] 6}
HTTP Code
Content Type
Response Body
Description
200application/xmlXML (example above)Returns XML with shipment data and a list (fiscal_data).
400application/jsonResponse of 400 aboveThere is a problem with the request sent. The message field contains a brief description. The client should not repeat the request without modifying it, as repeated attempts may result in a temporary block.