📝 Create a Product Review
This guide explains how to create a new product review using the Alphabite Reviews Plugin.
✅ Prerequisites
- A Medusa backend with the Reviews plugin installed and configured.
- A product to review.
- (Optional) Customer authentication if
allowOnlyVerifiedPurchases
istrue
.
🔨 Step-by-Step Implementation
1. Prepare Review Data
Gather the necessary information for the review:
product_id
: The ID of the product being reviewed.rating
: A number between 1 and 5.content
: The text of the review.image_base64s
: (Optional) An array of base64 encoded images.title
: (Optional) A title for the review.
2. Send the Request
Use the SDK or REST API to create the review.
- Using SDK
- Using REST (Medusa SDK or fetch)
const createdReview = await sdk.alphabite.reviews.create({
product_id: "prod_...",
rating: 5,
content: "This product is amazing!",
title: "Highly Recommended",
});
import { CreateReviewInput, CreateReviewOutput } from "@alphabite/medusa-sdk";
const createdReview = await sdk.client.fetch<CreateReviewOutput>("/store/reviews", {
method: "POST",
body: {
product_id: "prod_...",
rating: 5,
content: "This product is amazing!",
title: "Highly Recommended",
image_base64s: [],
} as CreateReviewInput,
});
API Reference
Learn more about our Medusa SDK Wrapper Alphabite Medusa SDK Wrapper 🔗
You can view the full endpoint documentation for Create Review 🔗
📝 Notes
- Ensure the
product_id
is valid. - If
allowOnlyVerifiedPurchases
istrue
in your plugin configuration, the customer must have purchased the product to leave a review. - If
allowMultipleReviewsPerProduct
isfalse
, a customer can only leave one review per product. - Image uploads are optional. If enabled, ensure images are base64 encoded.