---
name: bazaarproof-api
description: Integrate a store, website or backend with the BazaarProof API: show a seller's BazaarProof rating, reviews or proof strip on their site, send review requests after an order is delivered, sign order events, send reviews the seller's own website collected, add BazaarProof's review form to a site, or verify BazaarProof webhooks. Use when code calls bazaarproof.in/api/v1, or the user mentions BazaarProof keys (bp_sk_, bp_site_, bpsig_, whsec_), reviews, review requests or webhooks.
---

# BazaarProof API

BazaarProof is an Indian review site for Instagram, WhatsApp and small online sellers. Its API (`https://bazaarproof.in/api/v1`) lets a seller's own systems read their public record and ask buyers for reviews. Every key belongs to one seller; there is no seller id in any path.

Full reference: [references/api.md](references/api.md). Machine-readable: [references/openapi.json](references/openapi.json). Online: https://bazaarproof.in/developers.md

## Before writing code

1. Find out which key the user has. Never ask them to paste a secret key into chat; read it from the environment.
   - `BAZAARPROOF_KEY`: secret key `bp_sk_…`. **Server only.**
   - `BAZAARPROOF_SIGNING_SECRET`: `bpsig_…`, needed only for `POST /events` and `POST /reviews`. **Server only.**
   - `BAZAARPROOF_SITE_KEY`: `bp_site_…`. Public, read only, fine in HTML.
   - `BAZAARPROOF_WEBHOOK_SECRET`: `whsec_…`, one per webhook endpoint. **Server only.**
2. Keys come from the seller's dashboard, **API & webhooks**. A secret key is shown once; a lost one is replaced.
3. Check the plan. Reads are free. Writes (`POST /review-requests`, `POST /events`, `POST /reviews`, `POST /promotions`), webhooks and customer details (`/customers/*`, `/reviews/{id}/customer`, `include=customer`, `/orders/{ref}/reviews`) need **Enterprise**; WhatsApp and SMS requests need **Seller** or above. A `402 plan_required` means tell the seller, not retry.

## Pick the endpoint

| The user wants to | Use | Key |
|---|---|---|
| Show rating and review count | `GET /business` → `rating` | site key in the browser, or secret key on the server |
| Show one product's rating (pooled across its group) | `GET /products?id={store product id}` → `rating` | same |
| Product stars in Google for a product page (Enterprise) | `GET /products/{store product id}/jsonld?widget={widget key}` → merge `aggregateRating` + `review` into the page's Product JSON-LD | same |
| Show the five-fact proof strip | `GET /proof-strip` | same |
| List reviews on their site | `GET /reviews`, follow `next` | same |
| Ask one buyer for a review | `POST /review-requests` | secret key with write |
| Ask automatically from a store or courier tool | `POST /events` (signed), on `order.delivered` | secret key with write + signing secret |
| Keep their own review form and send its reviews to BazaarProof (Lighter) | `POST /reviews` (signed), one call per review as it arrives | secret key with write + signing secret |
| Replace their review form with BazaarProof's (Full) | No API call: the seller creates a **Review form** widget and you paste its snippet where the old form was | none |
| Show offers on the seller's BazaarProof page | `POST /promotions` with the whole feed (up to 10); `GET /promotions` to read it | secret key with write |
| Offer loyalty rewards for reviewing an order | `promos` (up to 5) on `POST /events` | secret key with write + signing secret |
| Sync reviews with their customers into a CRM (Enterprise) | `GET /reviews?include=customer`, follow `next` | secret key, server only |
| Match a review to an order, or see one customer's reviews (Enterprise) | `GET /reviews/{id}/customer`, `GET /customers/reviews?email_sha256=…`, `POST /customers/lookup`, `GET /orders/{ref}/reviews` | secret key, server only |
| React to new reviews or complaints | Webhook receiver, verify `BazaarProof-Signature` | webhook secret |

## Workflows

**Show the record on a website (no backend).** Call `GET https://bazaarproof.in/api/v1/proof-strip?site=$SITE_KEY` from the page. It works only on websites the seller listed in the dashboard (**Widgets → Your websites**), plus localhost; a 403 means the site isn't listed, so ask the seller to add it rather than working around it. Render all five `facts` in order with `updated` and a link to `profileUrl`. If `state` is `inactive`, show `message` instead. Responses are cached for 60 s; don't poll faster.

**Show reviews.** `GET /reviews?per_page=20`, newest first. Render every review, low ratings included. Show `incentiveNote` when `incentivised` is true, and label `source: "import"` reviews as imported. Link each review to its `url`.

**Send review requests after delivery.** On the store's delivered event, POST to `/events` with `type: "order.delivered"`, a unique `id` (for example `shop-{orderId}-delivered`), `order.ref`, the buyer's contact and the `consent` the buyer gave at checkout. Sign with `scripts/sign-event.mjs` or the same code. Read `outcome` in the response: only `queued` sends anything; the others explain why not. On `order.cancelled`, send that event too: pending requests are cancelled.

**Collect reviews on the seller's website.** Ask which they want. *Full*: BazaarProof's form replaces theirs, the buyer confirms with a code, and the review counts as a BazaarProof review (Seller plan and up). Paste the widget snippet from the dashboard (`<div data-bazaarproof="w_…"></div>` and `embed.js`) and remove the old form. Each form variation (a separate widget, its own key) collects either business reviews (the shop as a whole) or product reviews; ask the seller which one goes where. On product pages use a product form and add `data-bp-product="{store product id}"` (and `data-bp-gtin` with the barcode number if the store has one; optional); the product must be in the seller's product list with a photo, or the review is saved as a business review. Don't rebuild the form or post to `/api/collect` yourself. *Lighter*: keep their form and, on each new review, POST it to `/reviews` with the site's own review `id`, `rating`, `body` and `author.name` (required; `author.email` is optional and stays private), plus `product` (`id`, `name`, https `image`, optional `url` and `gtin` barcode number) for a product review (leave it out for a business review), signed like events (`node scripts/sign-event.mjs review.json --send reviews`). Send every rating, unedited, as it arrives. These show as imported from the seller's website, never verified, and can't be edited or removed afterwards.

**Receive webhooks.** Verify the signature on the **raw** body before parsing (`scripts/verify-webhook.mjs`), drop repeats by `BazaarProof-Event-Id`, reply 2xx within 10 s, then do the work. `review.created` carries `data.customer` (name, email, verified phone, order reference) for matching the review to the order; store it like any customer record and never publish it.

**Promotions.** Ask the seller for each offer's headline, a square image at least 500 x 500 (https), a description and terms. For the profile, POST the whole list to `/promotions` (it replaces what's there, including offers typed in the dashboard). For a review reward, add `promos` to the `order.delivered` event. Never word an offer around stars, ratings or positive reviews: the API refuses it with `400`.

## Rules (from the product's non-negotiables)

- Show the record as it is. Never filter out low ratings or pick only good reviews; the API has no rating filter on purpose.
- Show figures with their date and a link to the profile. Don't recompute or reword them into claims.
- Never call a seller "verified", "safe" or "certified".
- Send `consent: true` only when the buyer actually agreed to hear from this seller about this order on this channel.
- Rewards are for any honest review. Never word an incentive around stars, ratings or positive reviews.
- Never put a secret key, signing secret or webhook secret in browser code, mobile apps, logs or URLs.
- Data labelled sample is invented; don't present it as real.
- Customer details (email, phone, name) are for following up on orders. Never publish them, show them next to a review, or put a raw email or phone in a URL: hash it for the GET.
- The API cannot delete, hide, edit or reorder reviews or complaints. Don't look for a workaround; tell the user the seller can reply or dispute in the dashboard.

## Errors

Every error is `{ "error": { "code", "message" } }`. `message` is safe to show the seller.

- `429 rate_limited`: wait `Retry-After` seconds. Limits: 120 reads/min and 60 writes/min per secret key, 600/min per site key.
- `401 invalid_signature`: sign the exact bytes sent; check the server clock (5-minute window).
- `402 plan_required`, `422 opted_out`, `429 limit_reached`, `403 suspended`: don't retry; tell the seller.
- `405`: PUT, PATCH and DELETE don't exist, by design.

Full table: references/api.md, section "Errors".

## Scripts

- `node scripts/sign-event.mjs event.json`: prints the `BazaarProof-Signature` header for a body (uses `BAZAARPROOF_SIGNING_SECRET`). Add `--send` to POST it to `/events` with `BAZAARPROOF_KEY`, or `--send reviews` for `POST /reviews`.
- `node scripts/verify-webhook.mjs body.json "t=…,v1=…"`: checks a delivery against `BAZAARPROOF_WEBHOOK_SECRET`. Exits 0 if valid.
