Requires
write_comments
access scope. More access scope
The Create Comment API allows users to add a comment to a specific product. This includes details such as user feedback, star ratings, images, and likes.This API is especially useful for:
- Gathering customer feedback for products.
- Displaying product reviews on the storefront.3. Tracking user engagement with ratings and comments.
Note: The operation is scoped to a specific shop, identified by its unique domain prefix (shopdomain
), ensuring all updates are applied to the correct store.
Public Request Parameters
Parameter Name | Type | Required | Parameter Location | Parameter Value | Description |
---|---|---|---|---|---|
Access-Token | String | Yes | Header | Bx-_5aV eXNwl-4AB98s5xLV yg0fNzGf MuTpqtlBA | Used to authenticate API requests. Obtain an access token from the Access Token Guide. Pass it in the Authorization header for every request. |
Content-Type | String | Yes | Header | application /json | Indicates the media type of the request body. It tells the server how to parse the request and the client how to interpret the response. For more details, visit Content-Type. |
Public Response Parameters
Parameter Name | Type | Mandatory | Parameter Location | Example Value | Description |
---|---|---|---|---|---|
error | String | No | Response Body | { "error": "store is not active" } | Indicates an error encountered during the process. This field typically appears when the Access Token is missing or invalid. Example: { "error": "store is not active" } . |
errors | Array | No | Response Body | { "errors"["ProductId is required"] } | A list of errors that occurred during the request processing. Example: { "errors": [ "No Context" ] } . |
Request-Id | String | Yes | Header | Bx-_5aV eXNwl-4AB98s5xLV yg0fNzGf MuTpqtlBA | A unique identifier for each request. It helps in identifying and debugging specific requests. |
Error and Errors Clarification:
Added explanation that the error and errors fields are currently dependent on the API implementation, with plans for future unification.
Request Parameters
Body Parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
product_id | string | Yes | 33f1b4f6-94... | Product's ID to which the comment belongs. |
username | string | Yes | Joey | User name who posted the comment. |
star | int32 | Yes | 5 | Rating provided by the user (range: 1 to 5). |
image | string | No | http://abc.com/img.jpg;http://def.com/img.jpg | URLs of images attached to the comment, separated by semicolons. |
like | int32 | Yes | 100 | Number of likes for the comment. |
created_at | string | Yes | 2019-07-10 15:00:00 | Timestamp when the comment was created. Format: YYYY-MM-DD HH:mm:ss . |
content | string | Yes | Cheap but beautiful | Content of the comment. |
country | string | No | CN | Country code where the comment was created from (e.g., CN , US ). |
Response Explanation
Successful Response
Response Fields
Field | Type | Example | Description |
---|---|---|---|
comment.id | integer | 23532434 | Unique identifier for the comment. |
comment.store_id | integer | 633130 | ID of the store where the comment was created. |
comment.username | string | Joey | Name of the user who posted the comment. |
comment.email | string | "" | Email address of the user (if provided). |
comment.star | string | 5.0 | Rating provided by the user (as a string). |
comment.like | integer | 10 | Number of likes for the comment. |
comment.content | string | Cheap but beautiful | Content of the comment. |
comment.img | string | ["https://photokit.com/features/images/image-text-after.webp"] | List of image URLs attached to the comment (JSON string). |
comment.status | integer | 1 | Status of the comment 1: published, 0: unpublished |
comment.type | integer | 1 | Type of the comment |
comment.product_id | string | a1a88be0-a1d4-47e4-a2f2-ba6e131cf447 | ID of the product associated with the comment. |
comment.created_at | string | 2024-04-24 14:02:39 | Timestamp when the comment was created. Format: YYYY-MM-DD HH:mm:ss . |
comment.updated_at | string | 2024-04-25 08:22:58 | Timestamp when the comment was last updated. |
comment.country | string | CN | Country code where the comment was created from. |
comment.is_featured | integer | 0 | Indicates if the comment is featured (0: No, 1: Yes). |
comment.is_verified | integer | 0 | Indicates if the comment is verified (0: No, 1: Yes). |
comment.client_id | null | null | ID of the client who created the comment (if applicable). |
comment.anonymous | integer | 0 | Indicates if the comment was posted anonymously (0: No, 1: Yes). |
Error Response
Error responses in the API can be represented using two different fields: errors
and error
. Both fields provide details about issues encountered during request processing. Below is an explanation of the fields with their respective examples and descriptions.
Field | Type | Example | Description |
---|---|---|---|
errors | Array | A list of errors encountered during the request processing. |
Field | Type | Example | Description |
---|---|---|---|
error | Array | "store is not active" | Indicates an error encountered during the process. |
Request Examples
curl --request POST \
--url https://{shopdomain}.myshoplaza.com/openapi/2022-01/comments \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'access-token: YOUR_ACCESS_TOKEN' \
--data '{
"product_id": "33f1b4f6-94...",
"username": "Joey",
"star": 5,
"image": "http://abc.com/img.jpg;http://def.com/img.jpg",
"like": 100,
"created_at": "2019-07-10 15:00:00",
"content": "Cheap but beautiful",
"country": "CN"
}'
Success Response Example
{
"comment": {
"id": 23532434,
"store_id": 633130,
"username": "Joey",
"email": "",
"star": "5.0",
"like": 10,
"content": "Cheap but beautiful",
"img": "[\"https:\\/\\/photokit.com\\/features\\/images\\/image-text-after.webp\"]",
"status": 1,
"type": 1,
"product_id": "a1a88be0-a1d4-47e4-a2f2-ba6e131cf447",
"created_at": "2024-04-24 14:02:39",
"updated_at": "2024-04-25 08:22:58",
"country": "CN",
"is_featured": 0,
"is_verified": 0,
"client_id": null,
"anonymous": 0
}
}
Error Response Example
{
"error": "store is not active"
}
Error Details
Status Code | Message | Possible Reason | Example Response |
---|---|---|---|
400 | Bad Request | Invalid input format or request structure (e.g., missing required fields or incorrect data types). | Bad Request |
Unauthorized | The request is missing valid authentication credentials or the credentials provided are invalid. | Unauthorized | |
404 | Invalid or empty store name | invalid store name | { "errors": store is not active} |