Generate a token to display an affiliate’s dashboard within your application. The token automatically creates the affiliate account if it doesn’t exist.
Body Parameters
The affiliate program ID. Must be an active program belonging to your team.
Partner/affiliate information. Show Partner Object Properties
Partner’s email address. Used to identify or create the affiliate account.
Partner’s display name. Used when creating a new affiliate.
Partner’s avatar URL. Must be a valid URL.
Optional affiliate group ID. If not provided, uses the program’s default group. Use this to assign new affiliates to specific commission tiers or groups.
Your external user ID for linking referral users to your own user system. Useful for matching affiliates back to users in your application. Maximum 255 characters. If provided and the affiliate already exists, this will update their external user ID.
Custom key-value data for storing additional information about the affiliate (e.g., {"plan": "pro", "signup_source": "app"}). If provided and the affiliate already exists, this will update their metadata.
Response
Always true for successful responses.
The embed token data. Show Data Object Properties
The token to use for embed data requests. Valid for 30 minutes.
ISO 8601 timestamp when the token expires.
The affiliate’s full referral link.
The affiliate’s partnership status with the program. Either APPROVED or PENDING.
APPROVED: Affiliate can immediately start referring
PENDING: Affiliate needs manual approval before they can earn commissions
This depends on your program’s Access Mode setting (Public vs Private).
Behavior
User Lookup/Creation : If no user exists with the provided email, a new user is created.
Affiliate Lookup/Creation : If no affiliate exists for this user and program, one is created.
Group Assignment : New affiliates are assigned to the specified groupId or the program’s default group.
Partnership : New affiliates are enrolled in the program with a status based on your program’s Access Mode setting:
Public (auto-approve) → Partnership status is APPROVED (affiliate can start referring immediately)
Private (manual approval) → Partnership status is PENDING (requires manual approval in dashboard)
Tracking ID : A unique tracking ID is generated from the name or email.
Token Cleanup : Previous tokens for this affiliate/program are deleted.
curl -X POST "https://api.affonso.io/v1/embed/token" \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"programId": "cm7xutqbb0001yfkcrnpextmp",
"partner": {
"email": "[email protected] ",
"name": "John Doe",
"image": "https://example.com/avatar.jpg"
}
}'
Response
Error - Program Not Found
Error - Validation Error
{
"success" : true ,
"data" : {
"publicToken" : "a1b2c3d4e5f6789..." ,
"expiresAt" : "2024-01-15T10:30:00.000Z" ,
"link" : "https://yourcompany.com?via=john-doe" ,
"partnershipStatus" : "APPROVED"
}
}
With Custom Group
Assign new affiliates to a specific group with different commission rates:
curl -X POST "https://api.affonso.io/v1/embed/token" \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"programId": "cm7xutqbb0001yfkcrnpextmp",
"partner": {
"email": "[email protected] ",
"name": "VIP Partner"
},
"groupId": "cm8abc123vip_group_id"
}'
Tokens expire after 30 minutes. Generate a new token on each page load rather than caching tokens.