Skip to content

create-product-review ​

Method: POST
Path: /catalog/products/{product_id}/reviews

Tags: Reviews

Summary ​

Create product review

Description ​

Create a product review using an anonymous or signed-in bearer session. The current session user is recorded as the reviewer. New reviews await approval and are not featured.

Storefront SDK Usage ​

SDK Method: sdk.catalog.createProductReview()

Example:

typescript
const { data, error } = await sdk.catalog.createProductReview(
  { product_id: "prod_123" },
  {
    order_number: "ORD-001",
    rating: 5,
    review_text: "Excellent product! Highly recommended.",
    images: [
      new File(["image data"], "review1.jpg", { type: "image/jpeg" }),
      new File(["image data"], "review2.jpg", { type: "image/jpeg" })
    ]
  }
);

if (error) {
  console.error("Failed to create review:", error);
  return;
}

console.log("Review created successfully:", data.review);

TypeScript Definition ​

typescript
"create-product-review": {
        parameters: {
            query?: never;
            header?: never;
            path: {
                /** @description id of a particular product */
                product_id: string;
            };
            cookie?: never;
        };
        requestBody: {
            content: {
                "application/json": {
                    order_number: $Write<string>;
                    rating: number;
                    review_text: string;
                    name?: string;
                    /** Format: email */
                    email?: string;
                    tags?: string[];
                };
                "application/x-www-form-urlencoded": {
                    order_number: $Write<string>;
                    rating: number;
                    review_text: string;
                    name?: string;
                    /** Format: email */
                    email?: string;
                    tags?: string[];
                };
                "multipart/form-data": components["schemas"]["CreateReview"];
            };
        };
        responses: {
            /** @description Success response */
            201: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        /** @example Review submitted successfully. */
                        message: string;
                        success: boolean;
                        content: {
                            review: components["schemas"]["CatalogCreatedReview"];
                        };
                    };
                };
            };
            /** @description The request is invalid. */
            400: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": {
                        message: string;
                        success: boolean;
                        code?: string;
                        errors?: {
                            [key: string]: unknown;
                        } | string;
                        content?: {
                            [key: string]: unknown;
                        };
                    };
                };
            };
            401: components["responses"]["Unauthorized"];
            403: components["responses"]["Forbidden"];
            404: components["responses"]["NotFound"];
            500: components["responses"]["InternalServerError"];
            504: components["responses"]["GatewayTimeout"];
        };
    };

Component References ​

ReferenceResolves To
components["schemas"]["CreateReview"]CreateReview
components["schemas"]["CatalogCreatedReview"]CatalogCreatedReview
components["responses"]["Unauthorized"]Unauthorized
components["responses"]["Forbidden"]Forbidden
components["responses"]["NotFound"]NotFound
components["responses"]["InternalServerError"]InternalServerError
components["responses"]["GatewayTimeout"]GatewayTimeout

Parameters ​

  • product_id (path): id of a particular product

Request Body ​

Content Types: application/json, application/x-www-form-urlencoded, multipart/form-data

Responses ​

201 ​

Success response

400 ​

The request is invalid.

401 ​

Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.

403 ​

Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.

404 ​

Requested resource not found

500 ​

The request failed because of an unexpected error.

504 ​

The request timed out.

OpenAPI Definition ​

json
{
  "tags": [
    "Reviews"
  ],
  "operationId": "create-product-review",
  "summary": "Create product review",
  "description": "Create a product review using an anonymous or signed-in bearer session. The current session user is recorded as the reviewer. New reviews await approval and are not featured.",
  "externalDocs": {
    "url": "https://llm-docs.commercengine.io/storefront/operations/create-product-review",
    "description": "API reference for the create-product-review operation"
  },
  "parameters": [
    {
      "name": "product_id",
      "in": "path",
      "description": "id of a particular product",
      "required": true,
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "description": "Create Product Review model",
          "type": "object",
          "required": [
            "order_number",
            "rating",
            "review_text"
          ],
          "properties": {
            "order_number": {
              "type": "string",
              "maxLength": 45,
              "minLength": 1,
              "pattern": "\\S",
              "writeOnly": true
            },
            "rating": {
              "type": "number",
              "maximum": 5,
              "minimum": 1,
              "multipleOf": 0.5
            },
            "review_text": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "email": {
              "type": "string",
              "format": "email"
            },
            "tags": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              }
            }
          }
        }
      },
      "application/x-www-form-urlencoded": {
        "schema": {
          "description": "Create Product Review model",
          "type": "object",
          "required": [
            "order_number",
            "rating",
            "review_text"
          ],
          "properties": {
            "order_number": {
              "type": "string",
              "maxLength": 45,
              "minLength": 1,
              "pattern": "\\S",
              "writeOnly": true
            },
            "rating": {
              "type": "number",
              "maximum": 5,
              "minimum": 1,
              "multipleOf": 0.5
            },
            "review_text": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "email": {
              "type": "string",
              "format": "email"
            },
            "tags": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              }
            }
          }
        }
      },
      "multipart/form-data": {
        "schema": {
          "$ref": "#/components/schemas/CreateReview"
        }
      }
    }
  },
  "responses": {
    "201": {
      "description": "Success response",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success",
              "content"
            ],
            "properties": {
              "message": {
                "type": "string",
                "examples": [
                  "Review submitted successfully."
                ]
              },
              "success": {
                "type": "boolean"
              },
              "content": {
                "properties": {
                  "review": {
                    "$ref": "#/components/schemas/CatalogCreatedReview"
                  }
                },
                "required": [
                  "review"
                ],
                "type": "object"
              }
            }
          }
        }
      }
    },
    "400": {
      "description": "The request is invalid.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "message",
              "success"
            ],
            "properties": {
              "message": {
                "type": "string",
                "x-speakeasy-error-message": true
              },
              "success": {
                "type": "boolean"
              },
              "code": {
                "type": "string"
              },
              "errors": {
                "anyOf": [
                  {
                    "type": "object",
                    "additionalProperties": true
                  },
                  {
                    "type": "string"
                  }
                ]
              },
              "content": {
                "additionalProperties": true,
                "type": "object"
              }
            }
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    },
    "500": {
      "$ref": "#/components/responses/InternalServerError"
    },
    "504": {
      "$ref": "#/components/responses/GatewayTimeout"
    }
  },
  "security": [
    {
      "Authorization": []
    }
  ],
  "x-speakeasy-group": "catalog",
  "x-speakeasy-ignore": true,
  "x-speakeasy-name-override": "createProductReview"
}

Auto-generated from OpenAPI spec and TypeScript definitions

Last updated: