Link Management

Generate and track affiliate links with analytics

Generate Affiliate Link

POST /api/v1/affiliate/links/generate/

Request Body

{
  "affiliate_id": 123,
  "product_id": 456,
  "utm_parameters": {
    "source": "email",
    "medium": "newsletter", 
    "campaign": "summer2024",
    "content": "header_banner"
  },
  "expires_date": "2024-12-31T23:59:59Z",
  "custom_parameters": {
    "discount_code": "SAVE20",
    "landing_page": "special-offer"
  }
}

Example Response

{
  "success": true,
  "data": {
    "id": 789,
    "affiliate_id": 123,
    "product_id": 456,
    "url": "https://rebusai.com/product/awesome-course?ref=AFFILIATE123&utm_source=email",
    "short_url": "https://rebusai.co/a/abc123",
    "qr_code_url": "https://rebusai.com/qr/abc123.png",
    "created_date": "2024-01-15T10:30:00Z",
    "expires_date": "2024-12-31T23:59:59Z",
    "click_count": 0,
    "conversion_count": 0
  },
  "message": "Link generated successfully"
}

List Affiliate Links

GET /api/v1/affiliate/links/

Query Parameters

Parameter Type Description
affiliate_id int Filter by affiliate
product_id int Filter by product
active boolean Filter by active status
date_from date Created after date
date_to date Created before date

Get Link Analytics

GET /api/v1/affiliate/links/{id}/analytics/

Example Response

{
  "success": true,
  "data": {
    "link_id": 789,
    "total_clicks": 456,
    "unique_clicks": 324,
    "conversions": 28,
    "conversion_rate": 8.64,
    "revenue_generated": 3200.00,
    "commissions_earned": 384.00,
    "geographic_breakdown": {
      "US": 234,
      "CA": 89,
      "UK": 67,
      "Other": 66
    },
    "traffic_sources": {
      "email": 201,
      "social": 156,
      "direct": 99
    },
    "device_breakdown": {
      "desktop": 278,
      "mobile": 156,
      "tablet": 22
    }
  }
}