# REST API

WooCommerce Attribute Stock includes a fully integrated WooCommerce REST API endpoint.

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 (opens new window) for instructions.

For further instructions and examples of using the WooCommerce REST API, please refer to the WooCommerce REST API documentation (opens new window).

# Stock item properties

Property Type Description
id integer Unique identifier for the stock item. readonly
title string Stock item name.
slug string Stock item slug. readonly
enabled boolean Whether the stock item is enabled.
status string The post status of the stock item.
created date-time The date the stock item was created, in the site's timezone. readonly
created_gmt date-time The date the stock item was created, in GMT. readonly
modified date-time The date the stock item was last modified, in the site's timezone. readonly
modified_gmt date-time The date the stock item was last modified, in GMT. readonly
sku string Internal stock-keeping-unit.
quantity number Current stock quantity.
notes string Internal notes.
low_stock number Low stock threshold. Can be set to an empty string ("") to inherit the global WooCommerce setting.
limit_products boolean Limit product stock option. Restrict available stock for matching products and prevent over-purchasing
match_all boolean Match all groups option. Reduce stock for multiple matching attribute groups at the same time.
match_rules array List of attribute match rules data.
products array Products filter. List of product IDs.
exclude_products array Exclude products filter. List of product IDs.
categories array Categories filter. List of category IDs.
exclude_categories array Exclude categories filter. List of category IDs.
product_types array Product types filter. List of product type strings.
tags array List of tag names.

# List stock items

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

# Parameters

Key Type Description
context string Scope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
page integer Current page of the collection. Default is 1.
per_page integer Maximum number of items to be returned in result set. Default is 10.
status string|array Status of post object. Options: any, publish, draft, trash. Default is any, which is equivalent to ["publish", "draft"].
enabled boolean Overrides status if present. true is equivalent to publish status. false is equivalent to draft status.
search string Limit results to those matching a string.
after string Limit response to resources published after a given ISO8601 compliant date.
before string Limit response to resources published before a given ISO8601 compliant date.
exclude array Ensure result set excludes specific IDs.
include array Limit result set to specific IDs.
offset integer Offset the result set by a specific number of items.
orderby string Sort collection by object attribute. Options: title, sku, quantity, date, id, include, and slug. Default is title.
order string Sort order. Options: asc and desc. Default is asc.

# Retrieve a stock item

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

# Create a new stock item

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

# Update a stock item

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

# Delete a stock item

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

# Batch update stock items

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