Add Product Review
2/7/25Less than 1 minute
Add Review
Description
This API allows users to add a review for a specific product by providing a rating, comment, and product ID.
Endpoint
- URL:
/v1/reviews
- Method:
POST
Required Headers
{
"Authorization": "Bearer JWT_TOKEN",
"X-MerchantApiKey": "MERCHANT_API_KEY",
"Content-Type": "application/json"
}
๐ฅ Request Body
Field Name | Type | Required | Description |
---|---|---|---|
rating | Integer | Yes (1-5) | The rating given to the product (1 to 5). |
comment | String | Yes | The comment describing the review. |
productId | String | Yes | The ID of the product being reviewed. |
Example API Call (Using Fetch)
fetch("https://api.shopsynch.com/v1/reviews", {
method: "POST",
headers: {
"Authorization": "Bearer JWT_TOKEN",
"X-MerchantApiKey": "MERCHANT_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"rating": 5,
"comment": "Excellent product! Highly recommended.",
"productId": "12345",
"userId": "67890"
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
โ Sample 200 Response (Success)
{
"status": true,
"message": "Review added successfully",
"data": {
"id": "679f8f5a3b5f2173201c2582",
"createdDate": "2025-02-08T10:30:00",
"rating": 5,
"comment": "Excellent product! Highly recommended.",
"user": {
"id": "679f8f5a3b5f2173201cjsjs",
"fullName": "John Doe"
},
"product": {
"id": "679f8f5a3b5f2173201c2582",
"name": "Product Name",
"description": "product description"
}
}
}
โ Sample 404 Response (Not Found Error)
{
"status": false,
"message": "Product not found"
}
Next Steps
- Learn more about Fetching Reviews
- Learn more about Updating Reviews