Inventory
Stock levels for up to 100 products in one call, each named by id or SKU; all or nothing.
Call it on the client itself: admin.setInventory(). It needs the inventory:write scope. To change a product's other fields, use products.
Set stock
admin.setInventory(items: InventoryItem[], options?: RequestOptions): Promise<InventoryResult[]>
Sets stock for up to 100 products, each named by productId or sku. A stockQuantity turns stock tracking on, a stockStatus (in_stock or out_of_stock) turns it off. All or nothing: an unknown product, or a sku several products share, fails the call with an items.N error (name such a product by productId). Scope: inventory:write.
Parameters
| Parameter | Type | |
|---|---|---|
items |
InventoryItem[] |
A list of items, each with the fields below (without items[].). |
options |
RequestOptions |
idempotencyKey, signal and headers (see retries). |
Request fields
The SDK sends the list you pass as the body's items:
| Field | Type | Description |
|---|---|---|
items required | array of InventoryItemInput | At most 100 items. |
items[].productId | integer or null | |
items[].sku | string or null | At most 255 characters. |
items[].stockQuantity | integer or null | Turns stock tracking on. At least 0. At most 99999999. |
items[].stockStatus | string or null | Turns stock tracking off. One of in_stock, out_of_stock. |
Returns
The products' stock after the change.
| Field | Type | Description |
|---|---|---|
[].id | integer | |
[].sku | string or null | |
[].manageStock | boolean | |
[].stockQuantity | integer or null | |
[].stockStatus | string or null | |
[].updatedAt | string (date-time) or null |
Errors
| Status | When |
|---|---|
401 | invalid_api_key: no active Admin key in Authorization: Bearer. |
403 | admin_key_in_browser (an Origin header was sent), ip_not_allowed, plan_required(the shop's plan lacks the Integration API, or the feature the endpoint needs), orinsufficient_scope. |
409 | idempotency_in_progress: a request with this Idempotency-Key is still running. Retry with the same key after Retry-After seconds; the first answer is then replayed. |
422 | Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid). |
429 | Rate limited. |
Example
await admin.setInventory([
{ sku: 'MUG-01', stockQuantity: 40 },
{ productId: 12, stockStatus: 'out_of_stock' },
]);