Reviews
Reviews are used to evaluate Products and Channels.
On the tutorial page you can find some instructions on how to use Reviews to rate Products and Channels.
Representations
Review
idString | Unique identifier of the Review. |
versionInt | Current version of the Review. |
keyString | User-defined unique identifier of the Review. |
uniquenessValueString | Must be unique among Reviews. For example, if this value is set to Customer |
locale | Language in which the content of the Review is written. Pattern:^[a-z]{2}(-[A-Z]{2})?$ |
authorNameString | Name of the author. |
titleString | Title of the Review. |
textString | Content of the Review. |
targetProductReference | ChannelReference | Identifies the target of the Review. Can be a Product or a Channel, specified as ProductReference or ChannelReference, respectively. |
includedInStatisticsBoolean | Indicates if this Review is taken into account in the ratings statistics of the target.
A Review is per default used in the statistics, unless the Review is in a state that does not have the role |
ratingInt | Rating of the Product or Channel. Minimum:-100Maximum: 100 |
state | State of the Review. Used for approval processes, see Review approval process for details. |
customer | Customer who created the Review. |
custom | Custom Fields of the Review. |
createdAt | Date and time (UTC) the Review was initially created. |
createdByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
lastModifiedAt | Date and time (UTC) the Review was last updated. |
lastModifiedByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}
ReviewDraft
When creating a new Review, at least one of title, text or rating should be set.
keyString | User-defined unique identifier for the Review. |
uniquenessValueString | If set, this value must be unique among Reviews.
For example, if you want to have only one Review per Customer and per Product, you can set the value to Customer |
locale | Language in which the content of the Review is written. Pattern:^[a-z]{2}(-[A-Z]{2})?$ |
authorNameString | Name of the author. |
titleString | Title of the Review. |
textString | Content of the Review. |
targetProductResourceIdentifier | ChannelResourceIdentifier | Identifies the target of the Review. Can be a Product or a Channel, specified as ProductResourceIdentifier or ChannelResourceIdentifier, respectively. |
state | State of the Review. Used for approval processes, see Review approval process for details. |
ratingInt | Rating of the targeted Product or Channel.
This rating can represent the number of stars, a percentage, or a like (+1)/dislike (-1).
A rating is used in the ratings statistics of the targeted object, unless the Review is in a State that does not have the role -100Maximum: 100 |
customer | Customer who created the Review. |
custom | Custom Fields for the Review. |
{"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"}}
ReviewPagedQueryResponse
limitInt | Number of results requested. |
countInt | Actual number of results returned. |
totalInt | Total number of results matching the query.
This number is an estimation that is not strongly consistent.
This field is returned by default.
For improved performance, calculating this field can be deactivated by using the query parameter |
offsetInt | Number of elements skipped. |
resultsArray of Review | Reviews matching the query. |
{"limit" : 20,"offset" : 0,"count" : 2,"total" : 2,"results" : [ {"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}, {"id" : "2f60e06c-7672-47fc-962a-1eafa1123456","version" : 1,"includedInStatistics" : true,"authorName" : ".","title" : ".","text" : ".","rating" : 5,"target" : {"typeId" : "product","id" : "2c155644-bcde-426c-b021-a2aab123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b42123456"},"fields" : {"authorMail" : "."}},"createdAt" : "2016-10-20T06:51:26.795Z","lastModifiedAt" : "2016-10-20T06:51:26.795Z"} ]}
ReviewRatingStatistics
averageRatingFloat | Average rating of one target This number is rounded with 5 decimals. |
highestRatingFloat | Highest rating of one target |
lowestRatingFloat | Lowest rating of one target |
countInt | Number of ratings taken into account |
ratingsDistributionObject | Full distribution of the ratings. The keys are the different ratings and the values are the count of reviews having this rating. Only the used ratings appear in this object. |
ReviewReference
ReviewResourceIdentifier
ResourceIdentifier to a Review.
Get Review
Get Review by ID
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
200Review
curl -X GET https://api.{region}.commercetools.com/{projectKey}/reviews/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}
Get Review by Key
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
200Review
curl -X GET https://api.{region}.commercetools.com/{projectKey}/reviews/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}
Query Reviews
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | The parameter can be passed multiple times. |
/^var[.][a-zA-Z0-9]+$/Any string parameter matching this regular expression | Predicate parameter values. The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
withTotalBoolean | Controls the calculation of the total number of query results. Set to |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/reviews -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"limit" : 20,"offset" : 0,"count" : 2,"total" : 2,"results" : [ {"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}, {"id" : "2f60e06c-7672-47fc-962a-1eafa1123456","version" : 1,"includedInStatistics" : true,"authorName" : ".","title" : ".","text" : ".","rating" : 5,"target" : {"typeId" : "product","id" : "2c155644-bcde-426c-b021-a2aab123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b42123456"},"fields" : {"authorMail" : "."}},"createdAt" : "2016-10-20T06:51:26.795Z","lastModifiedAt" : "2016-10-20T06:51:26.795Z"} ]}
Create a Review
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
expand | The parameter can be passed multiple times. |
201Review
curl -X POST https://api.{region}.commercetools.com/{projectKey}/reviews -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"}}DATA
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}
This method produces the Review Created Message.
Update Review
Update Review by ID
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
versionInt | The expected version of the review on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actionsArray of ReviewUpdateAction | The list of update actions to be performed on the review. |
200Review
curl -X POST https://api.{region}.commercetools.com/{projectKey}/reviews/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "setAuthorName","authorName" : "John Doe"} ]}DATA
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}
Update Review by Key
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
versionInt | The expected version of the review on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actionsArray of ReviewUpdateAction | The list of update actions to be performed on the review. |
200Review
curl -X POST https://api.{region}.commercetools.com/{projectKey}/reviews/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "setAuthorName","authorName" : "John Doe"} ]}DATA
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}
Update actions
Set Key
actionString | "setKey" |
keyString | Value to set. If empty, any existing value will be removed. |
{"action" : "setKey","key" : "myReviewKey"}
Set Customer
actionString | "setCustomer" |
customer | Value to set. If empty, any existing value will be removed. |
{"action" : "setCustomer","customer" : {"typeId" : "customer","id" : "0c2eaad4-833c-43c1-98a4-5d03f57e9329"}}
Set Rating
This update action produces the ReviewRatingSet Message.
actionString | "setRating" |
ratingInt | Value to set. If empty, any existing value will be removed. Minimum:-100Maximum: 100 |
{"action" : "setRating","rating" : 60}
Set Target
actionString | "setTarget" |
targetProductResourceIdentifier | ChannelResourceIdentifier | Value to set, specified as ProductResourceIdentifier or ChannelResourceIdentifier, respectively. If empty, any existing value will be removed. |
{"action" : "setTarget","target" : {"typeId" : "product","id" : "{{product-id}}"}}
Set Text
actionString | "setText" |
textString | Value to set. If empty, any existing value will be removed. |
{"action" : "setText","text" : "reviewText"}
Set Title
actionString | "setTitle" |
titleString | Value to set. If empty, any existing value will be removed. |
{"action" : "setTitle","title" : "reviewTitle"}
Set Locale
actionString | "setLocale" |
locale | Value to set. If empty, any existing value will be removed. Pattern:^[a-z]{2}(-[A-Z]{2})?$ |
{"action" : "setLocale","locale" : "en-US"}
Transition State
Transition to a new State. This update action produces the Review State Transition Message.
actionString | "transitionState" |
state | Value to set. If there is no State yet, the new State must be an initial State. If the existing State has |
forceBoolean | Switch validations on or off. Default:false |
{"action" : "transitionState","state" : {"typeId" : "state","id" : "{{state-id}}"}}
Set Custom Type
actionString | "setCustomType" |
type | Defines the Type that extends the Review with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Review. |
fields | Sets the Custom Fields fields for the Review. |
{"action" : "setCustomType","type" : {"id" : "{{type-id}}","typeId" : "type"},"fields" : {"examplaryStringTypeField" : "TextString"}}
Set CustomField
actionString | "setCustomField" |
nameString | Name of the Custom Field. |
value | If |
{"action" : "setCustomField","name" : "ExamplaryStringTypeField","value" : "TextString"}
Delete Review
Delete Review by ID
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
dataErasureBoolean | Defaults to |
200Review
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/reviews/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}
Delete Review by Key
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
dataErasureBoolean | Defaults to |
200Review
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/reviews/key={key}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "919d5ab5-bf99-4bda-a6fd-ab3ee8123456","version" : 1,"includedInStatistics" : true,"authorName" : "John Doe","title" : "Incredible","text" : "Best product ever","rating" : 5,"target" : {"typeId" : "product","id" : "8fddacac-6ef5-4e66-af6e-124452123456"},"customer" : {"typeId" : "customer","id" : "8a8b3e43-b9b0-4b30-8c27-58148123456"},"custom" : {"type" : {"typeId" : "type","id" : "3939dd9c-0884-4bfa-99c2-40b426123456"},"fields" : {"authorMail" : "john.doe@example.com"}},"createdAt" : "2016-10-20T06:48:53.829Z","lastModifiedAt" : "2016-10-20T06:48:53.829Z"}