Update inventory by overriding existing values - Fabric
Update inventory by overriding existing values
cURL
curl --request PUT \
--url https://prod01.oms.fabric.inc/api/v2/inventory \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '\n{
"sku": "SKU00025",
"itemId": 4225678911,
"locationNum": 473746,
"channelId": 12,
"vendorId": "vendor123",
"leadTime": 1234,
"inventoryType": "primary",
"infiniteInventory": true,
"backOrderDate": "2022-08-08T00:00:00.000Z",
"preOrderDate": "2022-08-08T00:00:00.000Z",
"backOrderLimit": 100,
"preOrderLimit": 100,
"safetyStock": 10,
"lowStock": 10,
"segment": "Clothing",
"region": "US",
"counters": {
"on-hand": 10
},
"attributes": {
"buy online, pick up in-store (bopis)": true
}
}
'
Python
import requests
url = "https://prod01.oms.fabric.inc/api/v2/inventory"
payload = {
"sku": "SKU00025",
"itemId": 4225678911,
"locationNum": 473746,
"channelId": 12,
"vendorId": "vendor123",
"leadTime": 1234,
"inventoryType": "primary",
"infiniteInventory": True,
"backOrderDate": "2022-08-08T00:00:00.000Z",
"preOrderDate": "2022-08-08T00:00:00.000Z",
"backOrderLimit": 100,
"preOrderLimit": 100,
"safetyStock": 10,
"lowStock": 10,
"segment": "Clothing",
"region": "US",
"counters": { "on-hand": 10 },
"attributes": { "buy online, pick up in-store (bopis)": True }
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch API)
const options = {
method: 'PUT',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
sku: 'SKU00025',
itemId: 4225678911,
locationNum: 473746,
channelId: 12,
vendorId: 'vendor123',
leadTime: 1234,
inventoryType: 'primary',
infiniteInventory: true,
backOrderDate: '2022-08-08T00:00:00.000Z',
preOrderDate: '2022-08-08T00:00:00.000Z',
backOrderLimit: 100,
preOrderLimit: 100,
safetyStock: 10,
lowStock: 10,
segment: 'Clothing',
region: 'US',
counters: {'on-hand': 10},
attributes: {'buy online, pick up in-store (bopis)': true}
})
};
fetch('https://prod01.oms.fabric.inc/api/v2/inventory', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
Response Structure
{
"virtualCounters": {
"availableToPurchase": 10
},
"id": "62272e917b12209e68751d94",
"sku": "SKU00025",
"itemId": 4225678911,
"locationNum": 473746,
"channelId": 12,
"vendorId": "vendor123",
"leadTime": 1234,
"inventoryType": "Safety stock",
"infiniteInventory": true,
"counters": {
"on-hand": 10
},
"attributes": {
"buy online, pick up in-store (bopis)": true
}
}
- 400 Invalid request example:
{
"message": "Invalid request payload or parameter"
}
- 500 Internal server error example:
{
"message": "An internal error occurred. If the issue persists please contact support@fabric.inc."
}