Questions

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.

GET /widgets/questions

List a product's published questions with their published answers, newest question first. Only what a moderator has approved appears here, and an asker's email never does.

Query Parameters

apiPublishableKeystringrequired

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

productSlugstringrequired

Slug of the product whose questions to list.

limitnumber

How many questions to return.

cursorstring

The nextCursor from the previous page.

Request
curl \
  "https://api.cascade.dev/widgets/questions?apiPublishableKey=pk_YOUR_PUBLISHABLE_KEY&productSlug=string"
Response
{
  "enabled": true,
  "allowShopperAnswers": true,
  "totalQuestions": 0,
  "questions": [
    {
      "id": "string",
      "body": "string",
      "askerName": "string",
      "createdAt": "string",
      "answers": ["..."]
    }
  ],
  "nextCursor": "string"
}

POST /widgets/questions

Ask a question about a product. The question is recorded for the store to answer and published once a moderator approves it. The response also carries an instant answer generated from the product's published reviews, to read while the store writes a real one; it is null when the store has generated answers switched off or unavailable, which never stops the question being recorded.

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 500 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.

namestring

The name to show beside the question once it is published. Omit to ask anonymously.

emailstring (email)

Where to send the answer. Never published, and used for nothing else. Omit to ask without leaving one.

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

POST /widgets/questions/{id}/answers

Answer another shopper's published question. The answer waits for the store to approve it before it appears. Only available when the store allows shoppers to answer, which GET /widgets/questions reports as allowShopperAnswers.

Path Parameters

idstring (uuid)required

The ID of the published question being answered.

Query Parameters

apiPublishableKeystringrequired

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

Body Parameters

answerstringrequired

What this shopper wants to tell the person who asked.

visitorTokenstringrequired

Random id identifying the visitor's browser, used only for rate limiting.

namestring

The name to show above the answer. Omit to answer anonymously.

Request
curl \
  -X POST \
  "https://api.cascade.dev/widgets/questions/550e8400-e29b-41d4-a716-446655440000/answers?apiPublishableKey=pk_YOUR_PUBLISHABLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "answer": "string",
  "visitorToken": "string",
  "name": "string"
}'
Response
{
  "answerId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending"
}