Connect an ERP, POS, or warehouse system to read and update per-location stock and prices. Go to WooCommerce > Settings > Multi Inventory > REST API to see your store’s Base URL and a quick reference of endpoints.
Setup
↑ Back to top- Create an API key: Go to WooCommerce > Settings > Advanced > REST API > Add key. Select a user with the Manage WooCommerce capability (Administrator or Shop Manager), set Permissions to Read/Write, then copy the Consumer Key and Consumer Secret.
- Authenticate: Use the same keys as the standard WooCommerce REST API. Over HTTPS, send the Consumer Key as the Basic Auth username and the Consumer Secret as the password, or pass consumer_key and consumer_secret as query parameters.
- Base URL: https://yourstore.com/wp-json/ext-mim/v1 (the exact URL for your site is shown on the REST API tab).
- Requirement: The product must have Use Multi Inventory? enabled. Updates to other products return an error, and they are not included in GET results.
- Key permissions: A Read key can only use GET requests. Use a Read/Write key to make updates.
Default Stock vs Location Inventory
↑ Back to topEach product has one Default Stock entry plus one entry per assigned location, exactly as on the product edit screen. The WooCommerce product stock is the total of all entries, never a single location.
- location_id = 0: Targets Default Stock. Recommended for reading and updating the main inventory.
- location_id = {location ID}: Targets that location’s inventory only and does not change Default Stock. Exception: if this is the product’s assigned default location and the product has no separate entry for it, the request targets Default Stock.
Endpoints
↑ Back to top- GET /locations: Lists all published locations with id, name, and parent_id. Use this to find location IDs.
- GET /inventory: Lists Default Stock and all location entries for published products using multi inventory.
- PATCH /inventory/{product_id}/0: Updates Default Stock.
- PATCH /inventory/{product_id}/default: Same as above (alias).
- PATCH /inventory/{product_id}/{location_id}: Updates one location’s inventory. If the product has no entry for that location yet, one is created (except in the default location case above).
PUT is accepted wherever PATCH is.
GET /inventory Filters
↑ Back to top- product_id: Return one product. For a variable product, all its variations are returned.
- location_id: Return one location only. Use 0 for Default Stock only.
- sku: Partial, case-insensitive match on product SKU or location inventory SKU.
- page / per_page: Pagination. Default 20 per page, maximum 100. Total results and pages are returned in the X-WP-Total and X-WP-TotalPages response headers.
Updatable Fields (PATCH)
↑ Back to topSend only the fields you want to change, as a JSON body.
- stock_quantity: The new absolute quantity, not an increase or decrease. Must be a whole number of 0 or more. Each change in quantity is recorded in the product’s stock history with the note “REST API”.
- price / sale_price: Regular and sale price. On Default Stock this updates the product’s main price. On a location, setting a price enables location-specific pricing automatically. Send an empty string to clear the sale price.
- has_price: Location only. Set to false to remove location-specific pricing so the product’s main price applies.
- low_stock_threshold: Low stock alert level, as a whole number. On Default Stock this also updates the product’s WooCommerce low stock threshold.
- inventory_sku: Location only. Must be unique.
- priority: Inventory priority, as a whole number. Lower numbers are used first.
- date / expiry_date: Stock start and expiry date in YYYY-MM-DD format.
- manage_stock, stock_status, backorders: Product-level settings that apply to the whole product, not a single location. Accepted values: manage_stock yes/no, stock_status instock/outofstock/onbackorder, backorders no/notify/yes.
Response Fields
↑ Back to topEach inventory entry returns: product_id, parent_id, product_type, sku, inventory_sku, location_id, assigned_location_id, location_name, is_default, inventory_key, inventory_name, stock_quantity, price, sale_price, low_stock_threshold, status, stock_status, manage_stock, backorders, priority, date, expiry_date, has_price, and request_location_id. Default Stock always returns location_id as 0.
status and stock_status show the status of that entry, based on its quantity: instock if quantity is above 0, onbackorder if 0 and backorders are allowed, otherwise outofstock. Sending stock_status in a PATCH changes the product’s overall WooCommerce stock status, not this value.
Examples
↑ Back to topGet all locations:
curl https://yourstore.com/wp-json/ext-mim/v1/locations \
-u ck_xxxxxxxx:cs_xxxxxxxx
Get inventory for product 123:
curl “https://yourstore.com/wp-json/ext-mim/v1/inventory?product_id=123” \
-u ck_xxxxxxxx:cs_xxxxxxxx
Set stock to 50 and a location price for product 123 at location 45:
curl -X PATCH https://yourstore.com/wp-json/ext-mim/v1/inventory/123/45 \
-u ck_xxxxxxxx:cs_xxxxxxxx \
-H “Content-Type: application/json” \
-d ‘{“stock_quantity”: 50, “price”: “19.99”}’
Sample response:
{
“product_id”: 123,
“parent_id”: 0,
“product_type”: “simple”,
“sku”: “TSHIRT-RED”,
“inventory_sku”: “”,
“location_id”: 45,
“assigned_location_id”: 45,
“location_name”: “California Warehouse”,
“is_default”: false,
“inventory_key”: “loc_45”,
“inventory_name”: “California Warehouse”,
“stock_quantity”: 50,
“price”: “19.99”,
“sale_price”: “”,
“low_stock_threshold”: 5,
“status”: “instock”,
“stock_status”: “instock”,
“manage_stock”: “yes”,
“backorders”: “no”,
“priority”: 1,
“date”: “”,
“expiry_date”: “”,
“has_price”: true,
“request_location_id”: 45
}