# RevenueCat subscription canceled notifications on your phone > Get a push notification when a customer turns off auto-renew, with the reason and when their access ends. - Company: RevenueCat (https://www.justpush.io/recipes/revenuecat) - Event: `CANCELLATION` (CANCELLATION) - Tags: Finance, Subscriptions - Install: https://studio.justpush.io/recipes/revenuecat/cancellation - Web page: https://www.justpush.io/recipes/revenuecat/cancellation ## Setup 1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL. 2. In the RevenueCat dashboard, open your project's Integrations > Webhooks and add a new webhook. 3. Paste your webhook URL (shown in Studio after install) as the webhook URL. 4. Send all events, or only CANCELLATION; the recipe ignores every other event type. 5. Save, then click Send test event to confirm it arrives. ## Code Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing. ```js // RevenueCat → CANCELLATION // Fires when a customer turns off auto-renew (refunds are left to the refund recipe). // Docs: https://www.revenuecat.com/docs/integrations/webhooks/event-types-and-fields // // Paste this into a JustPush Studio integration and add a RevenueCat webhook pointing // at the integration's endpoint URL. // Human-readable store names. const STORES = { APP_STORE: "App Store", MAC_APP_STORE: "Mac App Store", PLAY_STORE: "Google Play", AMAZON: "Amazon", STRIPE: "Stripe", PADDLE: "Paddle", RC_BILLING: "Web Billing", ROKU: "Roku", PROMOTIONAL: "a promotional grant", TEST_STORE: "Test Store", } // RevenueCat prices are decimals ("9.99"), not cents. Returns null when there's no price. function money(amount, currency) { const value = Number(amount) if (amount == null || !Number.isFinite(value) || !currency) return null try { return new Intl.NumberFormat("en-GB", { style: "currency", currency }).format(value) } catch { return `${value} ${currency}` } } // Turn "NL" into 🇳🇱. function flag(countryCode) { return /^[A-Z]{2}$/.test(countryCode ?? "") ? String.fromCodePoint(...[...countryCode].map((c) => 127397 + c.charCodeAt(0))) : "" } // "pro_monthly on App Store from jane@example.com 🇳🇱 (sandbox)" function where(event) { const attributes = event.subscriber_attributes ?? {} const who = attributes.$email?.value ?? attributes.$displayName?.value const store = STORES[event.store] ?? event.store return ( (event.product_id ?? "a product") + (store ? ` on ${store}` : "") + (who ? ` from ${who}` : "") + (flag(event.country_code) ? ` ${flag(event.country_code)}` : "") + (event.environment === "SANDBOX" ? " (sandbox)" : "") ) } // RevenueCat timestamps are milliseconds since epoch. function day(ms) { return new Date(ms).toLocaleDateString("en-GB", { day: "numeric", month: "short", timeZone: "UTC" }) } // Why a subscription ended, in words. const REASONS = { UNSUBSCRIBE: "turned off auto-renew", BILLING_ERROR: "payment failed", DEVELOPER_INITIATED: "canceled by you", PRICE_INCREASE: "didn't accept a price increase", CUSTOMER_SUPPORT: "refunded", SUBSCRIPTION_PAUSED: "paused", } function handleRequest(request) { const event = (request.body || {}).event // "Send test event" in RevenueCat; confirm the connection with a quiet push. if (event?.type === "TEST") { return { title: "🔔 RevenueCat connected", message: "Test event received", topic: "RevenueCat", priority: -1 } } // Guard: only handle this event type, so other RevenueCat events on this integration stay quiet. if (event?.type !== "CANCELLATION") { console.log(`Ignoring RevenueCat event "${event?.type ?? "unknown"}"`) return null } // Refunds also arrive as CANCELLATION; the refund recipe handles those. if (event.cancel_reason === "CUSTOMER_SUPPORT") { console.log("Skipping refund — handled by the refund recipe") return null } const reason = REASONS[event.cancel_reason] const until = event.expiration_at_ms ? `. Access until ${day(event.expiration_at_ms)}.` : "" return { title: "👋 Subscription canceled", message: where(event) + (reason ? ` — ${reason}` : "") + until, topic: "RevenueCat", priority: 0, // Normal — worth knowing; they keep access until the period ends } } ``` ## RevenueCat CANCELLATION webhook payload (sample) ```json { "event": { "id": "CD489E0E-CANCELLA", "type": "CANCELLATION", "price": 0, "store": "APP_STORE", "app_id": "app1a2b3c4d5", "aliases": [ "user_8Hq2" ], "currency": "EUR", "product_id": "pro_monthly", "app_user_id": "user_8Hq2", "environment": "PRODUCTION", "period_type": "NORMAL", "country_code": "NL", "cancel_reason": "UNSUBSCRIBE", "transaction_id": "2000000712345678", "entitlement_ids": [ "pro" ], "purchased_at_ms": 1790584200000, "expiration_at_ms": 1791793800000, "event_timestamp_ms": 1790584200000, "subscriber_attributes": { "$email": { "value": "jane@example.com", "updated_at_ms": 1790584100000 } }, "original_transaction_id": "2000000612345678", "price_in_purchased_currency": 0 }, "api_version": "1.0" } ``` ## FAQ ### Does this work on iPhone and Android? Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification. ### Do I need to write code? No. Install the recipe in Studio, paste your webhook URL into RevenueCat and you are done. The code is there if you want to change the text, the sound or the buttons. ### Can I change what the notification says? Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save. ### What does it cost? JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.