You can Update Product Stock related information by REST API with the use of endpoint URL /V1/products/:productSku/stockItems/:itemId.
You can manage Stock Inventory related data with REST API with the given payload as below.
Action: PUT
Header: Authorization: Bearer <ADMIN_TOKEN>
URL: <BASE_URL>/V1/products/:productSku/stockItems/:itemId
(Example, https:/magento246.test/rest/V1/products/24-MB01/stockItems/90)
You can fetch itemId by calling the GET Product StockItems API. Product Stock Item by REST API V1/stockItems/:SKU Magento 2?
PAYLOAD:
{
"stockItem": {
"product_id": 12,
"stock_id": 1,
"qty": 1030,
"is_in_stock": true,
"is_qty_decimal": true,
"use_config_min_qty": true,
"min_qty": 0,
"use_config_min_sale_qty": 0,
"min_sale_qty": 0,
"use_config_max_sale_qty": true,
"max_sale_qty": 0,
"use_config_backorders": true,
"backorders": 0,
"use_config_notify_stock_qty": true,
"notify_stock_qty": 0,
"use_config_qty_increments": true,
"qty_increments": 0,
"use_config_enable_qty_inc": true,
"enable_qty_increments": true,
"use_config_manage_stock": true,
"manage_stock": true,
"low_stock_date": "",
"is_decimal_divided": true,
"stock_status_changed_auto": 0,
"extension_attributes": {}
}
}
All the fields are self-explanatory. You can set qty, is_in_stock to set your product In stock and Qty value.
RESPONSE: Item Id.
