Docs
Everything you need to set up your affiliate program with Sled. About a 10-minute read end-to-end.
1. Quick start
- Sign up with your email. You'll get a magic link.
- Name your program. Pick a slug (e.g.
acme) and set your commission % (default 30%). - Connect Polar in
/dashboard/settings— paste your Polar webhook secret, add our webhook URL in Polar. - Drop the tracking script on your marketing site.
- Share
https://usesled.com/acme/joinwith potential affiliates. They sign up and get their own link.
2. How attribution works
An affiliate sale follows this chain:
- An affiliate shares their link, e.g.
https://yoursite.com/?ref=abc1234 - A visitor clicks it. Our tracking script reads
?ref=abc1234and stores it in ata_refcookie (90 days default). - The visitor browses your site, eventually buys something through Polar / Stripe / etc.
- Your checkout code passes the cookie value as
metadata.referralto the payment provider. - The provider fires a webhook to Sled. We look up the referral code → match it to an affiliate → record the conversion + commission.
- Your affiliate sees the sale in their dashboard. You see it in yours.
3. Polar.sh integration
Step 1: Add the webhook in Polar
In your Polar dashboard → Settings → Webhooks → Add endpoint:
| Field | Value |
|---|---|
| URL | https://usesled.com/acme/api/webhook/polar |
| Events | order.created, order.refunded, subscription.canceled |
Copy the signing secret Polar generates. You'll paste it in your Sled settings.
Step 2: Paste the secret in Sled
Go to /dashboard/settings → Polar webhook secret → paste the value → save.
Step 3: Attach the referral cookie in your checkout
Wherever you create a Polar checkout session, attach the ta_ref cookie value as metadata:
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({ accessToken: process.env.POLAR_ACCESS_TOKEN });
const checkout = await polar.checkouts.create({
products: [productId],
successUrl: "https://yourapp.com/thanks",
metadata: {
referral: req.cookies.ta_ref ?? "",
},
});That's it. When a referred customer pays, the conversion appears in /dashboard within seconds.
4. Stripe integration
Webhook URL: https://usesled.com/acme/api/webhook/stripe
Events: checkout.session.completed, charge.refunded
Pass the referral in checkout session metadata:
const session = await stripe.checkout.sessions.create({
// ...your existing fields
metadata: { referral: getCookie("ta_ref") || "" },
});Paste the Stripe signing secret in /dashboard/settings → Stripe webhook secret.
5. Other providers
For any provider that can POST JSON, use our generic webhook. POST to https://usesled.com/acme/api/webhook/generic:
{
"event": "order",
"orderId": "ord_12345",
"amount": 4900,
"email": "customer@example.com",
"metadata": { "referral": "abc1234" }
}For refunds:
{ "event": "refund", "orderId": "ord_12345" }Set a shared secret in /dashboard/settings → Generic webhook secret → and send it on every request as either X-Webhook-Secret: yoursecret or Authorization: Bearer yoursecret.
Amounts are always in cents.
6. Tracking script
Embed on any page where affiliate links land (usually your marketing site root):
<script async src="https://usesled.com/acme/t.js"></script>
What it does, in order:
- Reads
?ref=CODEfrom the URL. - Stores
CODEin ata_refcookie for the configured attribution window (90 days default). - Pings
https://usesled.com/acme/api/clickto record the click. We dedupe by IP for 24 hours so refreshes don't inflate stats.
It's less than 1KB minified. No external dependencies. No third-party calls.
7. Affiliates
Inviting them
Share https://usesled.com/acme/join. Anyone with the link can sign up — name + email, that's it. They immediately get their affiliate link.
What they see
- Their unique referral link
- Click count, conversion count, revenue, earnings
- Pending vs paid amounts
- A form to add payout details (PayPal, Wise, IBAN, crypto wallet) — only after they earn their first commission
Managing them
In /dashboard/affiliates you see everyone's stats — clicks, conversions, owed, payout method.
8. Payouts
Sled doesn't move money for you. We track who's owed what — you send payments manually from your own PayPal / Wise / bank / crypto wallet.
This means: no KYC, no payment processing fees, no compliance overhead. Just a clean ledger.
The flow
- Open
/dashboard/payouts. Affiliates above your minimum threshold appear in Ready for payout. - Each row shows their payment method (PayPal / Wise / Bank / Crypto) and destination (email / IBAN / wallet address).
- You send the payment manually.
- Click Mark paid in the admin — the affiliate gets an email confirming, their pending balance resets.
Set your minimum payout threshold in /dashboard/settings. Default is $20.
9. Email notifications
We send 3 transactional emails on your behalf:
- Welcome — when an affiliate signs up, with their dashboard URL and referral link.
- First commission — when an affiliate earns their first conversion, prompting them to add payout details.
- Payout sent — when you click Mark paid in the admin.
Emails are sent from affiliates@usesled.com with your program name in the From field — affiliates see “acme · affiliate program” as the sender.
10. Settings
| Setting | What it does |
|---|---|
| Program name | Shown to affiliates on signup and in emails. |
| Commission % | Default 30%. Applied to every conversion. |
| Cookie days | How long the ref cookie lives. Default 90. |
| Minimum payout | Below this, affiliates aren't shown in 'Ready for payout'. |
| Polar webhook secret | Required to verify Polar webhooks. |
| Stripe webhook secret | Required if you use Stripe. |
| Generic webhook secret | Required if you use the generic webhook. |
11. Plans
| Free | Pro | |
|---|---|---|
| Price | $0 | $12.00/mo intro then $19.00/mo |
| Max affiliates | 3 | Unlimited |
| All webhooks | ✓ | ✓ |
| Email notifications | ✓ | ✓ |
| Priority support | — | ✓ |
See full pricing & FAQ on the pricing page.
12. Self-hosting
Sled is open source under AGPL-3.0. You can self-host it for free — including for your business — instead of using usesled.com.
Quick start
git clone https://github.com/ardakaano/slend cd sled npm install cp .env.example .env # edit .env (see below) npx prisma db push npm run db:seed npm run dev
Open http://localhost:3000. Sign up at /signup — if email is unconfigured, the magic link prints to your terminal.
Required env vars
| Variable | Description |
|---|---|
DATABASE_URL | Prisma connection — SQLite for dev, Postgres for prod |
BASE_URL | Your app URL (e.g. https://affiliate.yourapp.com) |
RESEND_API_KEY | Optional in dev (magic links print to console). Required for email in production. |
EMAIL_FROM | Sender address (must be Resend-verified) |
Deploy options
- VPS + Caddy/nginx — cheapest, full control. SQLite or Postgres both work. ~€4/mo Hetzner runs many apps.
- Railway / Render — git-push deploys, Postgres add-on one click. ~$5-10/mo.
- Fly.io — supports persistent volumes, so SQLite works without switching DBs.
- Vercel — needs hosted DB (Turso for SQLite, Neon for Postgres) because filesystem is read-only.
- Cloudflare Workers — not supported out of the box. Sled uses Node
crypto, which Workers replaces with Web Crypto API. PRs welcome.
Production checklist
- Switch from SQLite to Postgres: change
providerinprisma/schema.prisma, updateDATABASE_URL, runnpx prisma migrate dev --name init. - Set
RESEND_API_KEYand verify your domain in Resend. - If you want to charge customers (running your own SaaS): set up Polar billing env vars. Otherwise leave empty.
- Put a reverse proxy in front (Caddy is simplest) for HTTPS.
- Set up DB backups. With SQLite that's a daily file copy; with Postgres your provider usually handles it.
License compliance (AGPL-3.0)
You can use Sled in your business for free. The catch: if you modify the code AND offer it as a network service to others, you must publish your modifications under AGPL-3.0 too. If you just run unmodified Sled (or modify it for internal use only), this doesn't apply.
If AGPL doesn't work for you (e.g. you want to embed Sled in proprietary software), email hey@ardakaanozcan.com for a commercial license.
13. Troubleshooting
| Symptom | Fix |
|---|---|
| Webhook not arriving | Send a test event from the Polar dashboard. Check that the webhook URL matches your slug exactly (no typos). |
| Conversion not recorded | Your checkout's metadata.referral was empty. Verify your checkout code reads the ta_ref cookie before creating the session. |
| Affiliate code not detected | The ta_ref cookie didn't set. Make sure ?ref= was in the URL when the visitor first arrived on your site, and that the tracking script is loaded. |
| Affiliate can't access their dashboard | The dashboard URL is their secret — they should bookmark it. If lost, you can find their code in /dashboard/affiliates and resend the URL. |
| Wrong commission amount | Check the commission % in /dashboard/settings. Changes apply to NEW conversions only. |
| Free tier signup blocked | You hit the 3-affiliate cap. Upgrade to Pro for unlimited. |
Email support@usesled.com — Pro plan customers get priority response.