Update inventory balance
There are several calls available to update the inventory balance of a variant. The general term for balance updates are "movements". Each movement has product/variant UUIDs, a "from" location, a "to" location, and the number of items that should be moved.
Note: Every product and product variant must have a unique UUID.
- Authorization setup with the correct scope, and a valid authorization token. See How inventories work.
- The "from" and "to" location UUIDs for locations involved in the movement. See Fetch inventory locations.
- The product UUID for a specific product. See Fetch products.
- The variant UUID for which to update the balance. See Fetch products.
Use the following request to update the inventory balance for an organization.
1PUT /organizations/self/inventory
1{2"changes": [3{4"productUuid": <UUID>,5"variantUuid": <UUID>,6"fromLocationUuid": <UUID>,7"toLocationUuid": <UUID>,8"change": <NUMBER>9}10],11"returnBalanceForLocationUuid": <UUID>,12"externalUuid": <UUID>13}
Example: Updating the balance for product UUID 65314d7e-5f0f-11ec-bf63-0242ac130002
, variant UUIDs 78194842-5f0f-11ec-bf63-0242ac130002
and 7c6be742-5f0f-11ec-bf63-0242ac130002
, from location UUID 89ac1e4a-5f0f-11ec-bf63-0242ac130002
to location 92646e02-5f0f-11ec-bf63-0242ac130002
, with values 42
and 1337
.
The response will return the balances for the STORE
location since we are not providing any value for returnBalanceForLocationUuid
.
Request
1PUT /organizations/self/inventory
Request body
1{2"changes": [3{4"productUuid": "65314d7e-5f0f-11ec-bf63-0242ac130002",5"variantUuid": "78194842-5f0f-11ec-bf63-0242ac130002",6"fromLocationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",7"toLocationUuid": "92646e02-5f0f-11ec-bf63-0242ac130002",8"change": 429},10{11"productUuid": "65314d7e-5f0f-11ec-bf63-0242ac130002",12"variantUuid": "7c6be742-5f0f-11ec-bf63-0242ac130002",13"fromLocationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",14"toLocationUuid": "92646e02-5f0f-11ec-bf63-0242ac130002",15"change": 133716}17]18}
Response
1{2"locationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",3"variants": [4{5"locationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",6"locationType": "STORE",7"productUuid": "65314d7e-5f0f-11ec-bf63-0242ac130002",8"variantUuid": "78194842-5f0f-11ec-bf63-0242ac130002",9"balance": 19610},11{12"locationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",13"locationType": "STORE",14"productUuid": "65314d7e-5f0f-11ec-bf63-0242ac130002",15"variantUuid": "7c6be742-5f0f-11ec-bf63-0242ac130002",16"balance": 1069617}18]19}
An alternative way to update balances is through the bulk
API endpoint.
Using this endpoint, you can both start tracking and update the stock levels one or more products within a single request. For information about enabling tracking using the bulk endpoint, see Enable tracking using the bulk endpoint.
Example: Updating the balance for two variants.
1POST /organizations/self/v2/inventory/bulk
Request body
1{2"returnBalanceForLocationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",3"productChanges": [4{5"productUuid": "3cc3b9f6-623b-11ec-90d6-0242ac120003",6"trackingStatusChange": "START_TRACKING",7"variantChanges": [8{9"variantUuid": "4066f6cc-623b-11ec-90d6-0242ac120003",10"fromLocationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",11"toLocationUuid": "92646e02-5f0f-11ec-bf63-0242ac130002",12"change": 4213},14{15"variantUuid": "45900c4c-623b-11ec-90d6-0242ac120003",16"fromLocationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",17"toLocationUuid": "92646e02-5f0f-11ec-bf63-0242ac130002",18"change": 133719}20]21}22]23}
Response
1{2"locationUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",3"variants": [4{5"productUuid": "3cc3b9f6-623b-11ec-90d6-0242ac120003",6"variantUuid": "89ac1e4a-5f0f-11ec-bf63-0242ac130002",7"balance": 1968},9{10"productUuid": "3cc3b9f6-623b-11ec-90d6-0242ac120003",11"variantUuid": "45900c4c-623b-11ec-90d6-0242ac120003",12"balance": 1069613}14]15}