Skip to main content

Product tags

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

Product tag properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
namestringTag name. REQUIRED
slugstringAn alphanumeric identifier for the resource unique to its type.
descriptionstringHTML description of the resource.
countintegerNumber of published products for the resource. READ-ONLY

Create a product tag

This API helps you to create a new product tag.

POST /wp-json/wc/v1/products/tags

Example of how to create a product tag:

curl -X POST https://example.com/wp-json/wc/v1/products/tags \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Leather Shoes"
}'

Retrieve a product tag

This API lets you retrieve a product tag by ID.

GET /wp-json/wc/v1/products/tags/<id>
curl https://example.com/wp-json/wc/v1/products/tags/34 \
-u consumer_key:consumer_secret

List all product tags

This API lets you retrieve all product tag.

GET /wp-json/wc/v1/products/tags
curl https://example.com/wp-json/wc/v1/products/tags \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit.
pageintegerCurrent page of the collection.
per_pageintegerMaximum number of items to be returned in result set.
searchstringLimit results to those matching a string.
excludestringEnsure result set excludes specific ids.
includestringLimit result set to specific ids.
orderstringOrder sort attribute ascending or descending. Default is asc. Options: asc and desc.
orderbystringSort collection by object attribute. Default is name. Options: id, include, name, slug, term_group, description and count.
hide_emptyboolWhether to hide resources not assigned to any products. Default is false.
productintegerLimit result set to resources assigned to a specific product.
slugstringLimit result set to resources with a specific slug.

Update a product tag

This API lets you make changes to a product tag.

PUT /wp-json/wc/v1/products/tags/<id>
curl -X PUT https://example.com/wp-json/wc/v1/products/tags/34 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"description": "Genuine leather."
}'

Delete a product tag

This API helps you delete a product tag.

DELETE /wp-json/wc/v1/products/tags/<id>
curl -X DELETE https://example.com/wp-json/wc/v1/products/tags/34?force=true \
-u consumer_key:consumer_secret

Available parameters

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

Batch update product tags

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

note

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

POST /wp-json/wc/v1/products/tags/batch
curl -X POST https://example.com/wp-json/wc/v1/products/tags/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"name": "Round toe"
},
{
"name": "Flat"
}
],
"update": [
{
"id": 34,
"description": "Genuine leather."
}
],
"delete": [
35
]
}'