Affiliate Management

Complete CRUD operations for affiliate management

List Affiliates

GET /api/v1/affiliate/affiliates/

Query Parameters

Parameter Type Description
page int Page number (default: 1)
page_size int Results per page (max: 100, default: 20)
status string Filter by status (pending, approved, rejected)
tier int Filter by tier (1-5)
search string Search by name or email
active boolean Filter by active status

Example Request

curl -X GET "https://rebusai.com/api/v1/affiliate/affiliates/?page=1&page_size=20&status=approved" \
  -H "Authorization: Bearer sk_live_your_api_key"

Example Response

{
  "success": true,
  "data": {
    "results": [
      {
        "id": 123,
        "name": "John Smith",
        "email": "john@example.com",
        "status": {
          "value": "approved",
          "display": "Approved"
        },
        "tier": 2,
        "commission_rate": 12.0,
        "join_date": "2024-01-15T10:30:00Z",
        "active": true,
        "performance_metrics": {
          "total_sales": 15000.00,
          "total_commissions": 1800.00,
          "conversion_rate": 12.5,
          "total_clicks": 2500
        }
      }
    ],
    "pagination": {
      "page": 1,
      "page_size": 20,
      "total_pages": 5,
      "total_count": 95,
      "has_next": true,
      "has_previous": false,
      "next_url": "/api/v1/affiliate/affiliates/?page=2",
      "previous_url": null
    }
  },
  "message": "Affiliates retrieved successfully",
  "timestamp": 1640995200,
  "api_version": "1.0"
}

Create Affiliate

POST /api/v1/affiliate/affiliates/

Request Body

{
  "name": "Jane Doe",
  "email": "jane@example.com",
  "phone": "+1-555-0123",
  "website": "https://janedoe.com",
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "state_id": 47,
    "country_id": 233,
    "zip": "10001"
  },
  "payment_methods": [
    {
      "type": "paypal",
      "email": "jane@paypal.com"
    }
  ],
  "marketing_channels": ["social_media", "blog", "email"],
  "audience_size": 5000,
  "experience_level": "intermediate"
}

Example Response

{
  "success": true,
  "data": {
    "id": 124,
    "name": "Jane Doe",
    "email": "jane@example.com",
    "status": {
      "value": "pending",
      "display": "Pending Approval"
    },
    "tier": 1,
    "commission_rate": 10.0,
    "join_date": "2024-01-20T14:22:00Z",
    "active": true,
    "affiliate_code": "JANE_DOE_124"
  },
  "message": "Affiliate created successfully",
  "timestamp": 1640995200,
  "api_version": "1.0"
}

Get Affiliate Details

GET /api/v1/affiliate/affiliates/{id}/

Example Request

curl -X GET "https://rebusai.com/api/v1/affiliate/affiliates/123/" \
  -H "Authorization: Bearer sk_live_your_api_key"

Example Response

{
  "success": true,
  "data": {
    "id": 123,
    "name": "John Smith",
    "email": "john@example.com",
    "phone": "+1-555-0123",
    "website": "https://johnsmith.com",
    "status": {
      "value": "approved",
      "display": "Approved"
    },
    "tier": 2,
    "commission_rate": 12.0,
    "join_date": "2024-01-15T10:30:00Z",
    "active": true,
    "affiliate_code": "JOHN_SMITH_123",
    "address": {
      "street": "456 Oak St",
      "city": "Los Angeles",
      "state": "California",
      "country": "United States",
      "zip": "90210"
    },
    "payment_methods": [
      {
        "type": "paypal",
        "email": "john@paypal.com",
        "verified": true
      }
    ],
    "performance_metrics": {
      "total_sales": 15000.00,
      "total_commissions": 1800.00,
      "conversion_rate": 12.5,
      "total_clicks": 2500,
      "lifetime_value": 25000.00
    }
  },
  "message": "Affiliate details retrieved successfully",
  "timestamp": 1640995200,
  "api_version": "1.0"
}

Update Affiliate

PUT /api/v1/affiliate/affiliates/{id}/

Request Body

{
  "commission_rate": 15.0,
  "tier": 3,
  "phone": "+1-555-9999",
  "website": "https://newwebsite.com",
  "address": {
    "street": "789 New Ave",
    "city": "San Francisco",
    "zip": "94102"
  }
}

Example Request

curl -X PUT "https://rebusai.com/api/v1/affiliate/affiliates/123/" \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"commission_rate": 15.0, "tier": 3, "phone": "+1-555-9999"}'

Example Response

{
  "success": true,
  "data": {
    "id": 123,
    "name": "John Smith",
    "email": "john@example.com",
    "phone": "+1-555-9999",
    "website": "https://newwebsite.com",
    "status": {
      "value": "approved",
      "display": "Approved"
    },
    "tier": 3,
    "commission_rate": 15.0,
    "join_date": "2024-01-15T10:30:00Z",
    "updated_date": "2024-01-20T16:45:00Z",
    "active": true,
    "affiliate_code": "JOHN_SMITH_123"
  },
  "message": "Affiliate updated successfully",
  "timestamp": 1640995200,
  "api_version": "1.0"
}

Approve Affiliate

POST /api/v1/affiliate/affiliates/{id}/approve/

Request Body

{
  "tier": 2,
  "commission_rate": 12.0,
  "approval_note": "Approved based on excellent portfolio"
}

Example Request

curl -X POST "https://rebusai.com/api/v1/affiliate/affiliates/123/approve/" \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"tier": 2, "commission_rate": 12.0, "approval_note": "Approved based on excellent portfolio"}'

Example Response

{
  "success": true,
  "data": {
    "id": 123,
    "name": "John Smith",
    "email": "john@example.com",
    "status": {
      "value": "approved",
      "display": "Approved"
    },
    "tier": 2,
    "commission_rate": 12.0,
    "join_date": "2024-01-15T10:30:00Z",
    "approved_date": "2024-01-20T16:45:00Z",
    "approved_by": "admin@rebusai.com",
    "approval_note": "Approved based on excellent portfolio",
    "active": true,
    "affiliate_code": "JOHN_SMITH_123"
  },
  "message": "Affiliate approved successfully",
  "timestamp": 1640995200,
  "api_version": "1.0"
}

Get Affiliate Performance

GET /api/v1/affiliate/affiliates/{id}/performance/

Query Parameters

Parameter Type Description
date_from date Start date (ISO format: YYYY-MM-DD)
date_to date End date (ISO format: YYYY-MM-DD)

Example Response

{
  "success": true,
  "data": {
    "affiliate_id": 123,
    "period": {
      "start_date": "2024-01-01",
      "end_date": "2024-01-31"
    },
    "metrics": {
      "total_clicks": 1250,
      "unique_clicks": 890,
      "conversions": 67,
      "conversion_rate": 7.53,
      "total_sales": 8900.00,
      "total_commissions": 1068.00,
      "average_order_value": 132.84
    },
    "trending": {
      "clicks_trend": "+15%",
      "conversion_trend": "+8%",
      "commission_trend": "+22%"
    }
  }
}