RevenueCat webhook HMAC (onset-web prod)¶
Cloudflare Pages prod already has REVENUECAT_WEBHOOK_AUTHORIZATION. HMAC is optional defense-in-depth.
Enable in RevenueCat (required once)¶
The signing secret must originate from RevenueCat, not the other way around. RC shows it only at creation/rotation.
- RevenueCat dashboard → your Onset project
- Integrations → Webhooks → open the existing webhook (URL:
https://theonset.app/api/webhooks/revenuecator your prod endpoint) - Toggle HMAC webhook signing on
- Copy the signing secret immediately (shown once)
- Update secrets to match:
- BWS Onset project:
REVENUECAT_WEBHOOK_SIGNING_SECRET - Cloudflare Pages
onset-webprod:REVENUECAT_WEBHOOK_SIGNING_SECRET - Send a test webhook from the RC integration page; confirm Cloudflare logs show 200 (not 401)
Verification¶
Handler: functions/api/webhooks/revenuecat.js
Verifier: functions/_utils/revenuecat-webhook.js (header X-RevenueCat-Webhook-Signature, format t=<unix>,v1=<hmac>)
If HMAC is enabled in RC but the secret is missing/wrong in Cloudflare, webhooks still pass when REVENUECAT_WEBHOOK_AUTHORIZATION matches. HMAC is only enforced when REVENUECAT_WEBHOOK_SIGNING_SECRET is set.
Note on prior setup¶
A placeholder secret may exist in BWS/Cloudflare from an earlier ops pass. Rotate in RevenueCat and replace BWS + Cloudflare with RC's generated secret so signatures verify.