Skip to main content

Product attribute terms

The product attribute terms API allows you to create, view, update, and delete individual, or a batch, of attribute terms.

Product attribute term properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
namestringTerm name. MANDATORY
slugstringAn alphanumeric identifier for the resource unique to its type.
descriptionstringHTML description of the resource.
menu_orderintegerMenu order, used to custom sort the resource.
countintegerNumber of published products for the resource. READ-ONLY

Create an attribute term

This API helps you to create a new product attribute term.

POST /wp-json/wc/v2/products/attributes/<attribute_id>/terms
curl -X POST https://example.com/wp-json/wc/v2/products/attributes/2/terms \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "XXS"
}'

Retrieve an attribute term

This API lets you retrieve a product attribute term by ID.

GET /wp-json/wc/v2/products/attributes/<attribute_id>/terms/<id>
curl https://example.com/wp-json/wc/v2/products/attributes/2/terms/23 \
-u consumer_key:consumer_secret

List all attribute terms

This API lets you retrieve all terms from a product attribute.

GET /wp-json/wc/v2/products/attributes/<attribute_id>/terms
curl https://example.com/wp-json/wc/v2/products/attributes/2/terms \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
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.
searchstringLimit results to those matching a string.
excludearrayEnsure result set excludes specific ids.
includearrayLimit result set to specific ids.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is asc.
orderbystringSort collection by resource attribute. Options: id, include, name, slug, term_group, description and count. Default is name.
hide_emptybooleanWhether to hide resources not assigned to any products. Default is false.
parentintegerLimit result set to resources assigned to a specific parent.
productintegerLimit result set to resources assigned to a specific product.
slugstringLimit result set to resources with a specific slug.

Update an attribute term

This API lets you make changes to a product attribute term.

PUT /wp-json/wc/v2/products/attributes/<attribute_id>/terms/<id>
curl -X PUT https://example.com/wp-json/wc/v2/products/attributes/2/terms/23 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "XXS"
}'

Delete an attribute term

This API helps you delete a product attribute term.

DELETE /wp-json/wc/v2/products/attributes/<attribute_id>/terms/<id>
curl -X DELETE https://example.com/wp-json/wc/v2/products/attributes/2/terms/23?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcebooleanRequired to be true, as resource does not support trashing.

Batch update attribute terms

This API helps you to batch create, update and delete multiple product attribute terms.

note

Note: By default it's limited to up to 100 objects to be created, updated or deleted.

POST /wp-json/wc/v2/products/attributes/<attribute_id>/terms/batch
curl -X POST https://example.com/wp-json/wc/v2/products/attributes/<attribute_id>/terms/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "XXS"
},
{
"name": "S"
}
],
"update": [
{
"id": 19,
"menu_order": 6
}
],
"delete": [
21,
20
]
}'