Create Comment

🔒

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:

  1. Gathering customer feedback for products.
  2. 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 NameTypeRequiredParameter LocationParameter ValueDescription
Access-TokenStringYesHeaderBx-_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-TypeStringYesHeaderapplication
/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 NameTypeMandatoryParameter LocationExample ValueDescription
errorStringNoResponse 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" }.
errorsArrayNoResponse Body{ "errors"["ProductId is required"] }A list of errors that occurred during the request processing. Example: { "errors": [ "No Context" ] }.
Request-IdStringYesHeaderBx-_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

ParameterTypeRequiredExampleDescription
product_idstringYes33f1b4f6-94...Product's ID to which the comment belongs.
usernamestringYesJoeyUser name who posted the comment.
starint32Yes5Rating provided by the user (range: 1 to 5).
imagestringNohttp://abc.com/img.jpg;http://def.com/img.jpgURLs of images attached to the comment, separated by semicolons.
likeint32Yes100Number of likes for the comment.
created_atstringYes2019-07-10 15:00:00Timestamp when the comment was created. Format: YYYY-MM-DD HH:mm:ss.
contentstringYesCheap but beautifulContent of the comment.
countrystringNoCNCountry code where the comment was created from (e.g., CN, US).

Response Explanation

Successful Response

Response Fields

FieldTypeExampleDescription
comment.idinteger23532434Unique identifier for the comment.
comment.store_idinteger633130ID of the store where the comment was created.
comment.usernamestringJoeyName of the user who posted the comment.
comment.emailstring""Email address of the user (if provided).
comment.starstring5.0Rating provided by the user (as a string).
comment.likeinteger10Number of likes for the comment.
comment.contentstringCheap but beautifulContent of the comment.
comment.imgstring["https://photokit.com/features/images/image-text-after.webp"]List of image URLs attached to the comment (JSON string).
comment.statusinteger1Status of the comment 1: published, 0: unpublished
comment.typeinteger1Type of the comment
comment.product_idstringa1a88be0-a1d4-47e4-a2f2-ba6e131cf447ID of the product associated with the comment.
comment.created_atstring2024-04-24 14:02:39Timestamp when the comment was created. Format: YYYY-MM-DD HH:mm:ss.
comment.updated_atstring2024-04-25 08:22:58Timestamp when the comment was last updated.
comment.countrystringCNCountry code where the comment was created from.
comment.is_featuredinteger0Indicates if the comment is featured (0: No, 1: Yes).
comment.is_verifiedinteger0Indicates if the comment is verified (0: No, 1: Yes).
comment.client_idnullnullID of the client who created the comment (if applicable).
comment.anonymousinteger0Indicates 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.

FieldTypeExampleDescription
errorsArrayA list of errors encountered during the request processing.
FieldTypeExampleDescription
errorArray "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 CodeMessagePossible ReasonExample Response
400Bad RequestInvalid input format or request structure (e.g., missing required fields or incorrect data types).Bad Request
UnauthorizedThe request is missing valid authentication credentials or the credentials provided are invalid.Unauthorized
404Invalid or empty store nameinvalid store name{ "errors": store is not active}
Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!