Shipping to Mexico

Ship within Mexico: the postal code gives you the state, the city and the colonias. Send them, with the street number apart.

In Mexico the postal code decides the price and the route, and it is the only part of the address a quote checks. Take the state, the city and the colonia from the postal code, and send the street number in its own field.

At a glance

Postal codeFive digits, required: 03100. The only part of the address a quote checks
StateA two-letter code from the catalog, in state. Mexico City is CX
CityAs Geocodes returns it for the postal code: Ciudad de México
ColoniaIn district. Some carriers refuse the label without it
House numbernumber, in its own field, required to create a label
Tax IDThe RFC, in identificationNumber. Optional
CurrencyMXN
In sandboxEstafeta runs the full cycle; DHL, FedEx and iMile create and cancel labels

What an address to Mexico needs

The fields of a Mexican address. Where the address form (GET /generic-form?country_code=MX&form=address_info) differs, the table says so:

FieldRequiredWhat goes in it
streetyesAv. Insurgentes Sur — the street only
numberyes, for the labelThe exterior number — 1602. The form calls it Address2 and marks it optional, but the label requires it
districtsend itThe colonia — Del Valle Centro. The form marks it optional; Paquetexpress refuses a label without it
cityyesCiudad de México, or the municipality outside the capital
stateyesA two-letter code from the catalog — CX, NL, JA. Never the name
postalCodeyesFive digits — 03100
identificationNumbernoThe RFC
referencenoInterior number and directions for the driver — Interior 4, timbre azul

There is no field for the interior number: put it in reference.

Step 1 — Look up the postal code

API reference → Location by postal code

curl https://geocodes.envia.com/zipcode/MX/03100

No token needed. The response is an array:

[
  {
    "zip_code": "03100",
    "country": {
      "name": "México",
      "code": "MX"
    },
    "state": {
      "name": "Ciudad de Mexico",
      "iso_code": "MX-CMX",
      "code": {
        "1digit": null,
        "2digit": "CX",
        "3digit": "CMX"
      }
    },
    "locality": "Ciudad de México",
    "additional_info": {
      "street": null
    },
    "suburbs": [
      "Del Valle Centro",
      "Insurgentes San Borja"
    ],
    "coordinates": {
      "latitude": "19.386093",
      "longitude": "-99.169136"
    },
    "info": {
      "stat": "09014",
      "stat_8digit": "09014000",
      "time_zone": "America/Mexico_City",
      "utc": "-06:00"
    },
    "regions": {
      "region_1": "Ciudad de Mexico",
      "region_2": "Benito Juárez",
      "region_3": "",
      "region_4": ""
    }
  }
]
TakeFor
state.code["2digit"]state
localitycity
One of suburbsdistrict. A postal code can cover several colonias: 03100 covers two, so let the buyer choose

A postal code that does not exist returns [], and carriers refuse to quote it: DHL answers 1140 ("Price plan requested not found"), Estafeta 1102.

The quote checks only the postal code. A state from another part of the country, or a city that does not exist, still gets a quote and a label, and the label prints what you sent. Take the state, the city and the colonia from step 1.

Step 2 — The state code

API reference → Get states by country

curl https://queries.envia.com/state?country_code=MX

No token needed. Send code_2_digits, the code Geocodes returns. The quote also accepts the three-letter code (CMX) and the old DF, but a name is too long for the field and fails.

All 32 states and their codes
SendAlso in the catalogName
AGAGSAguascalientes
BCBCNBaja California
BSBCSBaja California Sur
CMCAMCampeche
CSCHPChiapas
CHCHHChihuahua
CXCMXCiudad de México
COCOACoahuila
CLCOLColima
DGDGODurango
GTGTOGuanajuato
GRGROGuerrero
HGHGOHidalgo
JAJALJalisco
MIMICMichoacán
MOMORMorelos
EMMEXMéxico
NANAYNayarit
NLNLENuevo León
OAOAXOaxaca
PUPUEPuebla
QTQROQuerétaro
QRROOQuintana Roo
SLSLPSan Luis Potosí
SISINSinaloa
SOSONSonora
TBTABTabasco
TMTAMTamaulipas
TLTLATlaxcala
VEVERVeracruz
YUYUCYucatán
ZAZACZacatecas

The list comes from GET /state?country_code=MX.

A complete address

{
  "name": "Luis Pérez",
  "email": "[email protected]",
  "phone": "+52 55 0000 0000",
  "street": "Av. Insurgentes Sur",
  "number": "1602",
  "district": "Del Valle Centro",
  "city": "Ciudad de México",
  "state": "CX",
  "postalCode": "03100",
  "country": "MX",
  "reference": "Interior 4, timbre azul"
}

Ship it, end to end

One shipment from start to finish: Monterrey → Ciudad de México, with Estafeta. Every request runs as written in sandbox, with the address above as the destination; only the tracking number is a placeholder.

Find the carriers that serve the lane

API reference → Get Carriers With Services

curl https://queries.test.envia.com/available-carrier/MX/0/1 \
  --header "Authorization: Bearer $ENVIA_TOKEN"

MX/0/1 reads: from Mexico, domestic (0), parcel (1). Each carrier comes with the services you can pass when you create the label: for Estafeta, local, ground and express.

Quote

API reference → Get Shipping Rates

curl --request POST \
  --url https://api-test.envia.com/ship/rate/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "origin": {
      "name": "Almacén Monterrey",
      "company": "Tienda Demo",
      "email": "[email protected]",
      "phone": "+52 81 0000 0000",
      "street": "Av. Benito Juárez",
      "number": "1500",
      "district": "Centro",
      "city": "Monterrey",
      "state": "NL",
      "postalCode": "64000",
      "country": "MX"
    },
    "destination": {
      "name": "Luis Pérez",
      "email": "[email protected]",
      "phone": "+52 55 0000 0000",
      "street": "Av. Insurgentes Sur",
      "number": "1602",
      "district": "Del Valle Centro",
      "city": "Ciudad de México",
      "state": "CX",
      "postalCode": "03100",
      "country": "MX",
      "reference": "Interior 4, timbre azul"
    },
    "packages": [
      {
        "content": "Ropa",
        "amount": 1,
        "type": "box",
        "weight": 1,
        "insurance": 0,
        "declaredValue": 0,
        "weightUnit": "KG",
        "lengthUnit": "CM",
        "dimensions": {
          "length": 20,
          "width": 20,
          "height": 10
        }
      }
    ],
    "shipment": {
      "carrier": "estafeta",
      "type": 1
    },
    "settings": {
      "currency": "MXN"
    }
  }'

shipment.carrier takes one carrier per request; call it once per carrier to compare. Prices come back in settings.currency.

{
  "meta": "rate",
  "data": [
    {
      "carrier": "estafeta",
      "service": "express",
      "serviceDescription": "Estafeta Siguiente Día",
      "dropOff": 0,
      "dropOffDescription": "Puerta a puerta",
      "deliveryEstimate": "Día siguiente",
      "totalPrice": 191.72,
      "currency": "MXN"
    }
  ]
}

deliveryEstimate is text for a person, in Spanish as the carrier sends it. Show it as is. dropOff says where the parcel starts and ends: 0 door to door, 1 branch to door, 2 door to branch. A service with 1 needs origin.branchCode.

Create the label

API reference → Generate a Shipping Label

curl --request POST \
  --url https://api-test.envia.com/ship/generate/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "origin": {
      "name": "Almacén Monterrey",
      "company": "Tienda Demo",
      "email": "[email protected]",
      "phone": "+52 81 0000 0000",
      "street": "Av. Benito Juárez",
      "number": "1500",
      "district": "Centro",
      "city": "Monterrey",
      "state": "NL",
      "postalCode": "64000",
      "country": "MX"
    },
    "destination": {
      "name": "Luis Pérez",
      "email": "[email protected]",
      "phone": "+52 55 0000 0000",
      "street": "Av. Insurgentes Sur",
      "number": "1602",
      "district": "Del Valle Centro",
      "city": "Ciudad de México",
      "state": "CX",
      "postalCode": "03100",
      "country": "MX",
      "reference": "Interior 4, timbre azul"
    },
    "packages": [
      {
        "content": "Ropa",
        "amount": 1,
        "type": "box",
        "weight": 1,
        "insurance": 0,
        "declaredValue": 0,
        "weightUnit": "KG",
        "lengthUnit": "CM",
        "dimensions": {
          "length": 20,
          "width": 20,
          "height": 10
        }
      }
    ],
    "shipment": {
      "carrier": "estafeta",
      "type": 1,
      "service": "express"
    },
    "settings": {
      "currency": "MXN",
      "printFormat": "PDF",
      "printSize": "STOCK_4X6"
    }
  }'
{
  "meta": "generate",
  "data": [
    {
      "carrier": "estafeta",
      "service": "express",
      "trackingNumber": "7000000000000000000001",
      "trackUrl": "https://test.envia.com/rastreo?label=7000000000000000000001&cntry_code=mx",
      "label": "https://…/estafeta/7000000000000000000001.pdf",
      "totalPrice": 191.72,
      "currency": "MXN"
    }
  ]
}

The label costs what the quote said: a Mexican account quotes and is charged in MXN.

Track it

API reference → Track Shipments

curl --request POST \
  --url https://api-test.envia.com/ship/generaltrack/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "trackingNumbers": [
      "7000000000000000000001"
    ]
  }'

A label you just created answers "status": "Created". For anything at volume, subscribe to webhooks instead of polling.

Cancel it, if it does not ship

API reference → Cancel a Shipment

curl --request POST \
  --url https://api-test.envia.com/ship/cancel/ \
  --header "Authorization: Bearer $ENVIA_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "carrier": "estafeta",
    "trackingNumber": "7000000000000000000001"
  }'

The response includes refundedAmount and balanceReturned: the charge returns to your balance.

International, into and out of Mexico

A shipment that crosses the Mexican border is an ordinary international shipment: see International Shipping & Customs, and the international guide, which ships from Mexico to the United States. From a Mexican account, declaredValue and items[].price are read in MXN.

Testing in sandbox

Which Mexican carriers work in sandbox
  • Estafeta runs the full cycle with express. Its ground is quoted but cannot be booked: the label answers 1172.
  • DHL, FedEx and iMile create and cancel labels.
  • Paquetexpress creates labels, and refuses one without the colonia: El nombre de la Colonia destino es obligatoria.
  • UPS issues labels with the placeholder tracking number 1ZXXXXXXXXXXXXXXXX, which cannot be tracked or canceled. Do not create UPS labels in sandbox: the charge stays on your test balance.
  • iVoy, J&T Express, Quiken and Sendex answer with internal errors, and 99minutos with 1125.
  • trackUrl opens a tracking page that does not know sandbox shipments. It works for labels created in production.

In production you use the carriers enabled on your account.

Next steps


Did this page help you?