Use GET /v1/embed/data to check if an affiliate already has a coupon:
Copy
const { data } = await fetch(`https://api.affonso.io/v1/embed/data?token=${token}`) .then(r => r.json());if (data.coupon) { // Affiliate already has a coupon console.log(`Your code: ${data.coupon.code}`);} else if (data.couponBlueprint) { // Can create a coupon console.log('You can create a coupon!');} else { // Self-service coupons not enabled console.log('Coupon creation not available');}
Once created, coupon codes cannot be changed. Affiliates should choose their code carefully.