How to Validate Addresses
Catch wrong or incomplete addresses before you buy a label. Failed deliveries, return-to-sender fees and courier address-correction surcharges all start with a bad address.
public.address_validation:writeWhat validation does for you
Checks that couriers recognise the address.
Fills in a missing postal code, corrects typos, and fixes a postal code that doesn't match the city.
Formats the address the way the local postal service and couriers expect it.
Converts non-Latin scripts to Latin: Улица Ленина 12 → Ulica Lenina 12.
Where to use it: at checkout (ask the buyer to confirm a correction), when importing orders in bulk, and before shipping to countries with non-Latin scripts.
Validate an address
- Send the address
Required:
line_1,city,country_alpha2. Optional, but they improve accuracy:postal_code,state,line_2,company_name.cURLcurl -X POST https://public-api.easyship.com/2024-09/addresses/validations \ -H "Authorization: Bearer $EASYSHIP_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "line_1": "10 Downing Street", "city": "London", "postal_code": "SW1A 2AA", "country_alpha2": "GB", "replace_with_validation_result": false }' - Read the resultResponse{ "address": { "id": "01563646-58c1-4607-8fe0-cae3e33c0001", "line_1": "10 Downing Street", "city": "London", "postal_code": "SW1A 2AA", "country_alpha2": "GB", "validation": { "status": "verified", "detail": "premise", "comparison": { "pre": "premise", "post": "premise", "changes": "none" }, "address": { "line_1": "10 Downing Street", "city": "London", "state": "London", "postal_code": "SW1A 2AA", "company_name": "Prime Minister's Office" } } } }
- Decide what to do
The
validationobject has four parts. Checkstatusfirst, thencomparison.changes.validation.status: was the address found?statusMeaning verified The address was matched to a known, deliverable address partial Only part of the address could be matched (for example, the street but not the building) ambiguous More than one possible match; the address needs more detail none The address couldn't be verified validation.comparison.changes: how much the returned address differs from what you sent, based on a 0–100 match score.changesMatch score Suggested action none 100 Use the address as sent minor 95–99 (for example, capitalisation or a single character) Use validation.addressmoderate 90–94 Show the suggestion and let the buyer confirm major 80–89 Ask the buyer to confirm or re-enter drastic 0–79 Ask the buyer to re-enter the address validation.detailis the most precise level the returned address reaches:premise(building),street,cityornone.validation.comparison.pre/postshow that level before and after correction, from most to least precise:delivery_point→premise→street→city→state→none. For example,pre: streetandpost: premisemeans validation added the building.
replace_with_validation_result: set it to true to save the corrected address automatically. Leave it false when the buyer should confirm the change first.FAQ
/addresses/validations with "country_alpha2": "US". The old domestic endpoint will stop working on 31 October 2026.422 invalid_content?line_1, city and country_alpha2 are required.state required?Updated about 18 hours ago
