Adding affiliates through the API is (usually) a 2-step process:
Create the affiliate: At this point the affiliate id will be created. As longs as an affiliate is created, but not yet part of any program, they will be archived.
Add the affiliate to a program: At this point, the affiliate's unique referral link will be generated (these are unique per affiliate, per program). It can be picked up from the response.
Note: To launch trigger email notifications when the affiliate is added to a program, add ?send_welcome_email=true
to the endpoint URL of the second step.