Skip to content

REST API

WooCommerce Attribute Stock includes a fully integrated WooCommerce REST API endpoint, which can be used to read and manage your attribute stock items from external software.

Before you can access the WooCommerce REST API for your site, you'll need to create an API key. Please refer to the official guide for instructions.

For further instructions and examples of using the WooCommerce REST API, please refer to the WooCommerce REST API documentation.

Stock item properties

PropertyTypeDescription
idintegerUnique identifier for the stock item.readonly
titlestringStock item name.
slugstringStock item post slug.readonly
skustringInternal stock keeping unit.
enabledbooleanWhether the stock item is enabled or disabled.
statusstringThe post status of the stock item.
quantitynumberCurrent stock quantity.
low_stocknumberLow stock threshold. An empty string ("") inherits the global WooCommerce setting.
internalbooleanInternal stock items don't affect the stock availability of products.
multiplexbooleanDeduct stock for multiple matching rules simultaneously instead of only the first matched rule.
lock_multipliersbooleanPrevent this item's stock multipliers from being overridden by products.
product_skubooleanAllow matched products to inherit this stock item's SKU.
product_imagebooleanAllow matched products to inherit this stock item's image.
image_idintegerAttachment ID of the stock image.
componentsobjectParent and child components relationships.
match_rulesobject[]List of match rules.
filtersobjectMatch rule filters.
tagsarrayList of tag names.
notesstringInternal notes.
createddate-timeThe date the stock item was created, in the site's timezone.readonly
created_gmtdate-timeThe date the stock item was created, in GMT.readonly
modifieddate-timeThe date the stock item was last modified, in the site's timezone.readonly
modified_gmtdate-timeThe date the stock item was last modified, in GMT.readonly

List stock items

http
GET /wp-json/wc/v3/attribute-stock

Parameters

KeyTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
statusstring|arrayStatus of post object. Options: any, publish, draft, trash. Default is any, which is equivalent to ["publish", "draft"].
enabledbooleanOverrides status if present. true is equivalent to publish status. false is equivalent to draft status.
searchstringLimit results to those matching a string.
afterstringLimit response to resources published after a given ISO8601 compliant date.
beforestringLimit response to resources published before a given ISO8601 compliant date.
excludearrayEnsure result set excludes specific IDs.
includearrayLimit result set to specific IDs.
offsetintegerOffset the result set by a specific number of items.
orderbystringSort collection by object attribute. Options: title, sku, quantity, date, id, include, and slug. Default is title.
orderstringSort order. Options: asc and desc. Default is asc.

Single item requests

Retrieve a stock item

http
GET /wp-json/wc/v3/attribute-stock/<id>

Create a new stock item

http
POST /wp-json/wc/v3/attribute-stock

Update a stock item

http
PUT /wp-json/wc/v3/attribute-stock/<id>

Delete a stock item

http
DELETE /wp-json/wc/v3/attribute-stock/<id>

Batch update stock items

http
POST /wp-json/wc/v3/attribute-stock/batch

Webhooks

Attribute stock includes standard WooCommerce webhook topics (under WooCommerceSettingsAdvancedWebhooks) for changes on attribute stock items.

Webhooks are useful in combination with workflow automation tools like Google Apps Script, Zapier, Make.com, etc. For example, you could automatically export your attribute stock list to a Google Sheet whenever there's a change. Or email yourself a weekly CSV stock report.

See the WooCommerce Webhooks documentation to learn more about webhooks.

TIP

AI tools like ChatGPT and Grok are very good at writing Google Apps Scripts like these, or guiding you to set up workflows with other automation tools. Just link them to this page and tell them what you want your automation to do.