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. MANDATORY
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/v3/products/tags

Example of how to create a product tag:

curl -X POST https://example.com/wp-json/wc/v3/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/v3/products/tags/<id>
curl https://example.com/wp-json/wc/v3/products/tags/34 \
-u consumer_key:consumer_secret

List all product tags​

This API lets you retrieve all product tag.

GET /wp-json/wc/v3/products/tags
curl https://example.com/wp-json/wc/v3/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. 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.
offsetintegerOffset the result set by a specific number of items.
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.
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/v3/products/tags/<id>
curl -X PUT https://example.com/wp-json/wc/v3/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/v3/products/tags/<id>
curl -X DELETE https://example.com/wp-json/wc/v3/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/v3/products/tags/batch
curl -X POST https://example.com/wp-json/wc/v3/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
]
}'