Install
Server-side referrals
Report signups and sales from your server with a secret key.
Use these when signup completes on your server, or when you bill through something Referralmeter doesn't connect to natively. They take your secret key (sk_…) with the write scope. Never put it in browser code.
Record a signup
The server-side twin of referralmeter.signup(). referral is what referralmeter.ref() returned in the browser (send it up with your signup form) or an affiliate code.
curl -X POST https://referralmeter.com/api/v1/referrals \
-H "Authorization: Bearer $REFERRALMETER_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"email":"new.user@example.com","external_id":"user_42","referral":"<referralmeter.ref()>","ip":"203.0.113.7"}'Pass the visitor's ip so the self-referral check still works.
Record a sale
curl -X POST https://referralmeter.com/api/v1/track/sale \
-H "Authorization: Bearer $REFERRALMETER_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"event_id":"pay_123","amount":4900,"currency":"usd","customer_external_id":"user_42","kind":"subscription"}'amountis in cents.event_idis your idempotency key: sending it twice records it once.- Later sales for the same
customer_external_id,customer_idor email attribute to the same affiliate without areferral. kind:subscription,one_time,creditsorusage. Your commission rules decide which kinds pay.livemode: falserecords a test sale that is never paid out.
Record a refund
curl -X POST https://referralmeter.com/api/v1/track/refund \
-H "Authorization: Bearer $REFERRALMETER_SECRET_KEY" -H "Content-Type: application/json" \
-d '{"event_id":"ref_9","payment_id":"pay_123","amount":4900}'Partial refunds claw back the same share of the commission. A commission that was already paid is deducted from the affiliate's next payout.