How do I keep my pages current with webhooks?
Updated · Integrations
A webhook tells your server when your reviews or settings change, so it can refresh its pages. It makes updates faster. Your pages still work without one.
Add an endpoint
- On the Integrations page, open the Next.js or React tab.
- Under Webhooks, enter your Endpoint URL and tick the events you want.
- Select Save endpoint.
We send a test event first, and save the endpoint only when it answers with a 2xx status. The address must use https, and it can't point at a private, loopback, or link-local address.
Your signing secret shows once, in Copy your signing secret. It starts with whsec_. Keep it on your server, for example as PEPREVIEWPRO_WEBHOOK_SECRET, which the SDK reads.
The events
- Review published (
review.published): a review went live. - Review updated (
review.updated): a published review changed. - Review deleted (
review.deleted): a review was deleted or left public view. - Store updated (
store.updated): your branding or widget settings changed. - Rating changed (
aggregate.changed): your rating or review count changed.
On Next.js, @pepreviewpro/next has the route ready. Add app/api/pepreviewpro/route.ts with export { POST } from "@pepreviewpro/next/webhooks"; and save https://your-store.example/api/pepreviewpro as the endpoint. It checks the signature and refreshes the reviews it cached.
To check your route before you save it, run npx pepreviewpro webhooks test <url> --secret whsec_…. It sends a signed test event and says whether your route answered with a 2xx.
Each body is { type, timestamp, data }, and data always carries your store's store_id, so one handler can serve several stores.
Check the signature
Deliveries follow the Standard Webhooks spec, with webhook-id, webhook-timestamp, and webhook-signature headers. Any Standard Webhooks library can check them. With the SDK:
const event = await prp.webhooks.verify(await request.text(), request.headers);
Pass the raw body, not parsed JSON. A bad signature throws, and so does a timestamp more than 5 minutes off.
Treat an event as a nudge
Deliveries can repeat and arrive out of order. Drop repeats by webhook-id. Use an event as a reason to fetch your reviews again, not as the data to keep. If you copy reviews into your own database, each review carries updated_at, so the newest copy wins.
Timing and failures
We send deliveries every 2 minutes, so your pages update within a minute or two of a change. The first visit after it may still see the old page, and the next visit gets the new one. Your server has 15 seconds to answer with a 2xx status. A delivery that fails is tried again, with longer gaps each time, for 24 hours.
After 3 days of failures, we turn the endpoint off and email you. Fix your server, then select Turn back on. The card shows Last delivery and Last status so you can check. Remove endpoint deletes it.
Was this helpful?