Create an Address
Creates an Address
POST
/
api
/
v2
/
platform
/
addresses
Create an Address
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
address: {
country_id: '224',
address1: '5th ave',
city: 'NY',
zipcode: '10001',
phone: '+1 123 456 789',
firstname: 'John',
lastname: 'Snow',
state_id: '516',
state_name: 'New York',
address2: '1st suite',
alternative_phone: '<string>',
label: 'My home address',
company: 'Vendo Connect Inc',
user_id: '<string>',
public_metadata: {distance_from_nearest_city_in_km: 10, location_type: 'building'},
private_metadata: {close_to_shop: true}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/addresses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/addresses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"address": {
"country_id": "224",
"address1": "5th ave",
"city": "NY",
"zipcode": "10001",
"phone": "+1 123 456 789",
"firstname": "John",
"lastname": "Snow",
"state_id": "516",
"state_name": "New York",
"address2": "1st suite",
"alternative_phone": "<string>",
"label": "My home address",
"company": "Vendo Connect Inc",
"user_id": "<string>",
"public_metadata": {
"distance_from_nearest_city_in_km": 10,
"location_type": "building"
},
"private_metadata": {
"close_to_shop": true
}
}
}
'{
"data": {
"id": "5",
"type": "address",
"attributes": {
"firstname": "John",
"lastname": "Doe",
"address1": "5 Lovely Street",
"address2": "Northwest",
"city": "Herndon",
"zipcode": "35005",
"phone": "555-555-0199",
"state_name": null,
"alternative_phone": "555-555-0199",
"company": "Company",
"created_at": "2022-11-08T19:33:51.471Z",
"updated_at": "2022-11-08T19:33:51.471Z",
"deleted_at": null,
"label": null,
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"country": {
"data": {
"id": "4",
"type": "country"
}
},
"state": {
"data": {
"id": "5",
"type": "state"
}
},
"user": {
"data": {
"id": "1",
"type": "user"
}
}
}
}
}{
"error": "First Name can't be blank, Last Name can't be blank, Address can't be blank, City can't be blank, Country can't be blank, Zip Code can't be blank, and Phone can't be blank",
"errors": {
"firstname": [
"can't be blank"
],
"lastname": [
"can't be blank"
],
"address1": [
"can't be blank"
],
"city": [
"can't be blank"
],
"country": [
"can't be blank"
],
"zipcode": [
"can't be blank"
],
"phone": [
"can't be blank"
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Body
application/json
Show child attributes
Show child attributes
Response
Record created
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Create an Address
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
address: {
country_id: '224',
address1: '5th ave',
city: 'NY',
zipcode: '10001',
phone: '+1 123 456 789',
firstname: 'John',
lastname: 'Snow',
state_id: '516',
state_name: 'New York',
address2: '1st suite',
alternative_phone: '<string>',
label: 'My home address',
company: 'Vendo Connect Inc',
user_id: '<string>',
public_metadata: {distance_from_nearest_city_in_km: 10, location_type: 'building'},
private_metadata: {close_to_shop: true}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/addresses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/addresses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"address": {
"country_id": "224",
"address1": "5th ave",
"city": "NY",
"zipcode": "10001",
"phone": "+1 123 456 789",
"firstname": "John",
"lastname": "Snow",
"state_id": "516",
"state_name": "New York",
"address2": "1st suite",
"alternative_phone": "<string>",
"label": "My home address",
"company": "Vendo Connect Inc",
"user_id": "<string>",
"public_metadata": {
"distance_from_nearest_city_in_km": 10,
"location_type": "building"
},
"private_metadata": {
"close_to_shop": true
}
}
}
'{
"data": {
"id": "5",
"type": "address",
"attributes": {
"firstname": "John",
"lastname": "Doe",
"address1": "5 Lovely Street",
"address2": "Northwest",
"city": "Herndon",
"zipcode": "35005",
"phone": "555-555-0199",
"state_name": null,
"alternative_phone": "555-555-0199",
"company": "Company",
"created_at": "2022-11-08T19:33:51.471Z",
"updated_at": "2022-11-08T19:33:51.471Z",
"deleted_at": null,
"label": null,
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"country": {
"data": {
"id": "4",
"type": "country"
}
},
"state": {
"data": {
"id": "5",
"type": "state"
}
},
"user": {
"data": {
"id": "1",
"type": "user"
}
}
}
}
}{
"error": "First Name can't be blank, Last Name can't be blank, Address can't be blank, City can't be blank, Country can't be blank, Zip Code can't be blank, and Phone can't be blank",
"errors": {
"firstname": [
"can't be blank"
],
"lastname": [
"can't be blank"
],
"address1": [
"can't be blank"
],
"city": [
"can't be blank"
],
"country": [
"can't be blank"
],
"zipcode": [
"can't be blank"
],
"phone": [
"can't be blank"
]
}
}
