Fulfillment - How to generate a sales receipt

To enhance the buying experience on the Fulfillment platform, sellers may automatically send sales receipts via our API. To use this feature, the seller should contact the relevant business representative. To be able to operate, it will be mandatory to have a store (branch) in fulfillment warehouse/s. Note: Bear in mind that the time from shipment creation to sales receipt load via API should not be longer than 60 seconds.

Content

Notification subscription

Bear in mind that the development should be subscribed to "shipments" notifications; you should subscribe from MyApps. Check our documentation to learn how to work with notifications. You will start receiving notifications upon sales generation on the platform and payment confirmation. Notification example
{
    "resource": "/shipments/139876",
    "user_id": 1234,
    "topic": "shipments",
    "received": "2011-10-19T16:38:34.425Z",
    "sent" : "2011-10-19T16:40:34.425Z",
}

Query shipment status

With the shipment ID, you will be able to make a GET to the shipments resource and retrieve all the information about it:
curl -H "x-format-new:true" https://api.mercadolibre.com/shipments/{shipment_id}?access_token=ACCESS_TOKEN
Confirmando que o envio tenha status = “handling” y substatus = “invoice_pending”, se procederá a gerar a nota fiscal.

Billing Info

The /shipments resource consists of different resources which offer the information required for the seller to arrange the logistics. The billing_info resource helps get tax information about the different players involved in product shipment.
curl https://api.mercadolibre.com/shipments/{shipment_id}/billing_info?access_token=ACCESS_TOKEN
Example
GET 
https://api.mercadolibre.com/shipments/26474580996/billing_info?access_token=ACCESS_TOKEN
{
	"receiver": {
		"id": 154808171,
		"document": {
			"id": "CPF",
			"value": "02972404475"
		},
		"additional_documents": []
	},
	"senders": [{
		"id": 168777350,
		"document": {
			"id": "CNPJ",
			"value": "21611372000396"
		},
		"additional_documents": [{
			"id": "IE",
			"value": "421038162111"
		}]
	}],
	"carrier": {
		"document": {
			"id": "CNPJ",
			"value": "20121850000317" 
		},
		"additional_documents": []
	}
}
Considerations:
  • Each one of the “additional_documents” may include a list of other documents which might be required.
  • If you need to get the information of the products to be shipped, go to the shipments/{id}/items e /items/{id} resources.

Send an electronic sales receipt

With all the information available, you will be able to generate an NFE (Nota Fiscal Electrónica) [Electronic Sales Receipt]. Once generated, you should make the following PUT to send it to Mercado Libre.
curl -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -d

'[{"data":"(insert the NFE XML)"}]'

https://api.mercadolibre.com/shipments/{shipment_id}/invoices?access_token=YOUR_ACCESS_TOKEN
If the PUT is successful, you will receive a 200 OK; shipment status will subsequently change to “ready_to_ship,” and its sub-status will change to “in_warehouse”. This could fail due to three reasons: XML missing body Result: {"message":"No invoices present","error":"no_invoices_present","status":400,"cause":null} Malformed XML Result: {"message":"Malformed XML","error":"malformed_xml","status":400,"cause":null} Errors in XML fields Result: {"message":"Invalid Invoice File","error":"invalid_invoice","status":400,"cause":null}

Be part of our community