Skip to main content

Endpoint

POST /api/v1/product-reviews
Create a new product review for a furniture product.

Request Body

productId
integer
required
ID of the product being reviewed
userId
integer
required
ID of the user creating the review
rating
integer
required
Rating given to the product (typically 1-5)
comment
string
Text comment or review description

Response

Returns the created product review object.
id
integer
required
Unique identifier for the newly created review
productId
integer
required
ID of the product being reviewed
userId
integer
required
ID of the user who created the review
rating
integer
required
Rating given to the product
comment
string
Text comment or review description
createdAt
string
Timestamp when the review was created (ISO 8601 format)

Status Codes

201
Created
Product review successfully created
400
Bad Request
Invalid request body or validation error

Example Request

curl -X POST "https://api.example.com/api/v1/product-reviews" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "userId": 501,
    "rating": 5,
    "comment": "Excellent quality sofa! Very comfortable and looks great in my living room."
  }'

Example Response

{
  "id": 1,
  "productId": 101,
  "userId": 501,
  "rating": 5,
  "comment": "Excellent quality sofa! Very comfortable and looks great in my living room.",
  "createdAt": "2024-01-15T10:30:00"
}

Response Headers

The response includes a Location header with the URI of the created resource:
Location: /api/v1/product-reviews/1

Validation Rules

  • productId is required and must be a valid integer
  • userId is required and must be a valid integer
  • rating is required and must be a valid integer
  • comment is optional but should be a string if provided

Notes

  • The createdAt timestamp is automatically set by the server
  • The review ID is automatically generated

Build docs developers (and LLMs) love