Documentation
Feedback
Guides
API Reference

Guides
CheckoutFulfillmentGet address by postal code
Get address by postal code

To assist the customer in the process of filling in data at Checkout and also to select the sellers able to deliver the product in a certain area, it is possible to register postal codes and assign them to addresses in the VTEX database. For more information about deliveries, visit Inventory & shipping - Overview.

This guide describes how to obtain the registered address information for a specific postal code and country.

Getting address by postal code

To get the registered address information for a postal code, you need to use the Get address by postal code endpoint. The country and postal code information must be sent through the URL request, as shown by the example below:

https://{accountname}.{environment.com.br}/api/checkout/pub/postal-code/BRA/22250040

After sending the request, the endpoint will return the response body containing the address information registered, as shown in the example below:


_17
...
_17
{
_17
"postalCode": "22250040",
_17
"city": "Rio de Janeiro",
_17
"state": "RJ",
_17
"country": "BRA",
_17
"street": "Praia Botafogo",
_17
"number": "",
_17
"neighborhood": "Botafogo",
_17
"complement": "",
_17
"reference": "",
_17
"geoCoordinates": [
_17
-43.182182312011719,
_17
-22.94549560546875
_17
]
_17
}
_17
...

Error codes

The following errors may appear as a message in the response body.

200 - OK

Despite the code 200 (which indicates the success of the request), if there is no registered address in the VTEX database associated with the entered postal code or country, the response body will not contain any address information.


_12
{
_12
"postalCode": "222500",
_12
"city": "",
_12
"state": "",
_12
"country": "BRA",
_12
"street": "",
_12
"number": "",
_12
"neighborhood": "",
_12
"complement": "",
_12
"reference": "",
_12
"geoCoordinates": []
_12
}

404 - Not Found

  • Message error example: "The requested URL was not found on the server": check that the URL data is correct.

_10
<body>
_10
<h1>404 Not Found</h1>
_10
<p>The requested URL was not found on this server.</p>
_10
</body>

500 - Internal Server Error

  • Message error example (code ORD026): "A communication error with Postal Code Service has occurred": this message will appear when less than three country code digits are entered in the URL request.

_10
{
_10
"fields": {},
_10
"error": {
_10
"code": "ORD026",
_10
"message": "A communication error with Postal Code Service has occurred",
_10
"exception": null
_10
},
_10
"operationId": "9e8e40ad-f98d-4e36-81f3-1937caa83f1c"
_10
}

Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
On this page