RevenueCat Webhooks
You configure one endpoint. RevenueCat posts one normalized JSON event schema for every store. Your job on the server side is to verify the signature, deduplicate by event.id, and dispatch per event type.
Phase 1: Discover
Confirm what you are wiring up before touching code.
- You own a server side HTTPS endpoint that accepts POST with a JSON body.
- You have the webhook secret from the RevenueCat dashboard under Integrations then Webhooks.
- You have durable storage to record processed event IDs and entitlement state per
app_user_id. - You understand that RevenueCat has already mapped products to entitlements, so you branch on
event.typeand readevent.entitlement_ids. You do not maintain a product to entitlement table on your backend.
Every event has this outer shape:
Phase 2: Plan
Pick the right action for each event type before you write the handler.
Key decisions baked into this table:
CANCELLATIONis not an access change. It is an intent signal. Revoking now is a bug that deletes paid access the user still owns.EXPIRATIONis the access change. This is when you revoke.- Resubscription after an
EXPIRATIONfiresRENEWAL, notINITIAL_PURCHASE. YourRENEWALbranch must be safe to run against a user whose entitlements are currently revoked, which means it must grant, not just extend. BILLING_ISSUEis not revocation. Revoking onBILLING_ISSUEcuts off users who are still inside Google Play grace period or account hold.
Phase 3: Execute
Wire up a handler that verifies, deduplicates, and dispatches.
Verify the signature and parse
Return 2xx as soon as the event is persisted. If processing is slow, enqueue it and acknowledge. A slow handler causes retries and duplicate deliveries.
Deduplicate on event.id
RevenueCat can redeliver the same event. event.id is the idempotency key.
insertIfAbsent must be atomic in your store (a unique index on event_id plus an insert that swallows duplicate key errors works). Do all downstream writes in the same transaction as the event ID insert so a crash mid handler does not leave you with a marked but unapplied event.
Dispatch per type
Notes that match the handbook:
grantEntitlementsonRENEWALmust be idempotent and additive so a resubscribe afterEXPIRATIONrestores access.scheduleRevocationstores a pending job keyed by(app_user_id, entitlement_id)that fires atexpiration_at_ms. If anUNCANCELLATIONarrives first, cancel the job. If anEXPIRATIONarrives first, let theEXPIRATIONhandler revoke and drop the pending job.
CANCELLATION payload (access continues)
The user keeps pro_access until 1702592000000. Schedule revocation for that timestamp.
EXPIRATION payload (revoke now)
Revoke pro_access for user_12345 as soon as you process this.
RENEWAL after expiry (resubscription)
When a lapsed user resubscribes, RevenueCat sends RENEWAL, not INITIAL_PURCHASE.
Your RENEWAL branch must grant entitlements, not assume they already exist. If you only extend an existing expiry, the resubscribed user stays locked out.
Verification Checklist
- Signature verification rejects requests with missing or wrong
X-RevenueCat-Signature. - A replayed event with the same
event.idis a no op and still returns 200. CANCELLATIONdoes not revoke access. The user retains entitlements untilexpiration_at_ms.EXPIRATIONrevokes access for the IDs inentitlement_ids.- A
RENEWALarriving after anEXPIRATIONrestores access for the sameapp_user_id. BILLING_ISSUEflags the account without revoking.- Handler returns 2xx within your retry window even when downstream work is async.


