Generate Referral Links
Create unique referral links for your users.
Each user gets a unique referral link that tracks their referrals. Links can be generated via SDK, API, or dashboard.
Using the SDK
import { ReferralEngine } from '@referral-engine/sdk'
const referral = new ReferralEngine({ apiKey: 'your_api_key' })
// Generate a link for a user
const link = await referral.createLink({
userId: 'user_123',
campaignId: 'camp_abc',
metadata: {
source: 'share_button'
}
})
console.log(link.url)
// https://ref.yourdomain.com/r/abc123Using the REST API
curl -X POST https://api.referralengine.com/v1/links \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user_123",
"campaign_id": "camp_abc"
}'Link Customization
You can customize links with:
- Custom slugs — Memorable URLs like
/r/john-smith - UTM parameters — Track sources in your analytics
- Deep link data — Pass data into your mobile app
Links are permanent by default but can be configured to expire after a certain time or number of uses.