Addresses by Country
What an address needs in each country, where each value comes from, and five rules that apply everywhere.
Every country wants a street, a city and a state. What changes is where those values come from, and five rules that hold everywhere.
Get Address Structure by Country returns the exact field list for any country, live. This page is about what the field list does not tell you.
This page is the address API. Address Rules by Country is the address form.
Build your form from that page — it carries the live field matrix for all 244 destination countries, generated from
GET /generic-formagainst production. Build your requests from this one.They are not the same, and the gap is the first rule below: the form has no
postal_codefield in 74 countries and the API requires it in all of them.
Five rules that apply to every country
API reference → Get states by country · What a route requires: taxes, items and customs paperwork
1. postalCode is always required — including where there is none
postalCode is always required — including where there is noneThis is the one that costs people a day. 74 countries have no postal code field at all — Chile, Colombia, Guatemala, Hong Kong, Peru, Bolivia and Panama among them — and three more, India, Lebanon and Uruguay, make it optional. The Shipping API requires it anyway, because it is required in the address schema for every country. Leave it out and you get, inside an HTTP 200 like every Shipping API error:
{ "meta": "error", "error": { "code": 400, "message": "Required property missing: postalCode" } }| Country | What to send |
|---|---|
CO Colombia | Anything. The DANE code goes in city, not here — see Shipping to Colombia |
GT Guatemala | Anything. It is required and not validated |
CL PE HK | A placeholder. Minimum three characters; an empty string is rejected |
2. state is a code of 2 or 3 characters, never a name
state is a code of 2 or 3 characters, never a nameThe schema is minLength: 2, maxLength: 3. Send a name and you get a length error that names a schema path rather than the problem:
{ "meta": "error", "error": { "code": 400, "message": "String is too long at #->properties:origin->$ref[#/definitions/address]->properties:state" } }Only the length is checked. The API does not compare the code with the catalog, so a made-up code of the right length can still get a quote and fail later. Take the code from the catalog.
Most countries give a two-letter code. Twenty only publish a three-letter one — their code_2_digits is null — Hong Kong, Afghanistan, New Zealand, Belgium and Puerto Rico among them.
When a country has both, either one resolves in the catalog: GET /state/PE/AM and GET /state/PE/AMA both answer Amazonas. But a three-letter code is not always unique. LIM is both Lima (LP) and Lima Capital (LR):
curl https://queries.envia.com/state/PE/LIMSo where a country gives two letters, send the two letters.
3. The field is identificationNumber, not identification_number
identificationNumber, not identification_numberThe address form names it in snake_case; the API uses camelCase and ignores identification_number, so the shipment would go out without the tax ID.
Required on both origin and destination for BR Brazil and CO Colombia. Optional elsewhere, absent entirely in AU, CA, GT and UY.
4. Ask what the route needs — do not branch on the country code
Whether a shipment needs items[] and a commercial invoice is not origin.country !== destination.country. A domestic Spanish parcel to the Canary Islands needs customs paperwork; a parcel between two EU countries does not. (Brazil is a different case: some carriers want a fiscal document on a domestic parcel — see Shipping to Brazil.)
curl -X POST https://geocodes.envia.com/location-requirements \
-H 'Content-Type: application/json' \
-d '{"origin":{"country_code":"ES","state_code":"M","postal_code":"28001"},
"destination":{"country_code":"ES","state_code":"TF","postal_code":"38001"}}'{ "applyTaxes": false, "includeBOL": true, "isInternalEU": true,
"isInternalGB": false, "isInternalUK": false }applyTaxes: false on a Madrid → Tenerife shipment means items[] are required. includeBOL is always the opposite of applyTaxes — it carries no information of its own, so read applyTaxes. It is true within one country, between the US and Puerto Rico, and within the EU, unless the route touches a territory with its own tax regime: the Canary Islands, Ceuta, Melilla, the Azores, Madeira, the French overseas departments, Sint Maarten. Envia's own client libraries call this on every quote rather than hardcoding those territories.
5. number is required to create a label — even where the form has no such field
number is required to create a label — even where the form has no such fieldThe address form marks number optional in most countries, and Colombia, Guatemala, Honduras and Macao have no number field at all. The label call requires it anyway, in every country — Chile, Colombia and Guatemala all refuse a label without it.
{ "meta": "error", "error": { "code": 400, "message": "Required property missing: number" } }A quote works without it, so the error shows up at the label. Where an address has no separate house number — a Colombian Carrera 7 # 71-21 carries it in the street — send "number": "S/N".
Where the city and state values come from
API reference → Get states by country
state is always a catalog, in every country that has the field:
curl https://queries.envia.com/state?country_code=CLNo token needed.
city is a catalog in only two countries. Everywhere else it is free text:
| Country | city | Where the list comes from |
|---|---|---|
CO Colombia | a catalog | GET /locate/CO/{state}/{city} turns a name into the DANE code, which is what city must carry |
GT Guatemala | a catalog | No endpoint serves it. 1100 City was not found means the city does not match that department — Guatemala has the method and city names that work |
| everyone else | free text | Type it. Geocodes can suggest it where a postal code exists |
Do not useGET /provinces/{state_code}It takes no country code. It searches every country at once and answers with whichever country owns the code, always with
HTTP 200:
You ask for You get AN— Antofagasta, Chile or Andaman & Nicobar, IndiaAntioquia, Colombia AM— Amazonas, ColombiaAmazonas, Brazil TO— Tolima, ColombiaTocantins, Brazil SA— Sacatepéquez, GuatemalaSalto, Uruguay AL— Alabama, United StatesAlagoas, Brazil In Colombia, 8 of the 33 department codes return another country. Guatemala's codes are numeric and return an empty list.
Use
/locate/{country}/{state}/{city}instead — the country is in the path, so it cannot answer with the wrong one.
Postal codes that need reshaping before you send them
Three countries need the value transformed, and Envia's own clients do it for you. If you build your own, do the same:
| Country | Rule | Example |
|---|---|---|
BR Brazil | Insert - at position 5 when 8 digits or more | 01310200 → 01310-200 |
AR Argentina | Strip the leading letter when longer than 4 | C1425 → 1425 |
US ZIP+4 | 9 digits → hyphenated | 123456789 → 12345-6789 |
US other | More than 5 digits but not 9 → truncate to 5 | 123456 → 12345 |
Two more live on the carrier backend and need nothing from you: Spain's Canary postal codes (35xxx, 38xxx) are treated as the separate customs territory they are, and Italy's island ranges are detected the same way.
Two countries put the number in its own field
MX Mexico and BR Brazil expect the exterior number as number, separate from street. Elsewhere it can be part of the street line. In Mexico this is enforced when you create the label, not when you quote — so an address that quotes fine can still fail at label time.
In the address form, number is required only in BR Brazil and UY Uruguay. The API requires it everywhere — rule 5.
The sandbox form calls this fieldstreetNumberThirteen countries call the field
streetNumberin the sandbox form andnumberin production — Australia, Canada, Ecuador, Hong Kong, India, Peru, Uruguay and six more; the full list is in Address Rules by Country.Send
number. In Uruguay it is required, and a label request that sendsstreetNumberis refused. Guatemala's form saysstreetNumbereven in production; sendnumberthere too (rule 5).
Per country
The countries with their own guide:
- Shipping to Mexico — the postal code gives you the state, the city and the colonias, and a full shipment with Estafeta
- Shipping to Chile — no postal code, 16 regions, a free-text city, and a full shipment with DHL
- Shipping to Colombia — the DANE code in
city, and a full shipment with FedEx - Shipping to Guatemala — a city catalog the API does not publish, and how to find names that work
- Shipping to Brazil — a required CPF or CNPJ, the CEP with its hyphen, an origin branch and the fiscal document some carriers need
- Shipping to Peru — two department codes, one of them ambiguous, and what you can test in sandbox
- Shipping to India — the PIN code every quote needs, and a full shipment with Blue Dart
- Shipping to Hong Kong — a destination only, with no postal code and a district code from the catalog
The other twelve — AF AR AU CA CN ES FR IT JP SG US UY — have no page of their own: the postal code is required and visible, it resolves city and state, and city is free text. The five rules above still apply, and so do the per-country notes on this page — Uruguay's number, the sandbox field names. For the fields to ask the buyer for, use GET /generic-form?country_code=XX&form=address_info; for the names to send, use Create Shipping Label.
Next steps
Ship within Mexico: the postal code gives you the state, the city and the colonias. Send them, with the street number apart.
Ship to Colombia with the DANE municipal code, which takes the place of the postal code.
Ship to Brazil: the CEP with its hyphen, a CPF or CNPJ on both ends, and the fiscal document some carriers need.
Updated 14 days ago