Polar.sh is one of the best billing platforms for indie SaaS, courses, and digital products in 2026. It's fast, has clean pricing, and the developer experience is excellent.
But it has one notable gap: there's no built-in affiliate program.
If you want creators, newsletter writers, and partners to refer customers to you on a commission basis, Polar doesn't help. Worse, the major affiliate platforms (Rewardful, Tolt, FirstPromoter) are Stripe-first and don't speak Polar's webhook format. So most Polar creators end up either skipping affiliates entirely or paying $89/mo to a tool that requires a manual webhook bridge.
This guide walks through the modern way to do it: a 10-minute setup that handles attribution, recurring commission on subscription renewals, refunds, and a self-serve affiliate dashboard, all native to Polar's webhook events.
What you'll have when you're done
- A public signup page where creators can join your affiliate program
- A unique referral link for each affiliate (e.g.
yoursite.com/?ref=abc1234) - Automatic attribution when a referred visitor buys via Polar checkout
- Recurring commission that follows subscription renewals (not just the first order)
- Refund handling that claws back commission if a customer refunds
- A dashboard where you see clicks, conversions, MRR by affiliate, and pending payouts
- A dashboard where each affiliate sees their own numbers
Total setup time: about 10 minutes if you're comfortable in your Polar dashboard and your checkout code.

TL;DR
If you just want the three snippets:
<!-- 1. Drop on your marketing site -->
<script async src="https://usesled.com/{your-slug}/t.js"></script>
2. In Polar dashboard → Settings → Webhooks → Add endpoint:
URL: https://usesled.com/{your-slug}/api/webhook/polar
Events: order.created, order.refunded, subscription.canceled
// 3. In your checkout-session creation code
await polar.checkouts.create({
products: [productId],
metadata: {
referral: cookies().get("ta_ref")?.value ?? "",
},
});
That's the whole integration. The rest of this post explains why each piece exists, the gotchas, and how to handle subscription renewals correctly.
How Polar affiliate tracking actually works
Before the setup, it helps to understand the data flow. There are five moments:
- Visitor lands on your site with a referral parameter. An affiliate shared
yoursite.com/?ref=abc1234. The visitor clicked it. - Tracking script reads the parameter and drops a cookie. A small JS script (
t.js) reads?ref=abc1234from the URL and storesabc1234in ata_refcookie for 90 days. - Visitor browses, eventually checks out. Could be 30 seconds later, could be 60 days later. As long as the cookie is alive, the attribution is intact.
- Your checkout code passes the cookie to Polar. When you create the Polar checkout session, you attach
metadata: { referral: cookieValue }. - Polar fires a webhook to your affiliate tool. The tool receives
order.created, looks upmetadata.referral, matches it to an affiliate, and records the conversion + commission.
The key insight: attribution is server-side, not client-side. You don't need to put any JavaScript on your checkout-success page. The webhook does the work after the order is complete.
Step 1: Drop the tracking script
Pick an affiliate tool. We'll use Sled in the examples because it's Polar-native (handles polar_whs_ webhook signatures, subscription renewals, refunds out of the box), but any Polar-compatible affiliate tool will follow the same shape.
After signup, you get a slug (let's say acme) and a tracking script URL:
<script async src="https://usesled.com/acme/t.js"></script>
Add it to the <head> of your marketing site. If you're on Next.js:
// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<script async src="https://usesled.com/acme/t.js"></script>
</head>
<body>{children}</body>
</html>
);
}
What the script does, in order:
- Reads
?ref=CODEfrom the current URL - Stores
CODEin a first-partyta_refcookie (90 days) - POSTs a click event to your affiliate tool (dedupes by IP for 24 hours so refreshes don't inflate stats)
The script is under 1KB minified, no external dependencies, no third-party calls. It's safe to drop on every page.
Step 2: Add the Polar webhook
In your Polar dashboard, go to Settings → Webhooks → Add endpoint and configure:
| Field | Value |
|---|---|
| URL | https://usesled.com/acme/api/webhook/polar |
| Events | order.created, order.refunded, subscription.canceled |
Polar will generate a signing secret that starts with polar_whs_. Copy it.
In your affiliate tool's settings, paste the secret. (In Sled, this is at /dashboard/settings → Polar webhook secret.) The signing secret is how the tool verifies that incoming webhook events actually came from Polar and weren't spoofed.
Gotcha: Polar uses the Standard Webhooks spec for signature verification, but the signing secret has a
polar_whs_prefix that isn't part of the spec. If you're building your own integration, you need to strip the prefix before passing the secret to your verifier. This is the #1 reason hand-rolled Polar webhook integrations break in the first hour. (Any Polar-aware affiliate tool handles this for you.)
Step 3: Pass the referral cookie through checkout
Wherever you create a Polar checkout session, attach the ta_ref cookie value as metadata:
import { Polar } from "@polar-sh/sdk";
import { cookies } from "next/headers";
const polar = new Polar({ accessToken: process.env.POLAR_ACCESS_TOKEN! });
export async function createCheckout(productId: string) {
const referral = (await cookies()).get("ta_ref")?.value ?? "";
return await polar.checkouts.create({
products: [productId],
successUrl: "https://yourapp.com/thanks",
metadata: {
referral,
},
});
}
If you're using Polar's hosted checkout via a button or link (not the SDK), you can pass metadata[referral] as a query parameter on the checkout URL:
<a href="https://buy.polar.sh/polar_cl_xxx?metadata[referral]=abc1234">Buy now</a>
Or generate the URL server-side after reading the cookie. Either works, the goal is just to get the referral code into Polar's metadata field on the order.
That's it. When a referred customer pays, the conversion appears in your affiliate dashboard within seconds of Polar firing the webhook.
The hard part: recurring commission on subscription renewals
Here's the bit most DIY affiliate integrations get wrong.
When a customer first subscribes via Polar, you get an order.created webhook with your metadata.referral intact. Easy to attribute.
But when Polar bills the customer the next month (and every month after), the renewal order.created payload does not include the original metadata. The referral field is empty. If you naively look at metadata.referral on every order, the renewal orders look like organic sales, and your affiliate stops earning commission after month 1.
This is the single biggest reason DIY Polar affiliate code is silently broken. Affiliates think they refer a $29/mo customer and earn $8.70/month forever. Actually, they earn $8.70 once.
The fix: subscription_id inheritance
Polar renewal orders carry the original subscription_id. You need to:
- On the first order with metadata.referral, record the mapping:
subscription_id → affiliateId. - On every subsequent order, if
metadata.referralis empty butsubscription_idmatches a known referral, attribute the renewal to the same affiliate.
In SQL-ish pseudocode:
// When order.created arrives:
const refCode = order.metadata?.referral;
const subId = order.subscription_id;
let affiliateId: string | null = null;
if (refCode) {
// First-order attribution
affiliateId = await findAffiliateByCode(refCode);
if (affiliateId && subId) {
await rememberSubscriptionAffiliate(subId, affiliateId);
}
} else if (subId) {
// Renewal, look up the original
affiliateId = await getSubscriptionAffiliate(subId);
}
if (affiliateId) {
await recordCommission({
affiliateId,
orderId: order.id,
amountCents: order.amount,
rate: 0.30,
});
}
This is straightforward if you're rolling your own, but easy to get wrong on edge cases (subscription upgrades, plan changes, currency conversion on renewals). The reason to use a Polar-aware affiliate tool (Sled handles this out of the box) is that the renewal-inheritance logic is already tested in production against real Polar subscription events.
Step 4: Handle refunds
When a customer refunds, you want to claw back the commission you owed the affiliate (otherwise affiliates could push customers who refund a week later, and you'd lose 60% of revenue on the deal).
Polar fires order.refunded when this happens. Your affiliate tool should listen for it and mark the matching commission as refunded (subtract it from the affiliate's pending balance).
If you're rolling your own:
// When order.refunded arrives:
const refundedOrderId = event.data.order_id;
await markCommissionRefunded(refundedOrderId);
Sled does this automatically when you subscribe to order.refunded in the webhook configuration above.
Step 5: Decide your commission rate and cookie window
This is the strategic part, not the technical part. Here's the modern indie SaaS baseline:
- 30% commission, recurring for the life of the subscription. Higher than the legacy 20% rate, because creators have more channels competing for their time in 2026. Recurring (not one-time) is critical to motivate evergreen content.
- 90-day cookie window. Long enough for B2B buying cycles. Anything shorter and creators complain (legitimately).
- Per-affiliate commission overrides for VIP partners. Default 30%, but bump your top 3 affiliates to 40% if they're driving real volume.
Set these in your affiliate tool's settings, not in code. You want to be able to change them without a deploy.
Step 6: Launch the affiliate signup page
Now share your affiliate signup URL, for Sled, it's https://usesled.com/{your-slug}/join. Anyone who visits can sign up with just a name and email, no approval required.
Promote it from:
- Your site footer ("Become an affiliate")
- Your customer onboarding email ("By the way, we have a 30% recurring affiliate program, link here")
- Your existing happy customers (DM them directly, most will say yes)
- Public directories of affiliate programs in your niche
Don't gatekeep. The friction of an approval queue is the single biggest reason indie affiliate programs fail to bootstrap.
What this costs
In 2026, the realistic options:
| Tool | Polar support | Price | Setup |
|---|---|---|---|
| Sled | Native (handles polar_whs_, renewals, refunds) |
10-day free trial, then $19/mo Pro | ~10 minutes |
| Rewardful | None (Stripe-first, requires manual webhook bridge) | $49–$149/mo | Hours of glue code |
| Tolt | None (no Polar). Stripe and Paddle are documented. | Basic $69 / Growth $99 / Pro $199 on tolt.io, checked 2026-11-03 | Not viable for Polar |
| FirstPromoter | None (Stripe-first, manual bridge possible) | $49–$149/mo | Hours of glue code |
| DIY | You write it | Free + your time | Days of work + ongoing bugs |
For most indie SaaS on Polar, the choice is between Sled and DIY. The DIY path is real (Polar's webhook spec is well-documented) but you'll spend at least 2–3 days getting the renewal inheritance, refund handling, and dashboard right. And then you're maintaining it forever.
Common Polar affiliate gotchas
A few things that bite people setting this up for the first time:
"Conversions aren't being recorded"
99% of the time: your checkout's metadata.referral is empty. Check that your checkout code is reading the ta_ref cookie before creating the Polar session, and that the cookie is actually set (open dev tools → Application → Cookies on a page with ?ref= in the URL).
"The webhook isn't arriving"
Send a test event from your Polar dashboard. Check that the webhook URL matches your slug exactly (a typo here is silent, Polar returns 404, you don't see it unless you check the Polar webhook logs).
"Renewals aren't crediting the affiliate"
You hit the subscription-renewal inheritance bug described above. Either fix your DIY code with the subscription_id lookup pattern, or use a tool that handles it.
"Signature verification fails"
You forgot to strip the polar_whs_ prefix from the signing secret. Or you passed the raw secret instead of the base64-decoded form. (Polar-aware tools handle this.)
"I see the affiliate dashboard but no clicks"
Check that the tracking script (t.js) is actually loaded. Open dev tools → Network on your homepage → look for a request to /t.js. If it's blocked, you may have an ad blocker or strict CSP rule.
Frequently asked questions
Does Polar.sh have a built-in affiliate program?
Not as of 2026-05. Polar is excellent for billing, subscriptions, license keys, and checkout (but affiliate tracking is not a built-in feature. You need to integrate a separate tool (like Sled) affiliate tracking built for Polar.sh) that listens to Polar's webhook events.
Can I use Rewardful with Polar.sh?
Technically yes via a manual webhook bridge, but it's painful and brittle. Rewardful is designed around Stripe's webhook format and doesn't understand Polar's polar_whs_ signatures, subscription renewal events, or refund payloads natively. You'd need to write a translation layer. Most Polar creators use a Polar-native tool instead.
What if I'm on Stripe or Paddle instead?
Same playbook, different webhook payload. We wrote dedicated setup guides for both: add an affiliate program to Stripe and add one to Paddle.
How do I handle subscription renewals correctly?
Renewal order.created events from Polar don't carry the original metadata.referral. You need to use the subscription_id to look up the affiliate from the first order. See the code example above. Sled does this automatically.
What's the recommended commission rate for Polar affiliates?
30% recurring is the modern baseline for indie SaaS in 2026. Higher (35–40%) if you have very high gross margins or want to incentivize top creators. Lower than 25% is generally not competitive, creators have many other programs to choose from.
Does Sled work with self-hosted Polar or just polar.sh?
Sled works with the hosted polar.sh service via standard webhooks. If you're running a self-hosted Polar instance, it should work as long as your webhook payloads match the Polar Standard Webhooks spec, but this isn't officially tested. The hosted polar.sh path is the supported one.
Can I run an affiliate program on Polar without writing any code?
Almost. You need to add one line to your checkout code (the metadata: { referral } field). Everything else (the tracking script, webhook, dashboard, payout calculations) is configuration. The one-line change is unavoidable because that's how Polar tells your affiliate tool which order to attribute.
What about Polar's license keys / pay-once products?
Same flow. order.created fires for one-time orders too. Your affiliate gets a one-time commission instead of recurring. The configuration is identical.
Want to set up an affiliate program for your Polar.sh product in the next 10 minutes? Sled is Polar-native, handles subscription renewals correctly, and comes with a 10-day free trial. Read the full docs →