Skip to main content

Product reviews

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

Product review properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
date_createdstringThe date the review was created, in the site's timezone. READ-ONLY
date_created_gmtstringThe date the review was created, as GMT. READ-ONLY
product_idintegerUnique identifier for the product that the review belongs to.
statusstringStatus of the review. Options: approved, hold, spam, unspam, trash and untrash. Defaults to approved.
reviewerstringReviewer name.
reviewer_emailstringReviewer email.
reviewstringThe content of the review.
ratingintegerReview rating (0 to 5).
verifiedbooleanShows if the reviewer bought the product or not.

Create a product review

This API helps you to create a new product review.

POST /wp-json/wc/v3/products/reviews

Example of how to create a product review:

curl -X POST https://example.com/wp-json/wc/v3/products/reviews \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"product_id": 22,
"review": "Nice album!",
"reviewer": "John Doe",
"reviewer_email": "john.doe@example.com",
"rating": 5
}'

Retrieve a product review

This API lets you retrieve a product review by ID.

GET /wp-json/wc/v3/products/reviews/<id>
curl https://example.com/wp-json/wc/v3/products/reviews/22 \
-u consumer_key:consumer_secret

List all product reviews

This API lets you retrieve all product review.

GET /wp-json/wc/v3/products/reviews
curl https://example.com/wp-json/wc/v3/products/reviews \
-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.
afterstringLimit response to reviews published after a given ISO8601 compliant date.
beforestringLimit response to reviews published before a given ISO8601 compliant date.
dates_are_gmtbooleanInterpret after and before as UTC dates when true.
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 desc.
orderbystringSort collection by resource attribute. Options: date, date_gmt, id, slug, include and product. Default is date_gmt.
reviewerarrayLimit result set to reviews assigned to specific user IDs.
reviewer_excludearrayEnsure result set excludes reviews assigned to specific user IDs.
reviewer_emailarrayLimit result set to that from a specific author email.
productarrayLimit result set to reviews assigned to specific product IDs.
statusstringLimit result set to reviews assigned a specific status. Options: all, hold, approved, spam and trash. Default is approved.

Update a product review

This API lets you make changes to a product review.

PUT /wp-json/wc/v3/products/reviews/<id>
curl -X PUT https://example.com/wp-json/wc/v3/products/reviews/20 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"rating": 5
}'

Delete a product review

This API helps you delete a product review.

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

Available parameters

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

Batch update product reviews

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

note

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

POST /wp-json/wc/v3/products/reviews/batch
curl -X POST https://example.com/wp-json/wc/v3/products/reviews/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"product_id": 22,
"review": "Looks fine",
"reviewer": "John Doe",
"reviewer_email": "john.doe@example.com",
"rating": 4
},
{
"product_id": 22,
"review": "I love this album",
"reviewer": "John Doe",
"reviewer_email": "john.doe@example.com",
"rating": 5
}
],
"update": [
{
"id": 7,
"reviewer": "John Doe",
"reviewer_email": "john.doe@example.com"
}
],
"delete": [
22
]
}'