revenuecat/ai-toolkit/rc-webhooks

Claude Code and agent skill by revenuecat/ai-toolkit

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Use this skill when consuming RevenueCat webhooks on your backend. Covers authenticating requests (Authorization header, optional HMAC signing), parsing the normalized event schema without breaking on new fields, idempotency via the event id field, every event type, and taking access from a re-read of the customer so CANCELLATION, EXPIRATION, and RENEWAL never grant or revoke the wrong access.

Install

npx vskill@latest install revenuecat/ai-toolkit/rc-webhooks

SKILL.md

The same SKILL.md was published earlier as revenuecat/ai-toolkit/rc-webhooks.

RevenueCat Webhooks

You configure one endpoint. RevenueCat posts one normalized JSON event schema for every store. Your job on the server side is to authenticate the request, deduplicate by event.id, and update your records from the customer the event touches.

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 set an authorization header value on the webhook integration in the RevenueCat dashboard under Integrations then Webhooks. If you also turn on HMAC webhook signing there, you stored its signing secret, which the dashboard shows only once.
  • Google Play Real Time Developer Notifications are connected to RevenueCat. Without them RevenueCat may learn about a refund of a one time purchase only when the app next opens.
  • You have durable storage to record processed event IDs and entitlement state per user.
  • You have the secret REST API key on the server, to re-read customers with GET /v1/subscribers/{app_user_id}.
  • You understand that RevenueCat has already mapped products to entitlements, so the customer it returns lists every entitlement with its expires_date, expired ones included. You do not maintain a product to entitlement table on your backend.

Every event has this outer shape:

json
{
"api_version": "1.0",
"event": {
"id": "evt_01HABCXYZ0000000000000001",
"type": "INITIAL_PURCHASE",
"app_user_id": "user_12345",
"original_app_user_id": "$RCAnonymousID:8b1d0e5c4f2a4d3e9c6b7a5f4e3d2c1b",
"aliases": ["$RCAnonymousID:8b1d0e5c4f2a4d3e9c6b7a5f4e3d2c1b", "user_12345"],
"product_id": "premium_monthly",
"period_type": "NORMAL",
"purchased_at_ms": 1700000000000,
"expiration_at_ms": 1702592000000,
"store": "PLAY_STORE",
"environment": "PRODUCTION",
"entitlement_ids": ["pro_access"],
"transaction_id": "GPA.1234-5678-9012-34567"
}
}

Phase 2: Plan

Take access from the customer, not from the event. For every event that can change access, re-read the customer it touches with GET /v1/subscribers/{app_user_id} and store the entitlements RevenueCat reports now. RevenueCat recommends this after any webhook, and it stays correct when events arrive late or out of order: automatic retries follow after 5, 10, 20, 40, and 80 minutes and a dashboard retry can come any time, so a retried EXPIRATION can land after the event that restored access, and another source (a granted entitlement, another store) can still grant an entitlement that one product's EXPIRATION lists. Use the payload only for what the customer does not carry, such as consumable credits.

Event typeMeaningHandler action besides the re-read
INITIAL_PURCHASEA new subscription was purchased, including the start of a free trial (period_type TRIAL). On Google Play it is also the usual event for a resubscription after an EXPIRATION.Nothing.
RENEWALSubscription renewed. Some resubscriptions after an EXPIRATION arrive as RENEWAL too.Nothing.
NON_RENEWING_PURCHASEA purchase that won't auto renew: a one time product, or an entitlement granted from the dashboard or API (store PROMOTIONAL).Credit consumables to the user, quantity units when present, keyed by transaction_id, except products whose balance RevenueCat in app currency manages.
CANCELLATIONAuto renew turned off, a billing issue was detected, a refund, or a granted entitlement was removed. cancel_reason says which.Do not revoke from the payload. Reverse any consumable credit recorded for the transaction_id.
UNCANCELLATIONUser re enabled auto renew before expiry.Nothing.
EXPIRATIONA subscription or a granted entitlement ended.Nothing. The re-read normally shows the entitlement expired; trust it over entitlement_ids.
BILLING_ISSUEPayment failed. User may be in grace period or on hold.Optionally start recovery messaging, such as an email; the re-read stores billing_issues_detected_at. Do not revoke. RevenueCat sends EXPIRATION if recovery fails.
SUBSCRIPTION_EXTENDEDExpiry pushed back through the store API (for example a defer). On Google Play it can also mean Google deferred a renewal charge by less than 24 hours, and RENEWAL or BILLING_ISSUE follows within a day.Nothing.
SUBSCRIPTION_PAUSEDGoogle Play subscription scheduled to pause. auto_resume_at_ms says when it resumes.Nothing. Access ends later with EXPIRATION (expiration_reason SUBSCRIPTION_PAUSED).
TEMPORARY_ENTITLEMENT_GRANTShort lived outage grant (up to 24h). Carries only app_user_id and sometimes store.Nothing; the payload has no entitlement or expiry fields. INITIAL_PURCHASE follows if the store later validates the purchase, EXPIRATION if it does not.
PRODUCT_CHANGEUser switched plan (upgrade, downgrade, or cross grade).Nothing. On Google Play, new_product_id marks a deferred change: product_id is still the current product, and the new one takes effect at the next renewal, when the re-read shows it (RevenueCat's docs name both INITIAL_PURCHASE and RENEWAL for that moment).
TRANSFERPurchases moved from the IDs in transferred_from to the IDs in transferred_to. No app_user_id on this event.Re-read every ID on both sides. Do not merge the users.
PURCHASE_REDEEMEDA web purchase (Paddle, RevenueCat Billing, or Stripe) was redeemed in the app through a redemption link. No app_user_id. redemption_outcome is alias, transfer (a TRANSFER is sent too), or redeemer_owns.Re-read the redeemer in redeemed_by, which RevenueCat sends only sometimes.
REFUND_REVERSEDApp Store only. A refund was reversed.Restore any consumable credit you reversed for the transaction_id.
SUBSCRIBER_ALIASDeprecated. Two app user IDs were merged into one identity.Legacy projects only: merge your local records for the IDs in aliases. New projects don't receive this event.
PRICE_INCREASE_CONSENT_REQUIRED, PRICE_INCREASE_CONSENT_APPROVEDA price increase needs, or got, the customer's consent before the subscription renews at the new price.No access change; skip the re-read.
VIRTUAL_CURRENCY_TRANSACTIONAn in app currency balance changed. source says why (a purchase, an API call, the SDK, an expiration, or an ad reward).No access change; skip the re-read. If you mirror balances, update them here, and only here, for products RevenueCat in app currency manages.
INVOICE_ISSUANCERevenueCat Billing only. An unpaid invoice was issued.No access change; skip the re-read.
EXPERIMENT_ENROLLMENTThe customer was enrolled in an experiment.No access change; skip the re-read.
TESTA test event sent from the dashboard, carrying a sample purchase payload.Return 200 and change nothing; skip the re-read.

Key decisions baked into this table:

  • CANCELLATION is not an access change on its own. After UNSUBSCRIBE or PRICE_INCREASE the user keeps access until expiration_at_ms; revoking now deletes paid access the user still owns. After CUSTOMER_SUPPORT (a refund) access usually ends now, but a refund does not always cancel the subscription and auto renew can stay on. DEVELOPER_INITIATED is a developer cancel through the store, which normally keeps access until expiry, or a removed granted entitlement, which ends access at once. The re-read settles each case.
  • EXPIRATION usually means access ended, but apply it through the re-read: a retried EXPIRATION can arrive after a resubscription, and a granted entitlement or another store can still grant the same entitlement.
  • A resubscription after an EXPIRATION can arrive as INITIAL_PURCHASE (usual on Google Play) or RENEWAL. A handler that only extends existing access on RENEWAL leaves the resubscribed user locked out; the re-read grants access on either.
  • BILLING_ISSUE is not revocation. Revoking on BILLING_ISSUE, or on the CANCELLATION with cancel_reason BILLING_ERROR that fires alongside it, cuts off users who are still inside a Google Play grace period. Users in account hold already lost access through the EXPIRATION that RevenueCat sends when grace ends.
  • A purchase made before login arrives under an anonymous app_user_id that matches none of your users, and the logIn merge that follows sends no webhook (SUBSCRIBER_ALIAS is not sent to new projects). Re-read the customer once the app's Purchases.logIn call has returned, for example from an endpoint the app calls right after it; a re-read inside your own login endpoint runs before that merge. That endpoint re-reads only the signed in user's own ID, never an ID from the request, and is throttled per user like the serve time re-read.

Phase 3: Execute

Wire up a handler that authenticates, deduplicates, and dispatches.

Authenticate and parse

RevenueCat sends the authorization header value you set on the webhook integration with every request. Check it on every request. HMAC signing is optional and adds a second check: when it is on, each delivery also carries X-RevenueCat-Webhook-Signature: t=<unix_timestamp>,v1=<hmac_sha256_hex>, an HMAC-SHA256 of "<t>.<raw body>" keyed with the integration's signing secret. RevenueCat recomputes t and v1 on every delivery attempt, retries included.

Call revenueCatWebhook() from your Ktor module at startup.

kotlin
fun Application.revenueCatWebhook() {
// Read at install time, so a missing or blank value fails the deploy instead of every request.
// A blank value would also match an empty Authorization header.
val expectedAuthorization: String = System.getenv("RC_WEBHOOK_AUTHORIZATION")?.takeIf { it.isNotBlank() }
?: error("Set RC_WEBHOOK_AUTHORIZATION to the authorization header value from the RevenueCat dashboard")
// Set only when HMAC signing is on for this integration. Once set, a request without a valid signature gets 401.
val signingSecret: String? = System.getenv("RC_WEBHOOK_SIGNING_SECRET")?.takeIf { it.isNotBlank() }
log.info("RevenueCat webhook checks: Authorization on, HMAC ${if (signingSecret != null) "on" else "off"}")
routing {
post("/revenuecat/webhook") {
if (!constantTimeEquals(call.request.headers[HttpHeaders.Authorization], expectedAuthorization)) {
call.respond(HttpStatusCode.Unauthorized); return@post
}
// Keep the raw bytes: the HMAC covers them exactly as received, so parse JSON only after verifying.
val body = call.receive<ByteArray>()
if (signingSecret != null &&
!verifyHmac(body, call.request.headers["X-RevenueCat-Webhook-Signature"], signingSecret)
) {
call.respond(HttpStatusCode.Unauthorized); return@post
}
val event = webhookJson.decodeFromString<RevenueCatEnvelope>(body.decodeToString()).event
handleEvent(event)
call.respond(HttpStatusCode.OK)
}
}
}
fun constantTimeEquals(actual: String?, expected: String): Boolean =
actual != null && MessageDigest.isEqual(actual.toByteArray(), expected.toByteArray())

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
73
Repository forks
9
7-day trend score
27

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/revenuecat/ai-toolkit/rc-webhooks/badge)](https://verified-skill.com/skills/revenuecat/ai-toolkit/rc-webhooks)

Something wrong with this skill or its page? Tell us.