set_inventory_quantity
Overwrite the absolute available inventory for a product variant at a specific location. Replaces the current count with the specified quantity, recording a reason code for audit history.
Instructions
Set the absolute available inventory for one variant at one location. This is a direct overwrite, not an adjustment — passing 5 sets the count to 5 regardless of what was there before. The pair (inventory_item_id, location_id) uniquely identifies the inventory level: get inventory_item_id from get_product (it's on each variant) and location_id from list_locations. Records a Shopify inventory adjustment with the reason code you provide. Use 'correction' for cycle counts/manual fixes, 'received' when receiving stock, 'cycle_count_available' for systematic counts. Tracks history; the audit log shows who/when via the API user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inventory_item_id | Yes | InventoryItem GID ('gid://shopify/InventoryItem/123') or numeric ID. Found on each variant in get_product output as variants[].inventoryItem.id. | |
| location_id | Yes | Location GID or numeric ID. Get from list_locations. Each variant tracks inventory per location. | |
| quantity | Yes | New absolute available quantity. This OVERWRITES the current count, it doesn't increment — pass the desired final number, not a delta. | |
| reason | No | Shopify-defined reason code recorded in the inventory audit history. Common values: 'correction' (manual fix), 'cycle_count_available' (systematic recount), 'received' (receiving new stock), 'damaged', 'shrinkage', 'other'. | correction |