CBT - Label

How to get my access token?

To generate your access token, follow the steps shown in how to get my access token

Request Format

The request should have the following format:

bash
1GET https://api.mercadolibre.com/shipments/{shipment_id}/documents/cbt_label?response_type={responseType}&label_type={labelType}&format_encoding={formatEncoding} 2 3--header 'Authorization: Bearer {accessToken}'

The label_type parameter is optional and allows explicitly requesting the label type:

  • first_mile | last_mile
  • If omitted (or unrecognized), legacy behavior applies and Labels decides the default.

The format_encoding parameter is optional and allows requesting the label content Base64-encoded in the response body:

  • Only base64 is accepted. Any other value returns HTTP 400.
  • If omitted, the response is returned as raw binary (legacy behavior).
  • When set to base64, two additional response headers are included:
    • X-Content-Format: the original document format (pdf or zpl).
    • Content-Transfer-Encoding: base64.

Response Format

An empty body is expected, and the format of the downloaded document will be determined by the value in the "response_type" key.

  • If "pdf" is specified, the document will be downloaded in PDF.
  • If "zpl" is specified and the route is USA-Mexico, the document will be downloaded in ZIP format.
  • If "response_type" is empty, the document will be downloaded in PDF format.
  • If format_encoding=base64 is sent, the body contains the document encoded as a Base64 string — clients must decode it before saving or printing.

Status Codes

Status
HTTP Code
Description
SUCCESS200Document will be downloaded.
FAILED4XXWhen the download was not successful, it is expected to return "error" along with the "message" that describes the reason for the error.
ERROR500Any server error

Examples

Request (binary, default):

bash
1GET https://api.mercadolibre.com/shipments/123132434/documents/cbt_label?response_type=pdf&label_type=last_mile 2 3--header 'Authorization: Bearer xxxxxxxxx'

Request (Base64-encoded):

bash
1GET https://api.mercadolibre.com/shipments/123132434/documents/cbt_label?response_type=pdf&label_type=last_mile&format_encoding=base64 2 3--header 'Authorization: Bearer xxxxxxxxx'

Response:

Successful (200 OK)

Default (binary) — the response body contains the raw document bytes:

HTTP/1.1 200 OK
Content-Type: application/pdf

<binary PDF content>

With format_encoding=base64 — the response body contains the Base64-encoded document, and two additional headers are included:

HTTP/1.1 200 OK
Content-Type: application/pdf
X-Content-Format: pdf
Content-Transfer-Encoding: base64

JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9MZW5ndGgg... (truncated)

Failed (Error HTTP 4XX)

json
1{ 2 "error": "error_get_document", 3 "message": "Shipment status is 'delivered'", 4 "status": 400 5}
json
1{ 2 "error": "bad_request", 3 "message": "Invalid response type", 4 "status": 400 5}
json
1{ 2 "error": "bad_request", 3 "message": "format_encoding must be 'base64'", 4 "status": 400 5}
json
1{ 2 "error": "shipment_not_found", 3 "message": "Shipment: 3002444733251", 4 "status": 404 5}

Error (Error HTTP 5XX)

json
1{ 2 "error": "internal_error", 3 "message": "Internal Server Error", 4 "status": 500 5}