I want to create new address for my users from my server. I’m using the API provided by VTEX, in this case I want to add/edit address on my costumers, I’m using the " Create new customer address" API
https://{accountName}.{environment}.com.br/api/dataentities/AD/documents
The body doesn’t ask for a geoCoordinates, and I want to store the coordinates of the user.
When my customers register an address from the frontend in VTEX the geoCoordinates are saved on the master data Indeed but I can’t achieve this behavior through the API
1 Like
Hi Juan! Welcome to the VTEX Community
To create a new address for your users with geoCoordinates using the VTEX API, you’ll need to ensure that the geoCoordinates field is included in your request body. Although the standard documentation for creating a new customer address might not explicitly mention geoCoordinates, VTEX Master Data allows for custom fields.
Here’s how you can add geoCoordinates when creating or editing an address via the VTEX API:
curl -X POST "https://{accountName}.{environment}.com.br/api/dataentities/AD/documents" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-VTEX-API-AppKey: {appKey}" \
-H "X-VTEX-API-AppToken: {appToken}" \
-d '{
"userId": "customer-id",
"addressName": "Home",
"addressType": "residential",
"city": "Rio de Janeiro",
"state": "RJ",
"country": "BRA",
"postalCode": "22250040",
"street": "Praia de Botafogo",
"number": "300",
"complement": "2nd floor",
"neighborhood": "Botafogo",
"geoCoordinates": "[-22.9443688,-43.1825604]"
}'
1 Like
Thanks I found that when I use the the api “Get client by profile by email” in the available address it return geoCoordinates, but when I’m creating using the post I have to send geoCoordinate without the “s” that solved the issue, kinda weird that behavior from the API.
1 Like