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 code | Five digits, required: 03100. The only part of the address a quote checks |
| State | A two-letter code from the catalog, in state. Mexico City is CX |
| City | As Geocodes returns it for the postal code: Ciudad de México |
| Colonia | In district. Some carriers refuse the label without it |
| House number | number, in its own field, required to create a label |
| Tax ID | The RFC, in identificationNumber. Optional |
| Currency | MXN |
| In sandbox | Estafeta 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:
| Field | Required | What goes in it |
|---|---|---|
street | yes | Av. Insurgentes Sur — the street only |
number | yes, for the label | The exterior number — 1602. The form calls it Address2 and marks it optional, but the label requires it |
district | send it | The colonia — Del Valle Centro. The form marks it optional; Paquetexpress refuses a label without it |
city | yes | Ciudad de México, or the municipality outside the capital |
state | yes | A two-letter code from the catalog — CX, NL, JA. Never the name |
postalCode | yes | Five digits — 03100 |
identificationNumber | no | The RFC |
reference | no | Interior 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/03100No 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": ""
}
}
]| Take | For |
|---|---|
state.code["2digit"] | state |
locality | city |
One of suburbs | district. 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=MXNo 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
| Send | Also in the catalog | Name |
|---|---|---|
AG | AGS | Aguascalientes |
BC | BCN | Baja California |
BS | BCS | Baja California Sur |
CM | CAM | Campeche |
CS | CHP | Chiapas |
CH | CHH | Chihuahua |
CX | CMX | Ciudad de México |
CO | COA | Coahuila |
CL | COL | Colima |
DG | DGO | Durango |
GT | GTO | Guanajuato |
GR | GRO | Guerrero |
HG | HGO | Hidalgo |
JA | JAL | Jalisco |
MI | MIC | Michoacán |
MO | MOR | Morelos |
EM | MEX | México |
NA | NAY | Nayarit |
NL | NLE | Nuevo León |
OA | OAX | Oaxaca |
PU | PUE | Puebla |
QT | QRO | Querétaro |
QR | ROO | Quintana Roo |
SL | SLP | San Luis Potosí |
SI | SIN | Sinaloa |
SO | SON | Sonora |
TB | TAB | Tabasco |
TM | TAM | Tamaulipas |
TL | TLA | Tlaxcala |
VE | VER | Veracruz |
YU | YUC | Yucatán |
ZA | ZAC | Zacatecas |
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. Itsgroundis quoted but cannot be booked: the label answers1172. - 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. trackUrlopens 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
Ship within Mexico from start to finish: validate the address, choose a carrier, buy the label and track it.
Ship from Mexico to the United States with the customs documents the border requires.
What an address needs in each country, where each value comes from, and five rules that apply everywhere.
Updated 13 days ago