Create a Stock Location
Creates a Stock Location
POST
/
api
/
v2
/
platform
/
stock_locations
Create a Stock Location
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
stock_location: {
name: 'Warehouse 3',
default: true,
address1: 'South St. 8',
address2: 'South St. 109',
country_id: '2',
state_id: '4',
city: 'Los Angeles',
state_name: 'California',
zipcode: '90005',
phone: '23333456',
active: true,
backorderable_default: true,
propagate_all_variants: true,
admin_name: '<string>'
}
})
};
fetch('http://{defaultHost}/api/v2/platform/stock_locations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/stock_locations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"stock_location": {
"name": "Warehouse 3",
"default": true,
"address1": "South St. 8",
"address2": "South St. 109",
"country_id": "2",
"state_id": "4",
"city": "Los Angeles",
"state_name": "California",
"zipcode": "90005",
"phone": "23333456",
"active": true,
"backorderable_default": true,
"propagate_all_variants": true,
"admin_name": "<string>"
}
}
'{
"data": {
"id": "179",
"type": "stock_location",
"attributes": {
"name": "Lon McClure",
"created_at": "2022-11-08T19:35:31.517Z",
"updated_at": "2022-11-08T19:35:31.517Z",
"default": false,
"address1": "1600 Pennsylvania Ave NW",
"address2": null,
"city": "Washington",
"state_name": null,
"zipcode": "20500",
"phone": "(202) 456-1111",
"active": true,
"backorderable_default": true,
"propagate_all_variants": false,
"admin_name": null
},
"relationships": {
"country": {
"data": {
"id": "415",
"type": "country"
}
}
}
}
}{
"error": "Name can't be blank",
"errors": {
"name": [
"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 a Stock Location
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
stock_location: {
name: 'Warehouse 3',
default: true,
address1: 'South St. 8',
address2: 'South St. 109',
country_id: '2',
state_id: '4',
city: 'Los Angeles',
state_name: 'California',
zipcode: '90005',
phone: '23333456',
active: true,
backorderable_default: true,
propagate_all_variants: true,
admin_name: '<string>'
}
})
};
fetch('http://{defaultHost}/api/v2/platform/stock_locations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/stock_locations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"stock_location": {
"name": "Warehouse 3",
"default": true,
"address1": "South St. 8",
"address2": "South St. 109",
"country_id": "2",
"state_id": "4",
"city": "Los Angeles",
"state_name": "California",
"zipcode": "90005",
"phone": "23333456",
"active": true,
"backorderable_default": true,
"propagate_all_variants": true,
"admin_name": "<string>"
}
}
'{
"data": {
"id": "179",
"type": "stock_location",
"attributes": {
"name": "Lon McClure",
"created_at": "2022-11-08T19:35:31.517Z",
"updated_at": "2022-11-08T19:35:31.517Z",
"default": false,
"address1": "1600 Pennsylvania Ave NW",
"address2": null,
"city": "Washington",
"state_name": null,
"zipcode": "20500",
"phone": "(202) 456-1111",
"active": true,
"backorderable_default": true,
"propagate_all_variants": false,
"admin_name": null
},
"relationships": {
"country": {
"data": {
"id": "415",
"type": "country"
}
}
}
}
}{
"error": "Name can't be blank",
"errors": {
"name": [
"can't be blank"
]
}
}
