# BazaarProof API reference (v1)

> Read a seller's public BazaarProof record (summary, proof strip, published reviews), queue review requests, send order and delivery events (with loyalty promos), send reviews the seller's website collected, publish a promotions feed on the profile, look up who wrote a review, and receive signed webhooks. Version `2026-11-25`.

Other formats: [OpenAPI 3.1](https://bazaarproof.in/api/v1/openapi.json) · [Agent Skill (zip)](https://bazaarproof.in/skills/bazaarproof-api.zip) · [Skill files](https://bazaarproof.in/skills/bazaarproof-api/SKILL.md) · [Human docs](https://bazaarproof.in/developers)

## Facts at a glance

| | |
|---|---|
| Base URL | `https://bazaarproof.in/api/v1` |
| Format | JSON over HTTPS. Send `Content-Type: application/json` on POST. |
| Auth, server | `Authorization: Bearer bp_sk_…` (secret key) |
| Auth, browser | `?site=bp_site_…` or header `BazaarProof-Site` (site key, read only) |
| Reads | Free on every plan (Free and up) |
| Writes and webhooks | Enterprise plan, read + write key |
| Customer details | Enterprise plan, secret key only (never a site key) |
| Rate limits | 120 reads/min and 60 writes/min per secret key; 600/min per site key |
| Errors | `{ "error": { "code", "message" } }`, see [Errors](#errors) |
| Signing | `BazaarProof-Signature: t={unix},v1={hex HMAC-SHA256 of "{t}.{raw body}"}`, 5-minute window |
| Never | edits, hides, deletes or reorders reviews or complaints; returns buyer contact details to a site key or below Enterprise |

## Rules an integration must follow

These come from the product's non-negotiables. Breaking them is not a bug the API can catch for you.

1. **Show the record as it is.** No filtering or hiding low ratings, no picking only good reviews. The API has no rating filter or sort on purpose.
2. **Show numbers with their date and a link.** Proof strip facts carry `updated` and `profileUrl`; show both. Don't recompute, round or restyle the figures into claims.
3. **Never call a seller "verified", "safe" or "certified".** The record is what was observed.
4. **Only send `consent: true` when the buyer agreed** to hear from the seller about that order on that channel. It is recorded as evidence.
5. **Rewards are for any honest review**, never tied to the rating. Don't word them around stars or positive reviews; the API refuses that wording.
6. **Keep secret keys on servers.** Never in page code, apps, logs or URLs. The site key is the only key that may appear in HTML.
7. **Anything labelled sample is invented data.** Don't present it as real.
8. **Customer details are for following up on orders.** Never publish a buyer's name, email or phone, or show them next to a review. Never put a raw email or phone in a URL: hash it (`/customers/reviews`) or POST it (`/customers/lookup`).
9. **Promotions and order promos are the seller's offers.** They can't mention stars, ratings or positive reviews; order promos are a reward for any review, and reviews written through them are labelled with the offer.

## Keys

| Key | Format | Where | Can |
|---|---|---|---|
| Secret | `bp_sk_{8}_{32}` | Server only | Read; write too if created with write access |
| Signing secret | `bpsig_{32}` | Server only | Signs `POST /events` and `POST /reviews` bodies. Comes with each secret key. |
| Site key | `bp_site_{20}` | Safe in HTML | Read only, from browsers (CORS), and only on the seller's listed websites. |
| Webhook secret | `whsec_{32}` | Your webhook receiver | Verifies deliveries from us. One per endpoint. |

- The seller creates and revokes keys in the dashboard under **API & webhooks**. A secret key is shown once; only a fingerprint is stored, so a lost key is replaced, not recovered.
- Each key belongs to one seller. All endpoints act on that seller; there is no seller id in the path.
- A site key works from a browser only on the seller's listed websites, plus localhost for testing. Calls with no `Origin` header (servers) are not checked: the data is public.
- Site-key responses are `Cache-Control: private, max-age=60`. Secret-key responses are `no-store`.

## Header loader

One tag in the seller's `<head>` places their widgets as configured in the dashboard (**Widgets → On your website**). Use this rather than calling the API from page code when the goal is only to show the record.

```html
<script async src="https://bazaarproof.in/embed.js" data-site="bp_site_XXXXXXXXXXXXXXXXXXXX"></script>
```

- Existing `<div data-bazaarproof="…">` widgets keep working. It loads async, uses shadow roots, sets no cookies and sends nothing about the visitor.
- Widgets and the loader show only on the seller's listed websites (dashboard, **Widgets → Your websites**; `yourshop.in` covers `www.yourshop.in`). With no websites listed they show nowhere. A copied tag shows nothing elsewhere. Placement changes reach the site within about 5 minutes.
- `embed.js` is minified and cached for 4 hours; don't copy it to your own server, or it stops getting fixes.

## Collecting reviews on the seller's website

Two integrations. Pick one per website; widgets show the reviews the same way either way.

| | Full | Lighter |
|---|---|---|
| What it is | BazaarProof's review form replaces the seller's own form | The seller keeps their form; their server sends each review |
| How | A **Review form** widget: `<div data-bazaarproof="w_…">` plus `embed.js` | [`POST /reviews`](#post-reviews), signed |
| Who confirms the buyer | BazaarProof: a 6-digit code to the buyer's phone or email | Nobody: BazaarProof can't check who wrote it |
| How it's shown | A BazaarProof review (`source: "widget"`) | Imported from the seller's website (`source: "import"`, `importedFrom` = their host), never a verified purchase |
| Plan | Seller and up | Enterprise, read + write key |

- **Two kinds of review.** A review is a **business review** (the shop as a whole: ordering, packing, delivery, support) or a **product review** (one product). Every review carries `subject`, and a product review carries `product` with the store's id, name, page and a thumbnail.
- **Full.** The seller creates a Review form widget in the dashboard (**Widgets**) and pastes its snippet where their form was. It works only on the seller's listed websites. A seller can make several Review form widgets (variations), each with its own key, heading, intro and optional questions, and each collects either business reviews or product reviews; use the snippet of the variation meant for that page. A product form shows the product's photo and name at the top. It uses its own fixed product, or the one the snippet names with `data-bp-product="{store product id}"` (and optionally `data-bp-gtin="{barcode number}"`), so one snippet in the product page template covers every product. The product must be in the seller's product list (**Products**, with a photo address); a product the list doesn't have is saved as a business review. The buyer's contact is never shown to the seller, and no cookie is set on the store. There's no API call to make: don't rebuild the form in your own code, and don't post to `/api/collect` from a server.
- **Lighter.** Send every review the seller's form receives, low ratings included, as it arrives. Don't filter, hold back or edit them first: that breaks rule 1.

## Rate limits

Fixed one-minute windows per key, the same on every plan. Every response has `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset` (seconds). Over the limit: `429 rate_limited` with `Retry-After` (seconds). Wait that long, then retry.

## Errors

```json
{ "error": { "code": "plan_required", "message": "Write endpoints are on the Enterprise plan. Reads stay free." } }
```

`message` is plain English and safe to show to the seller. Some errors add `field`.

| Status | code | When | What to do |
|---|---|---|---|
| 400 | `invalid_request` | A body field or query parameter is missing or wrong. `message` names it; `field` may too. | Fix the request. Don't retry unchanged. |
| 401 | `unauthorized` | No key, a malformed key, or a revoked one. | Check the Authorization header. Ask the seller for a new key if it was revoked. |
| 401 | `invalid_signature` | POST /events or POST /reviews signature missing, malformed, more than 5 minutes off, or not matching the body. | Sign the exact bytes you send with this key's signing secret; check the clock. |
| 402 | `plan_required` | A write endpoint for a seller not on the plan that includes it. | Tell the seller which plan is needed. Reads keep working. |
| 403 | `forbidden` | Read-only key used for a write, site key used for a write, or site key used from a website the seller hasn't listed. | For writes, use a read + write secret key from a server. For a website, ask the seller to add it under Widgets → Your websites. |
| 403 | `suspended` | The seller's profile is suspended. Writes pause; reads still work. | Stop writing. Nothing to retry until the seller sorts it out. |
| 404 | `not_found` | Unknown endpoint, or the seller's page is not available. | Check the path. |
| 405 | `method_not_allowed` | PUT, PATCH or DELETE. The API never edits, hides or deletes reviews or complaints. | There is no way to do this through the API, by design. |
| 422 | `opted_out` | The buyer asked not to get review requests on that channel. | Don't retry, don't try another channel to get around it. |
| 429 | `rate_limited` | Too many calls for this key in the current minute. | Wait `Retry-After` seconds, then retry. |
| 429 | `limit_reached` | The seller's monthly request (or WhatsApp) allowance is used up. | Don't retry this month; tell the seller. |
| 503 | `paused` | BazaarProof has paused this kind of write for a while (abuse protection). | Keep the item and retry later, with backoff. Nothing was saved. |

## Endpoints

### GET /business

The key's seller, as their public page shows it. Any key.

```bash
curl https://bazaarproof.in/api/v1/business -H "Authorization: Bearer $BAZAARPROOF_KEY"
```

Response (sample data):

```json
{
  "object": "business",
  "id": "biz_4u5ponu3502ri2sg",
  "slug": "neel-loom-studio",
  "name": "Neel Loom Studio",
  "tagline": "Hand-block printed cotton sarees",
  "url": "https://bazaarproof.in/b/neel-loom-studio",
  "status": "claimed",
  "claimed": true,
  "claimedAt": "2026-03-02T10:00:00.000Z",
  "inactive": false,
  "category": { "slug": "handloom", "name": "Handloom & sarees" },
  "city": { "slug": "jaipur", "name": "Jaipur", "state": "Rajasthan" },
  "rating": { "average": 4.4, "count": 37, "counts": { "1": 2, "2": 1, "3": 3, "4": 8, "5": 23 }, "lastReviewAt": "2026-11-20T09:12:00.000Z" },
  "officialAccounts": { "website": "https://neelloom.in", "instagramHandle": "neelloom", "whatsappNumber": "+919800000000", "upiId": null, "upiPayeeName": null },
  "onBazaarProofSince": "2026-03-02T00:00:00.000Z"
}
```

- `status`: `claimed` | `unclaimed` | `suspended`. `rating.average` is null with no reviews; always show it with `rating.count`.
- `whatsappNumber` only for a claimed seller. `upiId` and `upiPayeeName` only when the claimed seller declared them; otherwise null.

### GET /products

One of the seller's products, by your store's product id, with the rating it shows. Any key.

```bash
curl "https://bazaarproof.in/api/v1/products?id=8841" -H "Authorization: Bearer $BAZAARPROOF_KEY"
```

Response (sample data):

```json
{
  "object": "product",
  "id": "8841",
  "name": "Indigo saree",
  "url": "https://neelloom.in/p/indigo-saree",
  "imageUrl": "https://neelloom.in/img/indigo-saree.webp",
  "rating": { "average": 4.3, "count": 12, "counts": { "1": 1, "2": 0, "3": 1, "4": 3, "5": 7 }, "lastReviewAt": "2026-11-20T09:12:00.000Z" },
  "group": { "productIds": ["8841", "8842", "8843"] }
}
```

- `group` is not null when the seller grouped this product with others (one design in several colours, one item listed twice). Then `rating` counts every published review of every product in `group.productIds`, low ratings included: the same numbers the product widget shows.
- `rating.average` is null with no reviews; always show it with `rating.count`. An `id` that isn't in the seller's product list returns `404 not_found`.

### GET /products/{id}/jsonld

Enterprise. schema.org Product rating markup (`aggregateRating` + up to 10 `review` nodes) for the seller's own product page, to merge into its existing Product JSON-LD on the server. Any key; `402 plan_required` below Enterprise.

```bash
curl "https://bazaarproof.in/api/v1/products/8841/jsonld?widget=w_YOUR_WIDGET&ld_id=https%3A%2F%2Fneelloom.in%2Fp%2Findigo-saree%23product" -H "Authorization: Bearer $BAZAARPROOF_KEY"
```

- `widget`: the product widget on that page; the reviews marked up are exactly the ones it shows. Else `reviews` (0–10, default 8; 0 for a star line only) and `sort` (`recent` | `highest`).
- Response: `eligible`, `reason` (`no_reviews` | `inactive` | `imported` | `sample`), `aggregateRating`, `review`, `node` (a whole Product, with `@id` = `ld_id` when given), `script` (`node` as a ready `<script type="application/ld+json">`).
- Merge `aggregateRating` and `review` into the page's one Product node, or print `node` with the page's Product `@id`. Never a second Product, and never on a page that doesn't show the reviews.
- Never add business-level (Organization, LocalBusiness, OnlineStore) rating markup to the seller's own site: Google treats it as self-serving.
- Without a server: `data-bp-schema="product"` on a product widget adds the same markup in the browser.

### GET /proof-strip

The seller's record: five facts, already banded and worded, identical to every BazaarProof surface. Any key.

- `state: "active"`: `facts` (5 items, keys `buyers`, `described`, `repeat`, `complaints`, `since`), each `{ key, value, muted, label, detail }`; plus `updated` ("Updated 25 Nov 2026"), `summary` (one sentence), `poweredBy`, `profileUrl`, `methodUrl`, and `repeat` (the full "buyers came back" record).
- `muted: true` means below the floor (for example "Building a record"). Show the phrase as given; don't hide the fact.
- `state: "inactive"`: only `name`, `profileUrl`, `message`. Show the message instead of the strip.
- Display rules: all five facts or none, in the given order, with `updated` and a link to `profileUrl`.

### GET /reviews

Published reviews, newest first, every rating. Any key.

| Query | Default | Notes |
|---|---|---|
| `per_page` | 20 | 1 to 50 |
| `page` | 1 | Page number, for the first pages |
| `after` | | Cursor from a `next` link. Use it to page deep. |

`rating`, `min_rating`, `stars`, `sort` and `order` are refused with `400`.

```bash
curl "https://bazaarproof.in/api/v1/reviews?per_page=20" -H "Authorization: Bearer $BAZAARPROOF_KEY"
```

Response: `{ object: "list", data: Review[], page, perPage, total, pages, next, previous, allReviewsUrl }`. Follow `next` until it is null. With a site key, add `site=` to the `next` URL yourself.

Review (sample data):

```json
{
  "object": "review",
  "id": "rev_9j8d02tx5201biem",
  "url": "https://bazaarproof.in/b/neel-loom-studio/r/rev_9j8d02tx5201biem",
  "rating": 2,
  "title": null,
  "body": "Arrived a week late and the colour was lighter than the photos.",
  "language": "en",
  "productName": "Indigo saree",
  "subject": "product",
  "product": { "id": "8841", "name": "Indigo saree", "url": "https://neelloom.in/p/indigo-saree", "imageUrl": "https://neelloom.in/img/indigo-saree.webp" },
  "author": { "displayName": "Priya S.", "city": "Pune" },
  "verifiedPurchase": true,
  "proofOfPurchase": false,
  "incentivised": false,
  "incentiveNote": null,
  "source": "request",
  "importedFrom": null,
  "helpfulCount": 0,
  "publishedAt": "2026-11-22T20:02:28.498Z",
  "updatedAt": "2026-11-22T20:02:28.498Z",
  "sellerReply": { "body": "Sorry about the delay. We have refunded the shipping.", "createdAt": "2026-11-23T08:00:00.000Z" },
  "media": [{ "id": "med_…", "kind": "image", "url": "https://…", "posterUrl": null, "width": 1080, "height": 1350 }]
}
```

- `subject` is `product` or `business`. For a product review, show `product.name` with the review, and `product.imageUrl` as its thumbnail when it isn't null. `product` is null on business reviews.
- If `incentivised` is true, show `incentiveNote` with the review. If `source` is `import`, label it as imported from `importedFrom`.
- `author.displayName` is the name the reviewer chose. No email or phone, unless an Enterprise secret key adds `include=customer` (see Customers below); add `include=customer` to `GET /reviews` for a CRM sync.

### GET /reviews/{id}

One published review, the same shape. Any key. `include=customer` adds `customer` (Enterprise, secret key only).

### GET /reviews/{id}/customer

Who wrote one review: a Customer (below) plus `reviewId`. Enterprise plan, secret key.

### GET /customers/reviews

A customer's published reviews of the seller. Enterprise plan, secret key (never a site key). Email and phone never go in a URL: send sha256 hex of the normalised value.

| Query | Notes |
|---|---|
| `email_sha256` | sha256 of the email, trimmed and lowercase |
| `phone_sha256` | sha256 of the phone as E.164, `+91` and ten digits |
| `order_ref` | The seller's order reference |

Send any mix; a review matching any of them is listed. Email matches the reviewer's email, the account email or the address a review request went to; phone matches the verified account phone or the number a request went to.

```bash
curl "https://bazaarproof.in/api/v1/customers/reviews?email_sha256=$(printf '%s' 'asha@example.com' | shasum -a 256 | cut -d' ' -f1)" -H "Authorization: Bearer $BAZAARPROOF_KEY"
```

Response: `{ object: "customer_reviews", matchedOn, customer, summary: { reviewCount, averageRating, lowRatings, firstReviewAt, lastReviewAt }, data: (Review & { customer })[], truncated }`. Up to 100 reviews, newest first; `truncated` is true when there were more. Nothing matched: `customer: null`, empty `data`.

Customer: `{ object: "customer", name, displayName, email, emailConfirmed, phone, city, orderRef, requestId, requestChannel }`. Any field can be null. `phone` is only ever a number the buyer verified. Never sent: proof of purchase, "ordered before" answers, IP address, anything a moderator noted. Don't publish these details.

### POST /customers/lookup

The same answer, for a plain `email`, `phone` or `orderRef` in a JSON body. Enterprise plan, secret key. Reads only; nothing sent is stored.

### GET /orders/{ref}/reviews

Reviews tied to one order reference (URL-encoded), each with its customer. Same response as `GET /customers/reviews`. Enterprise plan, secret key.

### POST /review-requests

Queue one review request. Enterprise plan, read + write key. Body up to 8000 bytes.

| Field | Type | Required | Notes |
|---|---|---|---|
| `channel` | `email` \| `whatsapp` \| `sms` | yes | WhatsApp and SMS need the Seller plan or above |
| `contact` | string | yes | Email for email; Indian mobile for WhatsApp and SMS. Never echoed back. |
| `consent` | `true` | yes | Only when the buyer agreed to hear from the seller about this order on this channel |
| `orderRef` | string ≤120 | for WhatsApp | Also makes retries safe |
| `name` | string ≤120 | | Buyer's first name |
| `product` | string ≤200 | | Shown in the message |
| `delayDays` | integer 0–30 | | Default 0 |
| `incentive` | string ≤120 | | Reward for any honest review, disclosed on the review. No mention of stars, ratings or positive reviews. |

Unknown fields are refused. The same checks as the seller's dashboard apply: not suspended, channel on plan, WhatsApp names an order, monthly allowance left, buyer not opted out.

```bash
curl https://bazaarproof.in/api/v1/review-requests \
  -H "Authorization: Bearer $BAZAARPROOF_KEY" \
  -H "Content-Type: application/json" \
  -d '{"channel":"email","contact":"buyer@example.com","name":"Asha","orderRef":"NL-1042","delayDays":2,"consent":true}'
```

`201`: `{ "object": "review_request", "id": "req_…", "channel": "email", "status": "queued", "sendAfter": "…", "orderRef": "NL-1042", "duplicate": false }`

Same order, channel and buyer within 30 days returns `200` with the first request and `"duplicate": true`. Safe to retry.

Refusals: `400 invalid_request`, `402 plan_required`, `403 forbidden` or `suspended`, `422 opted_out`, `429 limit_reached`.

### POST /events

Order and delivery events from a store or courier tool. Enterprise plan, read + write key, **signed** with that key's signing secret (see [Signing](#signing)). Body up to 32000 bytes.

| Field | Type | Required | Notes |
|---|---|---|---|
| `id` | string ≤100 | yes | Your unique event id. A repeat returns `200` with `"duplicate": true` and does nothing. |
| `type` | `order.placed` \| `order.shipped` \| `order.delivered` \| `order.cancelled` | yes | |
| `order.ref` | string ≤120 | yes | |
| `order.product` | string ≤200 | | |
| `buyer` | `{ name?, email?, phone? }` | | |
| `consent` | `{ email?, whatsapp?, sms?: boolean }` | | No `true` value means nothing is queued |
| `channel` | `email` \| `whatsapp` \| `sms` | | Force a channel |
| `delayDays` | integer 0–30 | | Default by type: `order.placed` 7 days, `order.shipped` 5 days, `order.delivered` 2 days |
| `occurredAt` | ISO 8601 with offset | | |
| `incentive` | string ≤120 | | Same rule as review requests |
| `promos` | up to 5 of `{ headline ≤80, image, description ≤400, terms ≤600 }` | | Loyalty offers the buyer gets for writing a review, whatever the rating. Shown in the review request email. `image`: https, square, at least 500 x 500; we keep a 500 x 500 copy, and an image we can't copy is left out. No wording about stars, ratings or positive reviews (`400`). They are the request's reward: a review written through it is labelled with the first headline. |

How it decides:

1. `order.cancelled` cancels requests for that order that haven't gone out yet.
2. Otherwise the channel is `channel` if given, else the first of email, WhatsApp, SMS with `consent` true and a contact.
3. A request is queued only with that consent, and at most one per order, channel and buyer.

`202` (or `200` for a repeated `id`):

```json
{ "object": "order_event", "id": "oev_…", "eventId": "shop-77812-delivered", "duplicate": false, "outcome": "queued", "requestId": "req_…", "channel": "email", "sendAfter": "…", "message": "Review request queued." }
```

| outcome | Meaning |
|---|---|
| `queued` | Review request queued. |
| `no_consent` | Recorded. No request queued: the event did not say the buyer agreed to hear from you on any channel. |
| `no_contact` | Recorded. No request queued: no email or phone for the channel the buyer agreed to. |
| `invalid_contact` | Recorded. No request queued: the buyer's contact is not valid. |
| `opted_out` | Recorded. No request queued: this buyer asked not to get review requests on this channel. |
| `duplicate_order` | Recorded. A request for this order already exists. |
| `limit_reached` | Recorded. No request queued: this month's request limit is used up. |
| `channel_needs_plan` | Recorded. No request queued: this channel needs the Seller plan. |
| `cancelled_requests` | Queued requests for this order were cancelled. |
| `nothing_to_cancel` | Recorded. No queued request for this order. |

The event's outcome and order reference are kept; the buyer's contact is not (a queued request holds it, as a dashboard request does).

### GET /promotions

The seller's promotions on their profile now, in their order. Any key. A secret key with `all=1` also gets scheduled and ended ones. Shown only while the seller is on Enterprise.

Response: `{ object: "list", data: Promotion[] }`. Promotion: `{ object: "promotion", id, headline, description, terms, image, imageUrl, startsAt, endsAt, updatedAt }`; `image` is the address you sent, `imageUrl` our 500 x 500 copy.

### POST /promotions

Replace the promotions feed: general offers shown on the seller's profile, after the reviews, labelled as the seller's own. Enterprise plan, read + write key. Body up to 64000 bytes.

| Field | Type | Required | Notes |
|---|---|---|---|
| `promotions` | array, up to 10 | yes | The whole feed, in display order. Ones you leave out are removed; `[]` clears it. |
| `promotions[].id` | string ≤100 | yes | Your id. Same id again updates it. |
| `promotions[].headline` | string ≤80 | yes | |
| `promotions[].image` | https URL | yes | Square, at least 500 x 500. Fetched now and kept as a 500 x 500 copy; one that fails refuses the whole update with `400` naming it. |
| `promotions[].description` | string ≤400 | yes | |
| `promotions[].terms` | string ≤600 | yes | |
| `promotions[].startsAt`, `endsAt` | ISO 8601 with offset | | Shown only between them |

No wording about stars, ratings or positive reviews. Responds `200` with the stored feed, the same shape as `GET /promotions?all=1`.

### POST /reviews

The Lighter integration: one review the seller's own website collected. Enterprise plan, read + write key, **signed** like `POST /events` (see [Signing](#signing)). Body up to 16000 bytes. It publishes at once, counts in the seller's rating, and is shown as imported from the seller's website, never as a verified purchase.

| Field | Type | Required | Notes |
|---|---|---|---|
| `id` | string ≤100 | yes | Your website's own id for the review. A repeat returns `200` with `"duplicate": true` and changes nothing. |
| `rating` | integer 1–5 | yes | Send every rating. |
| `body` | string ≤4000 | yes | Exactly as the buyer wrote it. |
| `title` | string ≤100 | | |
| `author.name` | string ≤60 | yes | The name the buyer chose to show. A full name is shortened to first name and initial. Never put an email or phone here. |
| `author.email` | string ≤254 | | Optional. The buyer's email: private, never shown or echoed back, and never written to. Links the review to the buyer's other reviews; imported reviews never count toward their public totals or badges. A malformed address is refused. |
| `author.city` | string ≤40 | | |
| `product` | object | | Send it for a **product review**; leave it out for a **business review** (the shop as a whole). |
| `product.id` | string ≤128 | with `product` | Your store's product id, the same one as `data-bp-product` |
| `product.name` | string ≤200 | with `product` | Shown with the review |
| `product.image` | https URL ≤500 | with `product` | The product photo. We keep a 320 px copy as the thumbnail. |
| `product.url` | URL ≤500 | | The product page |
| `product.gtin` | digits | | Optional barcode number: GTIN-8, UPC-A (12), EAN-13 or GTIN-14. Kept for BazaarProof's own use, never shown or returned. A wrong check digit is ignored, never refused. |
| `createdAt` | ISO 8601 with offset | | When the buyer wrote it. Default now; a future time is refused. |

Unknown fields are refused. There is no edit or delete: a review, once sent, stays as sent. A `product` adds that product to the seller's product list, or updates its name, page and photo there.

```bash
BODY='{"id":"rev-1042","rating":2,"body":"Arrived a week late and the colour was lighter than the photos.","author":{"name":"Priya Sharma","city":"Pune"},"product":{"id":"8841","name":"Indigo saree","image":"https://neelloom.in/img/indigo.jpg","url":"https://neelloom.in/p/indigo-saree","gtin":"8901030865275"}}'
T=$(date +%s)
SIG=$(printf '%s.%s' "$T" "$BODY" | openssl dgst -sha256 -hmac "$BAZAARPROOF_SIGNING_SECRET" -hex | sed 's/^.* //')
curl https://bazaarproof.in/api/v1/reviews \
  -H "Authorization: Bearer $BAZAARPROOF_KEY" \
  -H "Content-Type: application/json" \
  -H "BazaarProof-Signature: t=$T,v1=$SIG" \
  -d "$BODY"
```

`201` (or `200` for a repeated `id`):

```json
{ "object": "site_review", "id": "rev_site_…", "reviewId": "rev-1042", "duplicate": false, "subject": "product", "url": "https://bazaarproof.in/b/neel-loom-studio/r/rev_site_…", "importedFrom": "neelloom.in", "verifiedPurchase": false }
```

Refusals: `400 invalid_request`, `401 invalid_signature`, `402 plan_required`, `403 forbidden` or `suspended`.

## Signing

Order events and reviews you send and webhooks we send use the same scheme.

- Header `BazaarProof-Signature: t={unix seconds},v1={hex}`
- `v1` = HMAC-SHA256(secret, `"{t}.{raw body}"`), lowercase hex
- Sign and verify the **exact bytes** on the wire. Don't re-serialise the JSON.
- Reject `t` more than 300 seconds from now (replays). Compare in constant time. Several `v1` values may appear; any match is enough.

```js
import { createHmac } from "node:crypto";

const body = JSON.stringify(event);
const t = Math.floor(Date.now() / 1000);
const v1 = createHmac("sha256", process.env.BAZAARPROOF_SIGNING_SECRET).update(`${t}.${body}`).digest("hex");

const res = await fetch("https://bazaarproof.in/api/v1/events", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BAZAARPROOF_KEY}`,
    "Content-Type": "application/json",
    "BazaarProof-Signature": `t=${t},v1=${v1}`,
  },
  body,
});
```

```js
import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody: the request body as received (string or Buffer), before JSON.parse.
export function verifyBazaarProof(rawBody, header, secret) {
  const parts = Object.fromEntries((header ?? "").split(",").map((p) => p.trim().split("=")));
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
  const given = Buffer.from(parts.v1 ?? "", "hex");
  return given.length === expected.length && timingSafeEqual(given, expected);
}
```

```php
$raw = file_get_contents('php://input');
$header = $_SERVER['HTTP_BAZAARPROOF_SIGNATURE'] ?? '';
parse_str(str_replace(',', '&', $header), $p);
$ok = isset($p['t'], $p['v1'])
  && abs(time() - (int) $p['t']) <= 300
  && hash_equals(hash_hmac('sha256', $p['t'] . '.' . $raw, $secret), $p['v1']);
```

```python
import hmac, hashlib, time

def verify_bazaarproof(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(p.strip().split("=", 1) for p in header.split(",") if "=" in p)
    t = int(parts.get("t", "0"))
    if not t or abs(time.time() - t) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))
```

## Webhooks

Enterprise plan. The seller adds endpoints in the dashboard (public `https` only) and picks events; each endpoint has its own `whsec_…` secret, shown once.

| Event | When |
|---|---|
| `review.created` | A buyer published a new review on your page. Carries the review and who wrote it. |
| `complaint.created` | A buyer raised a complaint. Details stay in your dashboard. |
| `complaint.due` | 6 hours before the 48-hour reply clock runs out, and 2 days before the 30-day resolve clock. |
| `ping` | The seller pressed "Send test event". |

Each delivery is a `POST` with:

- Headers: `BazaarProof-Signature`, `BazaarProof-Event` (type), `BazaarProof-Event-Id` (same on every retry and endpoint: de-duplicate on it), `BazaarProof-Delivery`.
- Body: `{ id, type, apiVersion, createdAt, business: { id, slug }, data }`. `data.review` is a Review (above); `review.created` adds `data.customer`, a Customer (above) or null. `data.complaint` is `{ object, id, ticket, kind, kindLabel, status, orderRef, createdAt, acknowledgedAt, ackDueAt, resolveDueAt, dashboardUrl }`; `complaint.due` adds `data.clock` (`acknowledge` | `resolve`) and `data.dueAt`. Complaint events never include the buyer's words or contact.
- `complaint.due` fires 6 hours before the 48-hour reply clock and 2 days before the 30-day resolve clock, unless the seller already replied or closed it.

Reply with any 2xx within 10 seconds, then do the work. Anything else (including redirects and timeouts) is retried with growing gaps, 8 tries over about two hours.

## What the API never does

- Delete, hide, edit or reorder a review or complaint (`PUT`, `PATCH`, `DELETE` return `405`).
- Filter reviews by rating.
- Return a buyer's email or phone to a site key or below the Enterprise plan, or complaint text to anyone.
- Show a phone number for an unclaimed seller, or a UPI ID the seller didn't declare.
- Change any number because a seller pays.
