Reviews are attached to individual products and to the authenticated user who writes them. They appear on the product detail page (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSCaicedo/Api-Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/ecommerce/product/{slug}) alongside a computed rating distribution that shows the percentage breakdown across all five star levels. Both creating and updating a review calls Cache::flush() so that the product page immediately reflects the new data.
POST /api/ecommerce/reviews
Creates a new product review. Requires a valid Bearer token. Theuser_id is set server-side from the token — clients must not supply it.
Body
The ID of the product being reviewed.
The review text. No maximum length is enforced at the API level; apply frontend validation as needed.
Star rating from
1 (worst) to 5 (best). The API stores the raw integer — enforce the 1–5 range on the client side.Response
The newly created review model, including the server-assigned
id, user_id, and timestamps.Creating a review calls
Cache::flush(), which invalidates all cached responses — including the product detail page, the storefront home feed, and the menu. The next request to GET /api/ecommerce/product/{slug} will rebuild the cache with the updated review list and rating distribution.PUT /api/ecommerce/reviews/
Updates an existing review. Requires a valid Bearer token. The server does not re-verify ownership — ensure your frontend only allows users to edit their own reviews.Path parameters
| Parameter | Type | Description |
|---|---|---|
id | integer | The review ID to update. |
Body
Updated review text.
Updated star rating (1–5).
Response
Updating a review also calls
Cache::flush(), clearing all cached storefront data for the same reason as creating a review.Rating Distribution
When you fetch a product viaGET /api/ecommerce/product/{slug}, the response includes a rating_distribution object that summarises the spread of star ratings across all reviews for that product.
"1" through "5") maps to a percentage of total reviews at that star level, rounded to 2 decimal places. The percentages are calculated as:
0.00.
| Key | Meaning |
|---|---|
"5" | Percentage of reviews that gave 5 stars |
"4" | Percentage of reviews that gave 4 stars |
"3" | Percentage of reviews that gave 3 stars |
"2" | Percentage of reviews that gave 2 stars |
"1" | Percentage of reviews that gave 1 star |
avg_reviews and count_reviews fields on the product resource give the overall average and total count:
reviews_avg and reviews_count accessors on the Product model and are available on every ProductEcommerceResource response.