Skip to main content

Batch Stock Upload

The stock resource provides a way to update stock one item at a time. Whilst this will be fast for small stock updates it can be extremely inefficient for large stock updates. The batchStock endpoint permits the developer to push batches of stock items for the same warehouse in a single call.

info

The limit on number of items in a single call is 1,000

Method Properties

The batchStock method has the following properties encapsulated in a batchStock object.

PropertyExampleDescription
item[collection]A collection of stock item objects with the following properties (see below) no more than 1,000 items can be processed in a single call. Exceeding this limit will result in an error being returned.
variant_id"0A5EED..."The id of the variant optional if barcode or code passed
barcode"5052011221399"The barcode of the variant optional if variant_id or code passed
code"ACC001018__A"The id of the variant optional if variant_id or barcode passed
inStock1The quantity you wish to set the inStock figure to
demand0The quantity you wish to set the demand figure to
supply0The quantity you wish to set the supply figure to

Method Call

POST/api/batchStock?warehouse_id=1571945CAB99744086F9FDFC9D9332D5

When passed with a valid body will update or create the stock records for each of the passed items for the specified warehouse.

Example - Using variant_id

Example body for a batchStock Post where variant_id is specified

{
"batchStock": {
"item": [
{
"variant_id": "0A5EEDAF16F8D54486AB2AD7474B3994",
"inStock": 1,
"demand": 0,
"supply": 0
},
{
"variant_id": "1571945CAB99744086F9FDFC9D9332D5",
"inStock": 12,
"demand": 0,
"supply": 0
}
]
}
}

Example - Using barcode

Example body for a batchStock Post where barcode is specified

{
"batchStock": {
"item": [
{
"barcode": "5052011221399",
"inStock": 1
}
]
}
}

Example - Using code

Example body for a batchStock Post where code is specified

{
"batchStock": {
"item": [
{
"code": "ACC001018__A",
"inStock": 1
}
]
}
}

Method Response

The method will respond with the following properties

PropertyDataDescription
allPassedtrueIndicates that all passed stock items were updated or created successfully.
error""Simple error text returned. See table below. Will not be returned if allPassed is true
results[collection]A collection of any items that failed to update or be created.
successfalseA property of results indicating that the item was updated or not
massage"Variant not found"A property of results giving a message for the item

Example Response

Example response for a batchStock Post

{
"allPassed": false,
"error": "Some items failed to update please check results.",
"results": [
{
"barcode": "NOT A VALID BARCODE",
"inStock": 12,
"demand": 0,
"supply": 0,
"success": false,
"message": "Variant not found"
}
]
}
}

Method Errors

The Following table shows the various errors that could be returned in the error property

ErrorError TextReason
12001"Missing mandatory property, 'batchStock'"The batchStock object was not found in the POST body
12002"Missing query parameter warehouse_id"The POST URL did not contain the warehouse_id query parameter
12003"Warehouse not found: 1571945CAB99744086F9FDFC9D9332D5"The passed warehouse_id could not be found
12004"Missing stock item collection!"The item collection was not found in the POST body
12005"Call exceeds 1,000 item limit!"The number of items passed was over the 1,000 limit
12006"Some items failed to update please check results."One of more passed items failed. You will need to look at the results collection to see the failed items and the reasons.

Item Result Errors

The Following table shows the various item errors that could be returned in the item error property

ErrorError TextReason
12051"Failed to save item"The item was not updated/created (internal error)
12052"Variant not found"The code passed for the item was not found