Docs

Integration Guide

Three ways to integrate AgentLinks. Pick whichever fits your stack.

Option 1 — Tracking script (easiest)

Drop this in your <head>. Done.

<script
  src="https://agentlinksai.com/agentlinks.js"
  data-app-id="YOUR_APP_ID"
  async
></script>

It automatically:

  • Reads ?ref=CODE from the URL
  • Stores it in a agentlinks_ref cookie for 60 days
  • Pings /api/track/click so the creator’s click counter updates
  • Exposes window.AgentLinks with manual signup/conversion methods

Step 2 — Track signups

Call this right after a user successfully creates an account:

window.AgentLinks.trackSignup({
  user_id: newUser.id,
  email: newUser.email
});

This creates a referral record tied to the refcookie set by the tracking script. If there’s no cookie (user came direct), it’s a no-op.

Step 3 — Track conversions

Call this after every successful payment. AgentLinks calculates commission automatically based on your app’s commission settings.

window.AgentLinks.trackConversion({
  user_id: customer.id,
  amount_cents: 999  // what the customer paid
});

⚠️ This is called from your backend after Stripe confirms the charge, not from the browser. Use the raw fetch form below for server-side calls.

Option 2 — Direct API (no script)

If you don’t want a script, call the endpoints directly from your backend. Public endpoints, no auth required — the ref code is the only credential needed.

POST /api/track/click

fetch('https://agentlinksai.com/api/track/click', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ ref: 'bf7k2x' })
});

POST /api/track/signup

fetch('https://agentlinksai.com/api/track/signup', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    ref: 'bf7k2x',
    user_id: 'usr_abc123',    // your internal user ID
    email: 'user@example.com' // optional
  })
});

POST /api/track/conversion

fetch('https://agentlinksai.com/api/track/conversion', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    ref: 'bf7k2x',
    user_id: 'usr_abc123',
    amount_cents: 2500  // required
  })
});

Response includes the calculated commission object: { amount_cents, commission_cents, platform_fee_cents, net_commission_cents }.

Option 3 — Stripe Connect (zero code)

Connect your Stripe account and AgentLinks will automatically detect paid invoices and credit commissions. No conversion tracking code needed.

  1. Go to your app dashboard
  2. Click Connect Stripe
  3. Complete the Stripe onboarding flow
  4. When a referred customer pays, the ref code comes in via Stripe metadata and we credit the creator

Important: You still need to pass the ref code to Stripe when creating customers or checkout sessions. Example:

stripe.customers.create({
  email: user.email,
  metadata: {
    agentlinks_ref: getCookie('agentlinks_ref')
  }
});

Commission math

AgentLinks takes a 5% platform fee on each commission. Creators receive the rest.

Customer paid:      $100.00
Your commission %:  30%
Gross commission:   $30.00
Platform fee (5%):  $1.50
Creator net:        $28.50

Creators earn 28.5% of the original sale. You effectively pay 30% for the promotion; AgentLinks takes 1.5% as the platform fee.

Pending vs. available balance

Conversions land in the creator’s pending balance for 14 days to account for refunds. After that, the amount moves to available and can be cashed out.

If you refund a customer, call /api/track/refundwith the ref code and amount — we’ll deduct it from the creator’s pending balance automatically.

List your app →