Polar subscription canceled notifications on your phone.

Get a push notification when a Polar subscription is canceled, with the customer's reason and the date their access ends.

subscription.canceledPayments & billingSubscriptions
How it works

Three steps to your first push

STEP 01

Install the recipe

One click in Studio gives you a personal webhook URL.

STEP 02

Paste your URL into Polar

Add it as a webhook for subscription.canceled.

STEP 03

Get a push on your phone

With the text, sound and buttons from the recipe.

Setup

How to set up the Polar subscription.canceled webhook

  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 Polar dashboard, open Settings > Webhooks and click Add Endpoint.
  3. Paste your webhook URL as the URL and leave the format on Raw.https://••••••••/•••••••• your personal URL, shown after install
  4. Generate a secret (JustPush doesn't need it), tick the subscription.canceled event and save.
  5. Tick **subscription.canceled**. By default Polar cancels at the end of the billing period: this event fires straight away while the customer still has access, and the push says until when. When access actually ends, Polar sends `subscription.revoked` (see the *Subscription ended* recipe).
  6. If you cancel a subscription with **immediate revocation**, Polar sends `subscription.canceled` and `subscription.revoked` together, so with both recipes installed you'll get two pushes for it.
  7. Don't tick `subscription.updated`: it repeats every cancellation as well.
  8. Testing in the **sandbox**? Add `?sandbox=1` to the URL so the button opens the sandbox dashboard.
  9. Polar signs every delivery (`webhook-id`, `webhook-timestamp`, `webhook-signature`; Standard Webhooks for secrets made on or after 8 September 2026), but JustPush doesn't check that signature yet, so keep your endpoint URL private.
The code

What runs when the webhook arrives

Studio calls handleRequest(request) with the incoming webhook and sends the message it returns. It's yours after install; change anything.

transform.js
1// Polar → subscription.canceled
2// Fires when a subscription is canceled, by the customer or by you. With the default
3// end-of-period cancellation the customer keeps access until the period ends
4// (status "active", cancel_at_period_end true); subscription.revoked follows at the real end.
5// Docs: https://polar.sh/docs/api-reference/current/subscription_canceled
6
7// The customer's cancellation reason, in words.
8const REASONS = {
9 customer_service: "customer service",
10 low_quality: "quality",
11 missing_features: "missing features",
12 switched_service: "switched to another service",
13 too_complex: "too complex",
14 too_expensive: "too expensive",
15 unused: "not using it",
16 other: "other",
17}
18
19// Polar amounts are in the currency's smallest unit (cents), except zero-decimal currencies.
20const ZERO_DECIMAL = new Set([
21 "bif", "clp", "djf", "gnf", "jpy", "kmf", "krw", "mga",
22 "pyg", "rwf", "ugx", "vnd", "vuv", "xaf", "xof", "xpf",
23])
24
25function money(amount, currency) {
26 if (typeof amount !== "number" || !Number.isFinite(amount) || typeof currency !== "string" || !currency) return null
27
28 const code = currency.toLowerCase()
29 const value = ZERO_DECIMAL.has(code) ? amount : amount / 100
30
31 try {
32 return new Intl.NumberFormat("en-GB", { style: "currency", currency: code.toUpperCase() }).format(value)
33 } catch {
34 return `${value} ${code.toUpperCase()}`
35 }
36}
37
38// "€19.00/month", or "€49.00 every 3 months".
39const INTERVALS = { day: "day", week: "week", month: "month", year: "year" }
40
41function price(sub) {
42 const amount = money(sub.amount, sub.currency)
43 const unit = pick(INTERVALS, sub.recurring_interval, null)
44
45 if (!amount) return null
46 if (!unit) return amount
47
48 const count = Number.isInteger(sub.recurring_interval_count) ? sub.recurring_interval_count : 1
49 return count > 1 ? `${amount} every ${count} ${unit}s` : `${amount}/${unit}`
50}
51
52// "29 Oct 2026" from an ISO timestamp, or null.
53function day(value) {
54 const date = typeof value === "string" ? new Date(value) : null
55 return date && !Number.isNaN(date.getTime())
56 ? date.toLocaleDateString("en-GB", { day: "numeric", month: "short", year: "numeric", timeZone: "UTC" })
57 : null
58}
59
60// Table lookup that ignores inherited names such as "toString".
61function pick(table, key, fallback) {
62 return typeof key === "string" && Object.prototype.hasOwnProperty.call(table, key) ? table[key] : fallback
63}
64
65// Only link to real http(s) URLs.
66function link(url, cta) {
67 return typeof url === "string" && /^https?:\/\//.test(url) ? [{ cta, url }] : []
68}
69
70// A non-empty string, or null.
71function text(value) {
72 return typeof value === "string" && value.trim() ? value.trim() : null
73}
74
75function flag(query, name) {
76 return ["1", "true", "yes"].includes(String(query?.[name] ?? "").toLowerCase())
77}
78
79// "Jane Doe's Pro plan (€19.00/month)"
80function describe(sub) {
81 const who = text(sub.customer?.name) ?? text(sub.customer?.billing_name) ?? text(sub.customer?.email)
82 const product = text(sub.product?.name) ?? "subscription"
83 const cost = price(sub)
84
85 return (who ? `${who}'s ${product}` : `A ${product}`) + (cost ? ` (${cost})` : "")
86}
87
88function dashboard(request, sub) {
89 // ?sandbox=1 points the button at the sandbox dashboard.
90 const host = flag(request.query, "sandbox") ? "https://sandbox.polar.sh" : "https://polar.sh"
91 return link(`${host}/to/dashboard/sales/subscriptions/${encodeURIComponent(sub.id)}`, "View subscription")
92}
93
94function handleRequest(request) {
95 const body = request.body && typeof request.body === "object" ? request.body : {}
96 const sub = body.data
97
98 // Guard: only subscription.canceled, so other Polar events on this integration stay quiet.
99 if (body.type !== "subscription.canceled" || !sub || typeof sub !== "object" || !sub.id) {
100 console.log(`Ignoring Polar "${typeof body.type === "string" ? body.type : "unknown"}" event`)
101 return null
102 }
103
104 // Immediate revocation: canceled and ended at once (subscription.revoked is sent right after).
105 const immediate = sub.cancel_at_period_end !== true && (sub.status === "canceled" || Boolean(sub.ended_at))
106 const until = day(sub.ends_at) ?? day(sub.current_period_end)
107 const reason = pick(REASONS, sub.customer_cancellation_reason, null)
108 let comment = text(sub.customer_cancellation_comment)
109 if (comment && comment.length > 120) comment = `${comment.slice(0, 117)}…`
110
111 return {
112 title: "👋 Subscription canceled",
113 message:
114 `${describe(sub)} was canceled.` +
115 (immediate ? " Access ended right away." : until ? ` Access until ${until}.` : "") +
116 (reason ? ` Reason: ${reason}.` : "") +
117 (comment ? ` “${comment}”` : ""),
118 topic: "Polar",
119 priority: 0, // Normal: worth knowing, and they usually keep access until the period ends
120 buttons: dashboard(request, sub),
121 }
122}
Payload

The Polar subscription.canceled webhook

This is what Polar sends to your URL for subscription.canceled. It is a sample, trimmed to the fields recipes use.

subscription.canceled · sample.json
1{
2 "data": {
3 "id": "s1a2b3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b",
4 "amount": 1900,
5 "status": "active",
6 "ends_at": "2026-10-29T08:00:00.000000Z",
7 "product": {
8 "id": "p2a2b3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b",
9 "name": "Pro plan",
10 "description": null,
11 "is_archived": false,
12 "is_recurring": true,
13 "organization_id": "o1a2b3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b",
14 "recurring_interval": "month",
15 "recurring_interval_count": 1
16 },
17 "currency": "eur",
18 "customer": {
19 "id": "c1a2b3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b",
20 "name": "Jane Doe",
21 "type": "individual",
22 "email": "[email protected]",
23 "billing_name": "Jane Doe",
24 "email_verified": true,
25 "organization_id": "o1a2b3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b"
26 },
27 "discount": null,
28 "ended_at": null,
29 "metadata": [],
30 "trial_end": null,
31 "created_at": "2026-06-29T08:00:00.000000Z",
32 "product_id": "p2a2b3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b",
33 "started_at": "2026-06-29T08:00:00.000000Z",
34 "canceled_at": "2026-09-29T08:06:40.000000Z",
35 "checkout_id": null,
36 "customer_id": "c1a2b3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b",
37 "discount_id": null,
38 "modified_at": "2026-09-29T08:06:40.000000Z",
39 "past_due_at": null,
40 "trial_start": null,
41 "current_period_end": "2026-10-29T08:00:00.000000Z",
42 "recurring_interval": "month",
43 "cancel_at_period_end": true,
44 "current_period_start": "2026-09-29T08:00:00.000000Z",
45 "recurring_interval_count": 1,
46 "customer_cancellation_reason": "too_expensive",
47 "customer_cancellation_comment": null
48 },
49 "type": "subscription.canceled",
50 "timestamp": "2026-09-29T08:06:40.000000Z"
51}
FAQ

Polar subscription canceled notifications: questions

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 Polar 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.

Ready when you are

Polar on your phone in two minutes.

Install the recipe, paste one URL, done. Free for 30 days, no credit card required.