Review answers

These endpoints are called from a shopper's browser, so they take your publishable key rather than a secret one. Anything specific to one customer also takes a signed email and timestamp: see Identifying the customer for how to produce the signature.

POST /widgets/review-answers

Ask a question about a product and get an answer generated from its published reviews, with the reviews it draws on. The answer is shown only to the shopper who asked; it is never published anywhere. Repeated questions are answered from cache. Only available when the store has review answers switched on, which GET /widgets/reviews reports as reviewAnswers.enabled.

Query Parameters

apiPublishableKeystringrequired

Your organization's publishable key, from Settings, API keys.

Body Parameters

productSlugstringrequired

Slug of the product the question is about.

questionstringrequired

The shopper's question, up to 300 characters.

visitorTokenstringrequired

Random id identifying the visitor's browser, used only for rate limiting. Only a hash of it is ever stored, and never with the question.

Request
curl \
  -X POST \
  "https://api.cascade.dev/widgets/review-answers?apiPublishableKey=pk_YOUR_PUBLISHABLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "productSlug": "string",
  "question": "string",
  "visitorToken": "string"
}'
Response
{
  "answered": true,
  "answer": "string",
  "reviewCount": 0,
  "generatedAt": "string",
  "citedReviews": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "rating": 0,
      "title": "string",
      "excerpt": "string",
      "createdAt": "string"
    }
  ]
}