✨ FunnelsEye API

Your all-in-one backend for marketing funnels, lead management, and more.

🔐 Authentication & User Management

Method Endpoint Description
POST /api/auth/signup Unified user registration supporting all roles including MLM coaches
For coaches: must provide unique selfCoachId. For other roles: MLM fields are optional.
Body: { "name": "Full name (required)", "email": "Email address (required)", "password": "Password (required)", "role": "User role: client, coach, admin, staff (required)", "selfCoachId": "Unique Coach ID - required only for coach role", "currentLevel": "MLM hierarchy level (1-12) - required only for coach role", "sponsorId": "Sponsor coach ID (required for coach role)", "teamRankName": "Team rank name (optional for coach role)", "presidentTeamRankName": "President team rank name (optional for coach role)" }
Example:
"POST /api/auth/signup\nBody: {\"name\": \"John Doe\", \"email\": \"john@example.com\", \"password\": \"password123\", \"role\": \"coach\", \"selfCoachId\": \"COACH123\", \"currentLevel\": 1, \"sponsorId\": \"sponsor_id\"}"
POST /api/auth/upgrade-to-coach Convert existing verified user to MLM coach
Allows users to join MLM system later without re-signup. All hierarchy fields required.
Body: { "required": [ "userId", "selfCoachId", "currentLevel", "sponsorId" ], "optional": [ "teamRankName", "presidentTeamRankName" ] }
Example:
{
  "userId": "user_id",
  "selfCoachId": "W1234567",
  "currentLevel": 1,
  "sponsorId": "sponsor_id",
  "teamRankName": "Team Alpha",
  "presidentTeamRankName": "President Team"
}
POST /api/auth/lock-hierarchy Lock coach hierarchy to prevent future changes (one-time action)
NEW: Lock hierarchy after first save. Changes can only be made through admin request.
Body: { "required": [ "coachId" ] }
Example:
{
  "coachId": "coach_id"
}
GET /api/auth/available-sponsors Get list of available digital coaches who can be sponsors
NEW: Only digital coaches can be sponsors. External sponsors removed.
Body: No body required
Example:
"GET /api/auth/available-sponsors"
GET /api/auth/coach-ranks Get all available coach ranks for signup dropdown
NEW: Returns 12 MLM coach ranks (Distributor Coach to Founder's Circle)
Body: No body required
Example:
"GET /api/auth/coach-ranks"
POST /api/auth/verify-otp No description
POST /api/auth/login No description
POST /api/auth/forgot-password No description
POST /api/auth/reset-password No description
POST /api/auth/resend-otp No description
GET /api/auth/me No description
PUT /api/auth/update-profile No description
POST /api/auth/logout No description

📈 Funnel Management

Method Endpoint Description
GET /api/funnels/coach/:coachId/funnels Get all Funnels for a Coach
GET /api/funnels/coach/:coachId/funnels/:funnelId Get Single Funnel Details
POST /api/funnels/coach/:coachId/funnels Create New Funnel
{
  "name": "My Funnel",
  "description": "Demo",
  "funnelUrl": "coach-1/demo-funnel",
  "targetAudience": "customer",
  "stages": []
}
PUT /api/funnels/coach/:coachId/funnels/:funnelId Update Funnel
{
  "name": "Updated Funnel Name"
}
DELETE /api/funnels/coach/:coachId/funnel/:funnelId Delete Funnel
GET /api/funnels/coach/:coachId/funnels/:funnelId/stages/:stageType Get Stages by Type
POST /api/funnels/:funnelId/stages Add Stage to Funnel
{
  "pageId": "landing-1",
  "name": "Landing",
  "type": "Landing",
  "html": "
...
" }
PUT /api/funnels/:funnelId/stages/:stageSettingsId Update Stage Settings
{
  "name": "New name",
  "isEnabled": true
}
POST /api/funnels/track Track Funnel Event
{
  "funnelId": "...",
  "stageId": "...",
  "eventType": "PageView",
  "sessionId": "sess-123",
  "metadata": {
    "ref": "ad"
  }
}
GET /api/funnels/:funnelId/analytics Get Funnel Analytics Data

🌐 Custom Domain Management

Method Endpoint Description
POST /api/custom-domains Add Custom Domain
{
  "domain": "coachvarun.in"
}
GET /api/custom-domains Get All Custom Domains for Coach
GET /api/custom-domains/:id Get Single Custom Domain Details
PUT /api/custom-domains/:id Update Custom Domain Settings
DELETE /api/custom-domains/:id Delete Custom Domain
POST /api/custom-domains/:id/verify-dns Verify DNS Records
POST /api/custom-domains/:id/generate-ssl Generate SSL Certificate
GET /api/custom-domains/:id/dns-instructions Get DNS Setup Instructions
GET /api/custom-domains/resolve/:hostname Resolve Domain by Hostname (Public)

🎯 Lead Management (CRM)

Method Endpoint Description
POST /api/leads Create New Lead (PUBLIC)
{
  "coachId": "...",
  "funnelId": "...",
  "name": "Jane",
  "email": "jane@ex.com",
  "phone": "+11234567890",
  "source": "Web Form"
}
GET /api/leads Get All Leads (filters/pagination)
GET /api/leads/:leadId Get Single Lead by ID
PUT /api/leads/:leadId Update Lead (PUBLIC - No Auth Required)
{
  "status": "Contacted",
  "leadTemperature": "Hot",
  "vslWatchPercentage": 75.5
}
DELETE /api/leads/:leadId Delete Lead
POST /api/leads/:leadId/followup Add Follow-up Note
{
  "note": "Called the lead",
  "nextFollowUpAt": "2025-01-20T10:00:00Z"
}
GET /api/leads/followups/upcoming Get Leads for Upcoming Follow-ups
POST /api/leads/:leadId/ai-rescore AI Rescore a Lead
POST /api/leads/assign-nurturing-sequence Assign a nurturing sequence to a lead
{
  "leadId": "...",
  "sequenceId": "..."
}
POST /api/leads/advance-nurturing-step Advance a lead to the next nurturing step
{
  "leadId": "..."
}
GET /api/leads/:leadId/nurturing-progress Get nurturing sequence progress for a lead
GET /api/leads/:leadId/ai-qualify AI-powered lead qualification and insights
{
  "leadId": "..."
}
POST /api/leads/:leadId/generate-nurturing-sequence Generate AI-powered nurturing strategy
{
  "leadId": "...",
  "sequenceType": "warm_lead"
}
POST /api/leads/:leadId/generate-followup-message Generate AI-powered follow-up message
{
  "leadId": "...",
  "followUpType": "first_followup",
  "context": "General follow-up"
}

🌱 Lead Nurturing

Method Endpoint Description
POST /api/lead-nurturing/assign-sequence Assign nurturing sequence to lead
{
  "leadId": "...",
  "sequenceId": "..."
}
POST /api/lead-nurturing/progress-step Progress lead to next nurturing step
{
  "leadId": "..."
}
GET /api/lead-nurturing/status Get nurturing status for leads

📊 Lead Scoring & Tracking

Method Endpoint Description
GET /api/lead-scoring/email-opened Track email opened event
GET /api/lead-scoring/link-clicked Track link clicked event
POST /api/lead-scoring/form-submitted Track form submission event
{
  "leadId": "...",
  "formData": {}
}
POST /api/lead-scoring/call-booked Track call booking event
{
  "leadId": "...",
  "callTime": "2025-01-25T10:00:00Z"
}
POST /api/lead-scoring/call-attended Track call attendance event
{
  "leadId": "...",
  "duration": 30
}
POST /api/lead-scoring/profile-completed Track profile completion event
{
  "leadId": "..."
}
POST /api/lead-scoring/lead-magnet-converted Track lead magnet conversion
{
  "leadId": "...",
  "magnetId": "..."
}
POST /api/lead-scoring/followup-added Track followup addition
{
  "leadId": "...",
  "followupNote": "Called prospect"
}
POST /api/lead-scoring/booking-recovered Track booking recovery
{
  "leadId": "...",
  "originalBookingId": "..."
}
POST /api/lead-scoring/inactivity-decay Track inactivity decay
{
  "leadId": "...",
  "daysInactive": 30
}
POST /api/lead-scoring/unsubscribed Track unsubscription event
{
  "leadId": "...",
  "reason": "No longer interested"
}
POST /api/lead-scoring/email-bounced Track email bounce event
{
  "leadId": "...",
  "bounceType": "hard"
}

🌱 Nurturing Sequences

Method Endpoint Description
POST /api/nurturing-sequences Create new nurturing sequence
{
  "name": "Warm Lead Sequence",
  "description": "5-step sequence for warm leads",
  "category": "warm_lead",
  "steps": [
    {
      "stepNumber": 1,
      "name": "Welcome Message",
      "actionType": "send_email",
      "actionConfig": {
        "message": "Hi {{lead.name}}, welcome!"
      },
      "delayDays": 0
    }
  ]
}
GET /api/nurturing-sequences Get all nurturing sequences for coach
GET /api/nurturing-sequences/:id Get single nurturing sequence details
PUT /api/nurturing-sequences/:id Update nurturing sequence
DELETE /api/nurturing-sequences/:id Delete nurturing sequence
POST /api/nurturing-sequences/:id/duplicate Duplicate a nurturing sequence
{
  "newName": "Warm Lead Sequence Copy"
}
PUT /api/nurturing-sequences/:id/toggle Toggle sequence active status
POST /api/nurturing-sequences/assign-to-funnel Assign sequence to funnel
{
  "sequenceId": "...",
  "funnelId": "..."
}
POST /api/nurturing-sequences/remove-from-funnel Remove sequence from funnel
{
  "sequenceId": "...",
  "funnelId": "..."
}
POST /api/nurturing-sequences/bulk-assign Bulk assign sequences to funnels
{
  "sequenceIds": [
    "seq1",
    "seq2"
  ],
  "funnelIds": [
    "funnel1",
    "funnel2"
  ]
}
GET /api/nurturing-sequences/:id/stats Get sequence execution statistics
GET /api/nurturing-sequences/category/:category Get sequences by category
POST /api/nurturing-sequences/:id/test Test sequence execution (dry run)
{
  "leadId": "..."
}

📊 Advanced MLM Network (Unified)

Method Endpoint Description
GET /api/advanced-mlm/health Health check for MLM system
Public endpoint to check system health
Example:
"GET /api/advanced-mlm/health"
GET /api/advanced-mlm/test-middleware Test middleware chain (Admin only)
Admin endpoint to test if middleware chain is working correctly
Example:
"GET /api/advanced-mlm/test-middleware (with admin JWT token)"
POST /api/advanced-mlm/setup-hierarchy Setup default coach ranks (Admin only)
Creates 12 default coach ranks (Distributor Coach to Founder's Circle)
Body: No body required
Example:
"POST /api/advanced-mlm/setup-hierarchy (with admin JWT token)"
GET /api/advanced-mlm/hierarchy-levels Get all available coach ranks
Returns list of coach ranks with names and descriptions
Body: No body required
Example:
"GET /api/advanced-mlm/hierarchy-levels"
POST /api/advanced-mlm/generate-coach-id Generate unique coach ID
Generates a unique 8-character coach ID
Body: No body required
Example:
"POST /api/advanced-mlm/generate-coach-id"
GET /api/advanced-mlm/search-sponsor Search for sponsors (digital system users only)
Search for potential sponsors by name, email, or coach ID (external sponsors removed)
Query: { "searchTerm": "string (required)", "searchType": "string (optional: \"digital\")" }
Example:
"GET /api/advanced-mlm/search-sponsor?searchTerm=john&searchType=digital"
POST /api/advanced-mlm/external-sponsor Create external sponsor (DEPRECATED)
External sponsors are no longer supported. Only digital coaches can be sponsors.
Body: { "required": [ "name", "email", "phone", "company" ], "optional": [ "website", "address", "notes" ] }
Example:
"This endpoint is deprecated - use digital coaches only"
POST /api/advanced-mlm/lock-hierarchy Lock hierarchy after first login (Coach only)
Prevents future hierarchy changes after first login
Body: { "required": [ "coachId" ] }
Example:
{
  "coachId": "507f1f77bcf86cd799439011"
}
POST /api/advanced-mlm/admin-request Submit admin request for hierarchy changes (Coach only)
Request admin approval for hierarchy modifications
Body: { "required": [ "coachId", "requestType", "reason" ], "optional": [ "requestedChanges", "priority" ] }
Example:
{
  "coachId": "507f1f77bcf86cd799439011",
  "requestType": "changeSponsor",
  "reason": "Better mentorship opportunity",
  "requestedChanges": {
    "newSponsorId": "507f1f77bcf86cd799439012"
  }
}
GET /api/advanced-mlm/admin-requests/:coachId Get admin requests for a specific coach (Coach only)
View all admin requests submitted by a specific coach
Params: { "coachId": "string (required)" }
Example:
"GET /api/advanced-mlm/admin-requests/507f1f77bcf86cd799439011"
GET /api/advanced-mlm/commissions/:coachId Get coach commissions (Coach only)
View commission earnings and calculations
Query: { "month": "string (optional: YYYY-MM format)", "year": "number (optional)" }
Params: { "coachId": "string (required)" }
Example:
"GET /api/advanced-mlm/commissions/507f1f77bcf86cd799439011?month=2024-01"
GET /api/advanced-mlm/admin/pending-requests Get all pending admin requests (Admin only)
Admin view of all pending hierarchy change requests
Body: No body required
Example:
"GET /api/advanced-mlm/admin/pending-requests (with admin JWT token)"
PUT /api/advanced-mlm/admin/process-request/:requestId Process admin request (approve/reject) (Admin only)
Approve or reject hierarchy change requests
Body: { "required": [ "action", "adminNotes" ], "optional": [ "approvedChanges" ] }
Params: { "requestId": "string (required)" }
Example:
{
  "action": "approve",
  "adminNotes": "Request approved after review",
  "approvedChanges": {
    "newSponsorId": "507f1f77bcf86cd799439012"
  }
}
PUT /api/advanced-mlm/admin/change-upline Change coach upline (Admin only)
Admin override to change coach sponsor/hierarchy
Body: { "required": [ "coachId", "newSponsorId" ], "optional": [ "reason", "effectiveDate" ] }
Example:
{
  "coachId": "507f1f77bcf86cd799439011",
  "newSponsorId": "507f1f77bcf86cd799439012",
  "reason": "Performance optimization"
}
GET /api/advanced-mlm/admin/commission-settings Get commission settings (Admin only)
View current commission structure and rates
Body: No body required
Example:
"GET /api/advanced-mlm/admin/commission-settings (with admin JWT token)"
PUT /api/advanced-mlm/admin/commission-settings Update commission settings (Admin only)
Modify commission calculations for platform subscriptions only
Body: { "required": [ "subscriptionCommissions" ], "optional": [ "levelMultipliers" ] }
Example:
{
  "subscriptionCommissions": {
    "monthly": 0.1,
    "yearly": 0.15,
    "lifetime": 0.2,
    "default": 0.1
  },
  "levelMultipliers": {
    "1": 1,
    "2": 1.1,
    "3": 1.2
  }
}
POST /api/advanced-mlm/admin/calculate-commission Calculate and create commission for subscription (Admin only)
Manually calculate commission for specific transactions
Body: { "required": [ "subscriptionId", "coachId", "amount" ], "optional": [ "commissionType", "notes" ] }
Example:
{
  "subscriptionId": "507f1f77bcf86cd799439011",
  "coachId": "507f1f77bcf86cd799439012",
  "amount": 100
}
POST /api/advanced-mlm/calculate-subscription-commission Calculate commission only on platform subscriptions (Admin only)
NEW: Calculate commission only on platform subscriptions, not all earnings
Body: { "required": [ "subscriptionId", "coachId", "subscriptionAmount" ], "optional": [ "subscriptionType", "notes" ] }
Example:
{
  "subscriptionId": "sub_123",
  "coachId": "coach_id",
  "subscriptionAmount": 99.99,
  "subscriptionType": "monthly",
  "notes": "Monthly subscription commission"
}
POST /api/advanced-mlm/admin/process-monthly-commissions Process monthly commission payments (Admin only)
Bulk process all pending commissions for a month
Body: { "required": [ "month", "year" ], "optional": [ "paymentMethod", "batchSize" ] }
Example:
{
  "month": "01",
  "year": 2024,
  "paymentMethod": "bank_transfer"
}
POST /api/advanced-mlm/downline Add a new coach to downline (Coach only)
Add new coach to your downline team
Body: { "required": [ "name", "email", "password", "sponsorId" ], "optional": [ "phone", "currentLevel", "teamRankName" ] }
Example:
{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "Passw0rd!",
  "sponsorId": "507f1f77bcf86cd799439011"
}
GET /api/advanced-mlm/downline/:sponsorId Get direct downline for a specific sponsor (Coach only)
View direct team members under a specific sponsor
Query: { "includePerformance": "boolean (optional: true/false)" }
Params: { "sponsorId": "string (required)" }
Example:
"GET /api/advanced-mlm/downline/507f1f77bcf86cd799439011?includePerformance=true"
GET /api/advanced-mlm/hierarchy/:coachId Get complete downline hierarchy (Coach only)
View complete team structure with configurable depth
Query: { "levels": "number (optional: default 5)", "includePerformance": "boolean (optional: true/false)" }
Params: { "coachId": "string (required)" }
Example:
"GET /api/advanced-mlm/hierarchy/507f1f77bcf86cd799439011?levels=10&includePerformance=true"
GET /api/advanced-mlm/team-performance/:sponsorId Get team performance summary (Coach only)
Comprehensive team performance metrics and analytics
Query: { "period": "string (optional: \"month\", \"quarter\", \"year\")", "includeInactive": "boolean (optional: true/false)" }
Params: { "sponsorId": "string (required)" }
Example:
"GET /api/advanced-mlm/team-performance/507f1f77bcf86cd799439011?period=month"
POST /api/advanced-mlm/generate-report Generate comprehensive team report (Coach only)
Create detailed performance reports with charts and insights
Body: { "required": [ "reportType", "sponsorId" ], "optional": [ "dateRange", "includeCharts", "format" ] }
Example:
{
  "reportType": "team_performance",
  "sponsorId": "507f1f77bcf86cd799439011",
  "dateRange": {
    "start": "2024-01-01",
    "end": "2024-01-31"
  }
}
GET /api/advanced-mlm/reports/:sponsorId Get list of generated reports (Coach only)
View all generated reports for a specific sponsor
Query: { "reportType": "string (optional)", "limit": "number (optional: default 20)" }
Params: { "sponsorId": "string (required)" }
Example:
"GET /api/advanced-mlm/reports/507f1f77bcf86cd799439011?reportType=team_performance"
GET /api/advanced-mlm/reports/detail/:reportId Get specific report details (Coach only)
View detailed content and data of a specific report
Params: { "reportId": "string (required)" }
Example:
"GET /api/advanced-mlm/reports/detail/507f1f77bcf86cd799439011"

🏗️ Coach Hierarchy Management

Method Endpoint Description
GET /api/coach-hierarchy/coach/:coachId Get coach hierarchy information
GET /api/coach-hierarchy/upline/:coachId Get coach upline structure
GET /api/coach-hierarchy/downline/:coachId Get coach downline structure
POST /api/coach-hierarchy/change-sponsor Request sponsor change
{
  "newSponsorId": "...",
  "reason": "Better mentorship opportunity"
}
GET /api/coach-hierarchy/requests Get hierarchy change requests
PUT /api/coach-hierarchy/requests/:requestId Process hierarchy change request
{
  "action": "approve",
  "notes": "Request approved"
}

👥 Staff Management

Method Endpoint Description
POST /api/staff Create staff under coach (verification required on first login)
{
  "name": "Assistant A",
  "email": "assistant@ex.com",
  "password": "Passw0rd!",
  "permissions": [
    "leads:view",
    "leads:update"
  ]
}
GET /api/staff List staff of coach (admin can pass ?coachId=...)
GET /api/staff/:id Get specific staff details
PUT /api/staff/:id Update staff (name, permissions, isActive)
{
  "name": "Assistant A2",
  "permissions": [
    "leads:view"
  ]
}
DELETE /api/staff/:id Deactivate staff
POST /api/staff/:id/permissions Update staff permissions
{
  "permissions": [
    "leads:view",
    "leads:write",
    "funnels:read"
  ]
}
POST /api/staff/:id/activate Activate staff account
GET /api/staff/:id/performance Get staff performance metrics
{
  "startDate": "2025-01-01",
  "endDate": "2025-01-31",
  "includeDetails": "true"
}
GET /api/staff/:id/performance/trends Get staff performance trends over time
{
  "period": "monthly",
  "months": 6
}
GET /api/staff/performance/comparison Compare performance between staff members
{
  "startDate": "2025-01-01",
  "endDate": "2025-01-31"
}
POST /api/staff/bulk-actions Perform bulk actions on staff
{
  "staffIds": [
    "staff1",
    "staff2"
  ],
  "action": "activate"
}

📅 Staff Calendar & Scheduling

Method Endpoint Description
POST /api/staff-calendar Create calendar event for staff
{
  "staffId": "staff123",
  "eventType": "task",
  "title": "Follow up call",
  "startTime": "2025-01-21T09:00Z",
  "endTime": "2025-01-21T09:30Z"
}
GET /api/staff-calendar Get calendar events (filtered by permissions)
{
  "staffId": "staff123",
  "startDate": "2025-01-21",
  "endDate": "2025-01-28"
}
GET /api/staff-calendar/:id Get specific calendar event
PUT /api/staff-calendar/:id Update calendar event
DELETE /api/staff-calendar/:id Delete calendar event
GET /api/staff-calendar/staff/:staffId/availability Get staff availability for time range
{
  "startTime": "2025-01-21T09:00Z",
  "endTime": "2025-01-21T17:00Z"
}
POST /api/staff-calendar/bulk-create Create multiple calendar events (recurring)
{
  "events": [
    {
      "staffId": "staff123",
      "eventType": "meeting",
      "title": "Weekly standup",
      "startTime": "2025-01-21T09:00Z",
      "endTime": "2025-01-21T09:30Z"
    }
  ]
}

💰 Performance & Commissions

Method Endpoint Description
POST /api/performance/record-sale Record a new sale for a coach
{
  "coachId": "...",
  "amount": 1000,
  "currency": "USD"
}
GET /api/performance/downline/:coachId Get total sales for downline coaches

⚙️ Automation Rules

Method Endpoint Description
POST /api/automation-rules Create New Automation Rule
{
  "name": "Hot lead message",
  "coachId": "...",
  "triggerEvent": "lead_temperature_changed",
  "actions": [
    {
      "type": "send_email",
      "config": {
        "message": "Hi {{leadData.name}}"
      }
    }
  ]
}
GET /api/automation-rules Get All Automation Rules
GET /api/automation-rules/:id Get Single Automation Rule
PUT /api/automation-rules/:id Update Automation Rule
{
  "isActive": false
}
DELETE /api/automation-rules/:id Delete Automation Rule
POST /api/automation-rules/:id/duplicate Duplicate automation rule
PUT /api/automation-rules/:id/toggle Toggle automation rule active status
POST /api/automation-rules/:id/test Test automation rule execution
GET /api/automation-rules/triggers Get available trigger events
GET /api/automation-rules/actions Get available action types
GET /api/automation-rules/analytics Get automation rule analytics

📁 File Upload

Method Endpoint Description
POST /api/files/upload Upload a file

🤖 AI Services

Method Endpoint Description
GET /api/ai/test-connection Test AI service connection and API keys
GET /api/ai/models Get available AI models and providers
POST /api/ai/generate-marketing-copy Generate marketing copy with AI
{
  "prompt": "Create compelling copy for a fitness program",
  "temperature": 0.8,
  "maxTokens": 500
}
POST /api/ai/generate-headlines Generate marketing headlines and CTAs
{
  "product": "12-week fitness program",
  "targetAudience": "busy professionals",
  "count": 5
}
POST /api/ai/generate-social-post Generate social media posts
{
  "coachName": "John Doe",
  "niche": "Weight Loss",
  "offer": "12-week program",
  "targetAudience": "weight loss seekers"
}
POST /api/ai/analyze-sentiment Analyze sentiment of messages
{
  "message": "I am interested in your program"
}
POST /api/ai/generate-contextual-response Generate contextual responses based on sentiment
{
  "userMessage": "How much does it cost?",
  "sentiment": "interested",
  "context": {
    "leadStage": "qualified"
  }
}
POST /api/ai/generate-sop Generate Standard Operating Procedures
{
  "taskType": "Lead Follow-up",
  "context": "Fitness coaching business"
}
POST /api/ai/generate-lead-insights Generate AI-powered lead insights
{
  "leadData": {
    "name": "Jane",
    "email": "jane@example.com",
    "source": "Facebook Ad",
    "engagement": "high"
  }
}
POST /api/ai/optimize-content Optimize content for better performance
{
  "content": "Join our fitness program",
  "targetAudience": "beginners",
  "goal": "increase conversions"
}
POST /api/ai/chat-completion Generic AI chat completion
{
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "model": "gpt-3.5-turbo",
  "temperature": 0.7
}
POST /api/leads/:leadId/generate-nurturing-sequence Generate AI-powered nurturing strategy
{
  "leadId": "...",
  "sequenceType": "warm_lead"
}
POST /api/leads/:leadId/generate-followup-message Generate AI-powered follow-up message
{
  "leadId": "...",
  "followUpType": "first_followup",
  "context": "General follow-up"
}

💡 Priority Feed & Calendar

Method Endpoint Description
GET /api/coach/daily-feed Get daily prioritized suggestions
GET /api/coach/:coachId/availability Get coach availability settings
POST /api/coach/availability Set or update coach availability
{
  "timeZone": "Asia/Kolkata",
  "workingHours": [
    {
      "dayOfWeek": 1,
      "startTime": "09:00",
      "endTime": "17:00"
    }
  ],
  "unavailableSlots": [],
  "slotDuration": 30,
  "bufferTime": 0
}
GET /api/coach/:coachId/available-slots Get bookable slots for a coach
POST /api/coach/:coachId/book Book a new appointment
{
  "leadId": "...",
  "startTime": "2025-01-21T09:00Z",
  "duration": 30,
  "notes": "Intro call",
  "timeZone": "Asia/Kolkata"
}
PUT /api/coach/appointments/:id/reschedule Reschedule an appointment
{
  "newStartTime": "2025-01-22T10:00:00Z",
  "newDuration": 45
}
DELETE /api/coach/appointments/:id Cancel an appointment
GET /api/coach/:coachId/calendar Get Calendar of Coach
POST /api/coach/booking-recovery/initiate Initiate booking recovery session
POST /api/coach/booking-recovery/cancel Cancel booking recovery session
GET /api/coach/priority-tasks Get priority tasks for today
GET /api/coach/performance-insights Get AI-powered performance insights
POST /api/coach/feedback Submit feedback for priority feed
{
  "taskId": "...",
  "rating": 5,
  "feedback": "Very helpful suggestion"
}

👤 Coach Profile Management

Method Endpoint Description
GET /api/coach-profile/me Get my coach information
PUT /api/coach-profile/:id/profile Update a coaches profile
POST /api/coach-profile/add-credits/:id Add credits to a coach account
GET /api/coach-profile/:id/portfolio Get coach portfolio details
PUT /api/coach-profile/:id/portfolio Update coach portfolio
{
  "headline": "Fitness Expert",
  "bio": "Certified personal trainer",
  "specializations": [
    "Weight Loss",
    "Muscle Building"
  ]
}
GET /api/coach-profile/:id/appointment-settings Get coach appointment settings
PUT /api/coach-profile/:id/appointment-settings Update appointment settings
{
  "availableDays": [
    "Monday",
    "Tuesday"
  ],
  "availableFromTime": "09:00",
  "availableToTime": "17:00"
}
GET /api/coach-profile/:id/lead-magnets Get coach lead magnet settings
PUT /api/coach-profile/:id/lead-magnets Update lead magnet settings

💳 Funnelseye Central Payment System

Method Endpoint Description
POST /api/funnelseye-payments/create-session Create a new payment session
{
  "amount": 999,
  "currency": "INR",
  "paymentMethod": "razorpay",
  "businessType": "product_purchase",
  "userId": "...",
  "userType": "customer",
  "productId": "...",
  "productName": "Fitness Book",
  "productDescription": "Complete fitness guide"
}
GET /api/funnelseye-payments/:paymentId Get payment details by ID
GET /api/funnelseye-payments/user/:userId Get all payments for a user
{
  "status": "completed",
  "businessType": "product_purchase",
  "page": 1,
  "limit": 10
}
POST /api/funnelseye-payments/webhook Process payment gateway webhooks (Public)
POST /api/funnelseye-payments/refund/:paymentId Process payment refund
{
  "amount": 500,
  "reason": "Customer request"
}
GET /api/funnelseye-payments/stats Get payment statistics
{
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "businessType": "product_purchase",
  "status": "completed"
}
GET /api/funnelseye-payments/health Check payment system health status
GET /api/funnelseye-payments/docs Get detailed API documentation
GET /api/funnelseye-payments/admin/payments Get all payments (Admin only)
{
  "status": "pending",
  "businessType": "commission",
  "page": 1,
  "limit": 20
}
PUT /api/funnelseye-payments/admin/payments/:paymentId/status Update payment status (Admin only)
{
  "status": "completed",
  "notes": "Payment processed successfully"
}
GET /api/funnelseye-payments/admin/gateways Get payment gateway configurations (Admin only)
PUT /api/funnelseye-payments/admin/gateways/:gatewayName Update gateway configuration (Admin only)
{
  "isEnabled": true,
  "config": {
    "keyId": "rzp_test_...",
    "keySecret": "..."
  }
}
POST /api/funnelseye-payments/admin/gateways Create new gateway configuration (Admin only)
{
  "gatewayName": "stripe",
  "isEnabled": false,
  "config": {
    "publishableKey": "pk_test_...",
    "secretKey": "sk_test_..."
  }
}
DELETE /api/funnelseye-payments/admin/gateways/:gatewayName Delete gateway configuration (Admin only)
POST /api/funnelseye-payments/admin/gateways/:gatewayName/test Test gateway connection (Admin only)

📦 Subscription Management

Method Endpoint Description
GET /api/subscriptions/plans Get available subscription plans (Public)
POST /api/subscriptions/subscribe Subscribe to a plan (Coach)
{
  "planId": "professional",
  "paymentMethod": "stripe",
  "autoRenew": true
}
POST /api/subscriptions/renew Renew subscription (Coach)
POST /api/subscriptions/cancel Cancel subscription (Coach)
{
  "reason": "User requested cancellation"
}
GET /api/subscriptions/my-subscription Get current user subscription (Coach)
POST /api/subscriptions/plans Create new subscription plan (Admin)
{
  "name": "Professional Plan",
  "price": 99,
  "features": [
    "maxFunnels: 10",
    "maxLeads: 1000"
  ]
}
PUT /api/subscriptions/plans/:id Update subscription plan (Admin)
{
  "name": "Updated Plan Name",
  "price": 129
}
DELETE /api/subscriptions/plans/:id Delete subscription plan (Admin)
POST /api/subscriptions/subscribe-coach Subscribe coach to plan (Admin)
{
  "coachId": "...",
  "planId": "professional"
}
POST /api/subscriptions/renew-coach Renew coach subscription (Admin)
POST /api/subscriptions/cancel-coach Cancel coach subscription (Admin)
GET /api/subscriptions/coach/:coachId Get specific coach subscription (Admin)
GET /api/subscriptions/all Get all coach subscriptions (Admin)
GET /api/subscriptions/analytics Get subscription analytics (Admin)
POST /api/subscriptions/send-reminders Send subscription reminders (Admin)
POST /api/subscriptions/disable-expired Disable expired subscriptions (Admin)

🛒 Shopping Cart Management

Method Endpoint Description
POST /api/cart Update shopping cart
{
  "coachId": "...",
  "leadId": "...",
  "items": [
    {
      "productId": "prod_123",
      "quantity": 1,
      "price": 99
    }
  ],
  "subtotal": 99,
  "tax": 8.91,
  "discount": 0,
  "total": 107.91
}
GET /api/cart/:cartId Get cart details
POST /api/cart/:cartId/recovery Send cart recovery notification
POST /api/cart/:cartId/complete Complete cart purchase
{
  "paymentData": {
    "method": "stripe",
    "token": "tok_123"
  }
}
GET /api/cart/coach/:coachId Get all carts for a coach
GET /api/cart/lead/:leadId Get cart for a specific lead
PUT /api/cart/:cartId/abandon Mark cart as abandoned

🤖 AI Ads Agent

Method Endpoint Description
POST /api/ai-ads/generate-copy Generate AI-powered ad copy
{
  "targetAudience": "Fitness enthusiasts 25-40",
  "productInfo": "Personal training program",
  "campaignObjective": "CONVERSIONS"
}
POST /api/ai-ads/optimize-budget/:campaignId Optimize budget allocation for campaign
GET /api/ai-ads/detect-anomalies/:campaignId Detect performance anomalies
POST /api/ai-ads/targeting-recommendations Generate targeting recommendations
{
  "targetAudience": "Weight loss seekers",
  "budget": 100
}
POST /api/ai-ads/auto-optimize/:campaignId Auto-optimize campaign performance
GET /api/ai-ads/performance-insights/:campaignId Get detailed performance insights
POST /api/ai-ads/create-optimized-campaign Create AI-optimized campaign
{
  "name": "AI Campaign",
  "objective": "CONVERSIONS",
  "targetAudience": "Fitness",
  "budget": 50,
  "productInfo": "Training program"
}
GET /api/ai-ads/dashboard Get AI ads dashboard data
POST /api/ai-ads/bulk-optimize Bulk optimize multiple campaigns
{
  "campaignIds": [
    "campaign1",
    "campaign2"
  ]
}
POST /api/ai-ads/generate-variations Generate ad variations
{
  "originalAdCopy": "Lose weight fast",
  "targetAudience": "Fitness",
  "variationCount": 5
}
POST /api/ai-ads/generate-poster Generate simple background image with AI text content and positioning instructions
{
  "coachName": "John Doe",
  "niche": "Weight Loss & Nutrition",
  "offer": "12-Week Transformation Program",
  "targetAudience": "weight_loss"
}
POST /api/ai-ads/generate-poster-variations Generate multiple background variations with text content for better selection
{
  "coachName": "John Doe",
  "niche": "Weight Loss & Nutrition",
  "offer": "12-Week Transformation Program",
  "targetAudience": "weight_loss",
  "variationCount": 3
}
POST /api/ai-ads/generate-headlines Generate AI-powered marketing headlines
{
  "coachName": "John Doe",
  "niche": "Weight Loss & Nutrition",
  "offer": "12-Week Transformation Program",
  "targetAudience": "weight_loss",
  "headlineCount": 5
}
POST /api/ai-ads/generate-social-post Generate complete social media post content
{
  "coachName": "John Doe",
  "niche": "Weight Loss & Nutrition",
  "offer": "12-Week Transformation Program",
  "targetAudience": "weight_loss"
}
POST /api/ai-ads/upload-to-instagram Upload generated content to Instagram via Meta Ads
{
  "imageUrl": "https://example.com/poster.jpg",
  "caption": "Transform your body!",
  "coachMetaAccountId": "act_123456789"
}
POST /api/ai-ads/generate-campaign Generate complete social media campaign package
{
  "coachName": "John Doe",
  "niche": "Weight_loss",
  "offer": "12-Week Transformation Program",
  "targetAudience": "weight_loss",
  "campaignDuration": 7,
  "dailyBudget": 50
}
GET /api/ai-ads/social-media-history Get social media content generation history

📋 Workflow & Task Management

Method Endpoint Description
GET /api/workflow/kanban-board Get Kanban board data
POST /api/workflow/tasks Create new task with intelligent assignment
{
  "name": "Follow up call",
  "description": "Call prospect",
  "dueDate": "2025-01-25T10:00:00Z",
  "relatedLead": "leadId",
  "priority": "HIGH",
  "stage": "LEAD_QUALIFICATION"
}
GET /api/workflow/tasks Get all tasks with filtering
{
  "status": "Pending",
  "priority": "HIGH",
  "page": 1,
  "limit": 10
}
GET /api/workflow/tasks/:id Get single task details
PUT /api/workflow/tasks/:id Update task
{
  "status": "In Progress",
  "priority": "URGENT"
}
DELETE /api/workflow/tasks/:id Delete task
PUT /api/workflow/tasks/:taskId/move Move task between stages (Kanban)
{
  "newStage": "PROPOSAL"
}
POST /api/workflow/tasks/:id/comments Add comment to task
{
  "content": "Called prospect, interested in program"
}
POST /api/workflow/tasks/:id/time-log Log time to task
{
  "startTime": "2025-01-20T09:00:00Z",
  "endTime": "2025-01-20T10:00:00Z",
  "description": "Client call"
}
POST /api/workflow/tasks/:id/subtasks Add subtask
{
  "name": "Send proposal",
  "description": "Email proposal to client"
}
GET /api/workflow/analytics Get task analytics
{
  "dateRange": 30
}
POST /api/workflow/auto-assign Auto-assign unassigned tasks
GET /api/workflow/upcoming-tasks Get upcoming tasks
{
  "days": 7
}
PUT /api/workflow/bulk-update-status Bulk update task status
{
  "taskIds": [
    "task1",
    "task2"
  ],
  "newStatus": "Completed"
}
POST /api/workflow/generate-sop Generate SOP for task type
{
  "taskType": "Lead Follow-up",
  "context": "Fitness coaching business"
}
GET /api/workflow/overdue-tasks Get overdue tasks
GET /api/workflow/tasks/stage/:stage Get tasks by stage
POST /api/workflow/tasks/from-lead/:leadId Create task from lead
{
  "taskName": "Follow up call",
  "description": "Follow up on lead inquiry"
}
GET /api/workflow/tasks/:id/dependencies Get task dependencies
POST /api/workflow/tasks/:id/dependencies Add task dependency
{
  "dependentTaskId": "...",
  "dependencyType": "blocks"
}
DELETE /api/workflow/tasks/:id/dependencies/:dependencyId Remove task dependency
POST /api/workflow/tasks/:id/dependencies Add task dependency
{
  "dependencyId": "taskId"
}
DELETE /api/workflow/tasks/:id/dependencies/:dependencyId Remove task dependency
GET /api/workflow/stages Get workflow stages configuration
PUT /api/workflow/stages Update workflow stages configuration
GET /api/workflow/templates Get workflow templates
POST /api/workflow/templates Create workflow template
POST /api/workflow/templates/:templateId/apply Apply workflow template to coach

🏆 Staff Leaderboard & Scoring

Method Endpoint Description
GET /api/staff-leaderboard/leaderboard Get staff leaderboard with rankings
GET /api/staff-leaderboard/staff/:staffId/score Get individual staff performance score
GET /api/staff-leaderboard/staff/:staffId/achievements Get staff achievements and badges
GET /api/staff-leaderboard/staff/:staffId/progress Get staff progress over time
GET /api/staff-leaderboard/team/analytics Get team performance analytics
GET /api/staff-leaderboard/team/most-improved Get most improved staff member
GET /api/staff-leaderboard/team/trends Get team performance trends
GET /api/staff-leaderboard/staff/comparison Compare staff performance
{
  "staffIds": [
    "staff1",
    "staff2"
  ]
}
GET /api/staff-leaderboard/config/ranking-levels Get ranking levels configuration
GET /api/staff-leaderboard/config/achievements Get achievements configuration
GET /api/staff-leaderboard/config/scoring-weights Get scoring weights configuration
PUT /api/staff-leaderboard/config/scoring-weights Update scoring weights
{
  "weights": {
    "taskCompletion": 0.4,
    "qualityRating": 0.3,
    "efficiency": 0.2,
    "leadership": 0.1
  }
}

👥 Staff Dashboard

Method Endpoint Description
GET /api/staff-dashboard/data Get complete staff dashboard data
{
  "timeRange": 30
}
GET /api/staff-dashboard/overview Get staff overview metrics and quick actions
GET /api/staff-dashboard/tasks Get staff tasks overview and analytics
GET /api/staff-dashboard/performance Get staff performance metrics and scoring
GET /api/staff-dashboard/achievements Get staff achievements and badges
GET /api/staff-dashboard/team Get team data and collaboration metrics
GET /api/staff-dashboard/progress Get staff progress over time
{
  "timeRange": 30
}
GET /api/staff-dashboard/comparison Compare staff performance with team
GET /api/staff-dashboard/goals Get staff goals and targets
GET /api/staff-dashboard/calendar Get staff calendar and schedule
GET /api/staff-dashboard/notifications Get staff notifications and alerts
GET /api/staff-dashboard/analytics Get staff analytics and insights
PUT /api/staff-dashboard/unified/appointments/transfer-from-coach Transfer appointment from coach to staff with meeting host permissions
{
  "appointmentId": "appointment_id",
  "staffId": "staff_id",
  "hostPermissions": {
    "hasHostAccess": true,
    "canStartMeeting": true,
    "canManageParticipants": true,
    "canShareScreen": true,
    "canRecordMeeting": false
  },
  "reason": "Coach unavailable"
}
PUT /api/staff-dashboard/unified/appointments/transfer Transfer appointment between staff members
{
  "appointmentId": "appointment_id",
  "fromStaffId": "staff_id_1",
  "toStaffId": "staff_id_2",
  "reason": "Workload redistribution"
}

💰 Coach Financial Management

Method Endpoint Description
GET /api/coach/financial/revenue Get coach revenue analytics
{
  "timeRange": 30,
  "period": "daily"
}
GET /api/coach/financial/payments Get payment history
{
  "page": 1,
  "limit": 20,
  "status": "active"
}
GET /api/coach/financial/balance Get Razorpay account balance
POST /api/coach/financial/payout Create manual payout
{
  "amount": 1000,
  "payoutMethod": "UPI",
  "upiId": "coach@paytm",
  "notes": "Monthly payout"
}
GET /api/coach/financial/payouts Get payout history
{
  "page": 1,
  "limit": 20,
  "status": "processed"
}
PUT /api/coach/financial/payout-settings Update automatic payout settings
{
  "autoPayoutEnabled": true,
  "payoutMethod": "UPI",
  "upiId": "coach@paytm",
  "minimumAmount": 500,
  "payoutFrequency": "weekly"
}
GET /api/coach/financial/mlm-commission Get MLM commission structure and history
POST /api/coach/financial/payout-to-coach Payout to another coach
{
  "targetCoachId": "coach_id",
  "amount": 500,
  "notes": "Commission payout"
}
GET /api/coach/financial/refunds Get refund history
{
  "page": 1,
  "limit": 20
}

🎛️ Admin V1 Master API

Method Endpoint Description
POST /api/admin/auth/login Admin login (unified)
{
  "email": "admin@example.com",
  "password": "password123",
  "rememberMe": true
}
POST /api/admin/auth/logout Admin logout (unified)
{
  "sessionToken": "session_token_here"
}
GET /api/admin/v1/auth/profile Get admin profile
GET /api/admin/v1/dashboard Get comprehensive admin dashboard
{
  "timeRange": 30
}
GET /api/admin/v1/analytics Get platform analytics
{
  "timeRange": 30,
  "metric": "all"
}
GET /api/admin/v1/users Get all users with filtering
{
  "page": 1,
  "limit": 20,
  "role": "user",
  "status": "active",
  "search": "john"
}
GET /api/admin/v1/users/:userId Get user details with subscriptions
PUT /api/admin/v1/users/:userId Update user status or details
{
  "status": "active",
  "coachId": "coach_id",
  "notes": "VIP client"
}
GET /api/admin/v1/financial-settings Get financial settings
PUT /api/admin/v1/financial-settings Update financial settings
{
  "razorpay": {
    "keyId": "rzp_test_..."
  },
  "platformFees": {
    "subscriptionFee": 5
  }
}
GET /api/admin/v1/financial/razorpay-account Get Razorpay account details
PUT /api/admin/v1/financial/mlm-commission-structure Update MLM commission structure
{
  "levels": [
    {
      "level": 1,
      "percentage": 10
    }
  ],
  "platformFeePercentage": 5
}
POST /api/admin/v1/financial/process-mlm-commission Process MLM commission
{
  "subscriptionId": "sub_id",
  "subscriptionAmount": 1000,
  "coachId": "coach_id"
}
GET /api/admin/v1/financial/platform-fees Get platform fee settings
PUT /api/admin/v1/financial/platform-fees Update platform fee settings
{
  "subscriptionFee": 5,
  "transactionFee": 2
}
GET /api/admin/v1/financial/analytics-dashboard Get financial analytics dashboard
{
  "timeRange": 30
}
GET /api/admin/v1/downline Get downline structure
{
  "coachId": "coach_id",
  "level": 3
}
GET /api/admin/v1/mlm-reports Get MLM commission reports
{
  "timeRange": 30,
  "coachId": "coach_id"
}
GET /api/admin/v1/platform-config Get platform configuration
PUT /api/admin/v1/platform-config Update platform configuration
{
  "general": {
    "platformName": "New Platform"
  },
  "features": {
    "mlmEnabled": true
  }
}
GET /api/admin/v1/content/plans Get all coach plans/programs
{
  "page": 1,
  "limit": 20,
  "status": "active",
  "search": "fat loss"
}
POST /api/admin/v1/content/plans Create new coach plan
{
  "name": "21-Day Fat Loss",
  "description": "Complete program",
  "price": 2999,
  "duration": 21
}
PUT /api/admin/v1/content/plans/:planId Update coach plan
{
  "price": 3999,
  "status": "active"
}
GET /api/admin/v1/messaging/settings Get messaging settings
PUT /api/admin/v1/messaging/settings Update messaging settings
{
  "whatsapp": {
    "enabled": true,
    "provider": "gupshup"
  },
  "email": {
    "enabled": true
  }
}
GET /api/admin/v1/subscription-plans Get subscription plans
GET /api/admin/v1/ai-settings Get AI settings
PUT /api/admin/v1/ai-settings Update AI settings
{
  "nutritionist": {
    "enabled": true,
    "model": "gpt-3.5-turbo"
  },
  "support": {
    "enabled": true
  }
}
GET /api/admin/v1/system/health Get system health status
GET /api/admin/v1/settings Get global platform settings
PUT /api/admin/v1/settings/:section Update global settings section
{
  "platformName": "New Platform Name",
  "defaultLanguage": "en"
}
GET /api/admin/v1/audit-logs Get audit logs with filtering
{
  "page": 1,
  "limit": 20,
  "severity": "high",
  "startDate": "2024-01-01"
}
GET /api/admin/v1/products Get all admin products
{
  "page": 1,
  "limit": 20,
  "status": "active",
  "search": "fitness"
}
POST /api/admin/v1/products Create admin product
{
  "name": "Fitness Program",
  "description": "Complete program",
  "category": "fitness",
  "basePrice": 2999
}
GET /api/admin/v1/security/incidents Get security incidents
{
  "timeRange": 7,
  "severity": "high"
}

📊 Coach Dashboard

Method Endpoint Description
GET /api/coach-dashboard/data Get complete dashboard data
GET /api/coach-dashboard/overview Get overview metrics and quick actions
GET /api/coach-dashboard/leads Get leads analytics and funnel data
GET /api/coach-dashboard/tasks Get tasks analytics and distribution
GET /api/coach-dashboard/marketing Get marketing analytics and AI insights
GET /api/coach-dashboard/financial Get financial analytics and revenue trends
GET /api/coach-dashboard/team Get team analytics and leaderboard
GET /api/coach-dashboard/performance Get performance analytics and KPIs
GET /api/coach-dashboard/widgets Get dashboard widgets configuration
GET /api/coach-dashboard/widgets/:widgetId Get specific widget data
GET /api/coach-dashboard/trends Get performance trends over time
GET /api/coach-dashboard/alerts Get performance alerts and warnings
GET /api/coach-dashboard/ai-insights Get AI-powered insights and recommendations
GET /api/coach-dashboard/kpis Get key performance indicators
GET /api/coach-dashboard/sections Get dashboard sections configuration
GET /api/coach-dashboard/real-time Get real-time dashboard updates
GET /api/coach-dashboard/export Export dashboard data
{
  "format": "csv",
  "timeRange": 30
}
GET /api/coach-dashboard/calendar Get coach calendar with appointments
GET /api/coach-dashboard/available-slots Get available booking slots
POST /api/coach-dashboard/appointments Book new appointment
{
  "leadId": "...",
  "startTime": "2025-01-21T09:00:00Z",
  "duration": 30,
  "notes": "Intro call"
}
GET /api/coach-dashboard/appointments/upcoming Get upcoming appointments
GET /api/coach-dashboard/appointments/today Get today's appointments
PUT /api/coach-dashboard/appointments/:appointmentId/reschedule Reschedule appointment
{
  "newStartTime": "2025-01-22T10:00:00Z",
  "newDuration": 45
}
DELETE /api/coach-dashboard/appointments/:appointmentId Cancel appointment
GET /api/coach-dashboard/appointments/stats Get appointment statistics
GET /api/coach-dashboard/availability Get coach availability settings
PUT /api/coach-dashboard/availability Set coach availability
{
  "timeZone": "Asia/Kolkata",
  "workingHours": [
    {
      "dayOfWeek": 1,
      "startTime": "09:00",
      "endTime": "17:00"
    }
  ],
  "slotDuration": 30
}
GET /api/coach-dashboard/zoom-meetings Get all Zoom meetings for coach
GET /api/coach-dashboard/zoom-meetings/appointment/:appointmentId Get Zoom meeting details for specific appointment

💬 Message Templates

Method Endpoint Description
POST /api/message-templates Create new message template
{
  "name": "Welcome Message",
  "type": "email",
  "category": "welcome",
  "content": {
    "body": "Hi {{lead.name}}, welcome to our program!"
  }
}
GET /api/message-templates Get all message templates for coach
GET /api/message-templates/pre-built Get pre-built message templates
GET /api/message-templates/categories Get available template categories
GET /api/message-templates/types Get available template types
GET /api/message-templates/variables Get common template variables
GET /api/message-templates/:id Get specific template details
PUT /api/message-templates/:id Update message template
DELETE /api/message-templates/:id Delete message template
POST /api/message-templates/:id/duplicate Duplicate a template
{
  "newName": "Welcome Message Copy"
}
POST /api/message-templates/:id/render Render template with variables
{
  "variables": {
    "lead.name": "John",
    "coach.name": "Sarah"
  }
}
POST /api/message-templates/seed Seed pre-built templates for coach

🔗 Zoom Integration

Method Endpoint Description
POST /api/zoom-integration/setup Setup Zoom API integration
{
  "clientId": "zoom_client_id",
  "clientSecret": "zoom_client_secret",
  "zoomEmail": "coach@example.com",
  "zoomAccountId": "zoom_account_id"
}
GET /api/zoom-integration Get Zoom integration settings
PUT /api/zoom-integration Update Zoom integration settings
POST /api/zoom-integration/test Test Zoom API connection
GET /api/zoom-integration/usage Get Zoom account usage statistics
GET /api/zoom-integration/status Get integration status and health
POST /api/zoom-integration/meeting-templates Create meeting template
{
  "name": "30-min Session",
  "duration": 30,
  "settings": {
    "join_before_host": true
  }
}
GET /api/zoom-integration/meeting-templates Get meeting templates
DELETE /api/zoom-integration Delete Zoom integration
GET /api/zoom-integration/meetings Get all Zoom meetings for coach
GET /api/zoom-integration/meetings/appointment/:appointmentId Get Zoom meeting details for specific appointment
POST /api/zoom-integration/cleanup/start Start automatic Zoom meeting cleanup
{
  "retentionDays": 2,
  "interval": "daily"
}
POST /api/zoom-integration/cleanup/stop Stop automatic Zoom meeting cleanup
POST /api/zoom-integration/cleanup/manual Perform manual Zoom meeting cleanup
{
  "retentionDays": 2
}
GET /api/zoom-integration/cleanup/stats Get Zoom cleanup statistics and status
PUT /api/zoom-integration/cleanup/retention Update Zoom cleanup retention period
{
  "retentionDays": 3
}

🎯 Lead Magnets

Method Endpoint Description
GET /api/lead-magnets/coach Get coach lead magnet settings
PUT /api/lead-magnets/coach Update coach lead magnet settings
POST /api/lead-magnets/ai-diet-plan Generate AI diet plan
POST /api/lead-magnets/bmi-calculator Calculate BMI with recommendations
POST /api/lead-magnets/ebook-generator Generate personalized e-book content
POST /api/lead-magnets/workout-calculator Calculate workout metrics (1RM, heart rate)
POST /api/lead-magnets/progress-tracker Track fitness progress and analytics
POST /api/lead-magnets/sleep-analyzer Analyze sleep quality and get recommendations
POST /api/lead-magnets/stress-assessment Assess stress levels and get coping strategies
GET /api/lead-magnets/available Get all available lead magnets
GET /api/lead-magnets/analytics Get lead magnet performance analytics
GET /api/lead-magnets/history/:leadId Get lead magnet interaction history

🌐 Public Funnel Pages

Method Endpoint Description
GET /funnels/:funnelSlug/:pageSlug Render a public funnel page

👑 Admin Management

Method Endpoint Description
POST /api/admin/auth/login Admin login
POST /api/admin/auth/logout Admin logout
GET /api/admin/auth/me Get current admin user
GET /api/admin/settings Get platform settings
PUT /api/admin/settings Update platform settings
GET /api/admin/settings/credit-system Get credit system configuration
PUT /api/admin/settings/credit-system Update credit system configuration
GET /api/admin/users Get all users (Admin)
GET /api/admin/users/:userId Get specific user details (Admin)
PUT /api/admin/users/:userId Update user (Admin)
DELETE /api/admin/users/:userId Delete user (Admin)
POST /api/admin/users/:userId/activate Activate user account (Admin)
POST /api/admin/users/:userId/deactivate Deactivate user account (Admin)
GET /api/admin/logs Get system logs (Admin)
GET /api/admin/logs/errors Get error logs (Admin)
GET /api/admin/logs/access Get access logs (Admin)
GET /api/admin/logs/audit Get audit logs (Admin)
GET /api/admin/analytics/platform Get platform-wide analytics (Admin)
GET /api/admin/analytics/users Get user analytics (Admin)
GET /api/admin/analytics/revenue Get revenue analytics (Admin)
GET /api/admin/analytics/performance Get performance analytics (Admin)
GET /api/admin/financial/credit-system Get credit system configuration (Admin)
PUT /api/admin/financial/credit-system Update credit system configuration (Admin)
GET /api/admin/financial/credit-packages Get credit packages (Admin)
GET /api/admin/financial/revenue-analytics Get revenue analytics (Admin)
GET /api/admin/financial/payment-failures Get payment failure analytics (Admin)
GET /api/admin/financial/gateway-markup Get gateway markup analytics (Admin)
GET /api/admin/financial/credit-usage Get credit usage analytics (Admin)
GET /api/admin/financial/payment-settings Get payment settings (Admin)
PUT /api/admin/financial/payment-settings Update payment settings (Admin)
GET /api/admin/financial/commission-payouts Get commission payouts (Admin)
POST /api/admin/financial/commission-payouts/:paymentId/process Process commission payout (Admin)
GET /api/admin/financial/payment-gateways Get payment gateway configurations (Admin)
PUT /api/admin/financial/payment-gateways/:gatewayName Update payment gateway configuration (Admin)
POST /api/admin/financial/payment-gateways/:gatewayName/test Test payment gateway (Admin)
GET /api/admin/financial/payment-analytics Get payment analytics (Admin)
GET /api/admin/financial/razorpay-account Get Razorpay account details and balance (Admin)
PUT /api/admin/financial/mlm-commission-structure Update MLM commission structure (Admin)
{
  "levels": [
    {
      "level": 1,
      "percentage": 10
    },
    {
      "level": 2,
      "percentage": 5
    }
  ],
  "platformFeePercentage": 5,
  "maxLevels": 3,
  "autoPayoutEnabled": true,
  "payoutThreshold": 100
}
POST /api/admin/financial/process-mlm-commission Process MLM commission for subscription (Admin)
{
  "subscriptionId": "sub_id",
  "subscriptionAmount": 1000,
  "coachId": "coach_id"
}
GET /api/admin/financial/platform-fees Get platform fee settings (Admin)
PUT /api/admin/financial/platform-fees Update platform fee settings (Admin)
{
  "subscriptionFee": 5,
  "transactionFee": 2,
  "payoutFee": 1,
  "refundFee": 0.5
}
GET /api/admin/financial/analytics-dashboard Get comprehensive financial analytics dashboard (Admin)
{
  "timeRange": 30
}

📢 Marketing & Advertising

Method Endpoint Description
GET /api/ads List all ad campaigns for coach
POST /api/ads/create Create a new ad campaign
{
  "coachMetaAccountId": "123456789",
  "campaignData": {
    "name": "My Campaign",
    "objective": "LEAD_GENERATION",
    "budget": 100
  }
}
POST /api/ads/sync Sync campaigns from Meta to DB
{
  "coachMetaAccountId": "123456789"
}
PUT /api/ads/:campaignId Update an ad campaign
{
  "name": "Updated Name",
  "budget": 200
}
POST /api/ads/:campaignId/pause Pause an ad campaign
POST /api/ads/:campaignId/resume Resume an ad campaign
GET /api/ads/:campaignId/analytics Get analytics/insights for a campaign
POST /api/ads/upload-image Upload image and get Meta image hash
{
  "imageUrl": "https://example.com/image.jpg"
}
POST /api/ads/:campaignId/ad-sets Create ad set for targeting and budget
{
  "name": "Target Audience",
  "targeting": {
    "age_min": 25,
    "age_max": 45,
    "geo_locations": {
      "countries": [
        "US"
      ]
    }
  },
  "daily_budget": 2500
}
POST /api/ads/:campaignId/creatives Create ad creative with image and text
{
  "name": "Website Creative",
  "object_story_spec": {
    "link_data": {
      "link": "https://yourwebsite.com",
      "message": "Check out our amazing program!",
      "image_hash": "abc123...",
      "call_to_action": {
        "type": "LEARN_MORE"
      }
    }
  }
}
POST /api/ads/:campaignId/ads Create ad that combines ad set and creative
{
  "name": "Website Traffic Ad",
  "adset_id": "adset_456",
  "creative": {
    "creative_id": "creative_789"
  },
  "status": "PAUSED"
}
GET /api/ads/:campaignId/ad-sets List ad sets for a campaign
GET /api/ads/:campaignId/creatives List ad creatives for a campaign
GET /api/ads/:campaignId/ads List ads for a campaign
DELETE /api/ads/:campaignId Delete ad campaign
GET /api/ads/coach/:coachId Get all ads for specific coach
GET /api/ads/analytics/overview Get overall ads analytics
POST /api/ads/bulk-actions Perform bulk actions on campaigns
{
  "campaignIds": [
    "camp1",
    "camp2"
  ],
  "action": "pause"
}
POST /api/ads/create-url-campaign Create complete URL campaign (all-in-one)
{
  "coachMetaAccountId": "123456789",
  "campaignData": {
    "name": "Website Traffic Q1",
    "objective": "LINK_CLICKS",
    "status": "PAUSED",
    "daily_budget": 5000
  },
  "adSetData": {
    "name": "Target Audience",
    "targeting": {
      "age_min": 25,
      "age_max": 45,
      "geo_locations": {
        "countries": [
          "US"
        ]
      }
    },
    "daily_budget": 2500,
    "billing_event": "IMPRESSIONS",
    "optimization_goal": "LINK_CLICKS"
  },
  "creativeData": {
    "name": "Website Creative",
    "object_story_spec": {
      "link_data": {
        "link": "https://yourfitnesswebsite.com",
        "message": "Transform your fitness journey today!",
        "image_hash": "abc123...",
        "call_to_action": {
          "type": "LEARN_MORE"
        }
      }
    }
  },
  "adData": {
    "name": "Website Traffic Ad",
    "status": "PAUSED"
  }
}

🚀 Marketing V1 API (Comprehensive)

Method Endpoint Description
GET /api/marketing/v1/credentials/meta/setup-steps Get detailed Meta API setup instructions
GET /api/marketing/v1/credentials/openai/setup-steps Get detailed OpenAI setup instructions
POST /api/marketing/v1/credentials/meta Setup Meta API credentials for coach
{
  "accessToken": "EAABwzLixnjYBO...",
  "appId": "123456789",
  "appSecret": "abc123...",
  "businessAccountId": "123456789",
  "adAccountId": "act_123456789"
}
POST /api/marketing/v1/credentials/meta/verify Verify Meta API credentials
GET /api/marketing/v1/credentials/meta/account-info Get Meta account information
POST /api/marketing/v1/credentials/openai Setup OpenAI credentials for AI features
{
  "apiKey": "sk-...",
  "modelPreference": "gpt-4"
}
GET /api/marketing/v1/credentials/status Get marketing credentials status
GET /api/marketing/v1/campaigns/analysis Get comprehensive campaign analysis
{
  "dateRange": "30d",
  "campaignIds": "camp1,camp2",
  "includeInsights": true,
  "includeRecommendations": true
}
GET /api/marketing/v1/campaigns/:campaignId/insights Get detailed campaign insights
{
  "dateRange": "30d",
  "breakdown": "daily",
  "includeDemographics": true,
  "includePlacements": true
}
GET /api/marketing/v1/campaigns/:campaignId/metrics Get campaign performance metrics
{
  "dateRange": "30d",
  "metrics": "impressions,clicks,spend,ctr,cpc,cpm,conversions"
}
GET /api/marketing/v1/campaigns/:campaignId/audience-insights Get campaign audience insights
{
  "dateRange": "30d"
}
GET /api/marketing/v1/campaigns/:campaignId/recommendations Get campaign optimization recommendations
{
  "includeAIRecommendations": true
}
POST /api/marketing/v1/campaigns/create Create new campaign with AI assistance
{
  "name": "AI Campaign",
  "objective": "CONVERSIONS",
  "budget": 50,
  "targetAudience": "Fitness enthusiasts 25-45",
  "productInfo": "Online fitness coaching program",
  "useAI": true,
  "autoOptimize": false
}
PUT /api/marketing/v1/campaigns/:campaignId Update campaign settings
{
  "name": "Updated Campaign",
  "status": "ACTIVE",
  "dailyBudget": 75
}
POST /api/marketing/v1/campaigns/:campaignId/pause Pause campaign
POST /api/marketing/v1/campaigns/:campaignId/resume Resume campaign
DELETE /api/marketing/v1/campaigns/:campaignId Delete campaign
POST /api/marketing/v1/campaigns/:campaignId/duplicate Duplicate campaign
{
  "newName": "Campaign Copy",
  "modifications": {
    "budget": 60,
    "targetAudience": "Updated audience"
  }
}
POST /api/marketing/v1/ai/generate-copy Generate AI-powered ad copy
{
  "productInfo": "Online fitness coaching",
  "targetAudience": "Fitness enthusiasts 25-45",
  "campaignObjective": "CONVERSIONS",
  "tone": "motivational",
  "length": "medium",
  "includeCallToAction": true
}
POST /api/marketing/v1/ai/targeting-recommendations Generate AI-powered targeting recommendations
{
  "targetAudience": "Fitness enthusiasts",
  "budget": 50,
  "objective": "CONVERSIONS",
  "productInfo": "Online fitness coaching",
  "excludeAudiences": [
    "competitors"
  ]
}
POST /api/marketing/v1/ai/optimize-campaign/:campaignId Optimize campaign with AI
{
  "optimizationType": "performance",
  "includeBudgetOptimization": true,
  "includeAudienceOptimization": true,
  "includeCreativeOptimization": true
}
POST /api/marketing/v1/ai/generate-creatives Generate AI-powered creative variations
{
  "baseCreative": "Transform your fitness journey",
  "productInfo": "Online fitness coaching",
  "targetAudience": "Fitness enthusiasts",
  "variations": 3,
  "includeImages": false,
  "includeVideos": false
}
GET /api/marketing/v1/ai/performance-insights/:campaignId Get AI-powered performance insights
{
  "dateRange": "30d",
  "includePredictions": true,
  "includeTrends": true,
  "includeAnomalies": true
}
POST /api/marketing/v1/ai/generate-strategy Generate AI-powered marketing strategy
{
  "businessInfo": "Online fitness coaching business",
  "goals": "Increase conversions by 50%",
  "budget": 1000,
  "timeline": "3 months",
  "targetAudience": "Fitness enthusiasts 25-45",
  "competitors": [
    "competitor1",
    "competitor2"
  ]
}
GET /api/marketing/v1/dashboard Get marketing dashboard data
{
  "dateRange": "30d",
  "includeAIInsights": true,
  "includeRecommendations": true
}
GET /api/marketing/v1/campaigns/performance-summary Get campaign performance summary
{
  "dateRange": "30d",
  "campaignIds": "camp1,camp2",
  "includeComparisons": true
}
GET /api/marketing/v1/campaigns/export Export campaign data
{
  "format": "csv",
  "dateRange": "30d",
  "campaignIds": "camp1,camp2",
  "includeInsights": true
}
POST /api/marketing/v1/campaigns/:campaignId/schedule Schedule campaign
{
  "startDate": "2024-01-01T00:00:00Z",
  "endDate": "2024-01-31T23:59:59Z",
  "timezone": "UTC",
  "budgetSchedule": {
    "dailyBudget": 50
  }
}
POST /api/marketing/v1/campaigns/:campaignId/automation Set up campaign automation rules
{
  "rules": [
    {
      "condition": "ctr < 1%",
      "action": "pause_campaign"
    }
  ],
  "notifications": true,
  "autoOptimize": false
}
GET /api/marketing/v1/campaigns/:campaignId/automation/status Get automation status

🧮 Lead Scoring & Tracking

Method Endpoint Description
GET /api/lead-scoring/email-opened Track email open (tracking pixel, use ?leadId=LEAD_ID)
GET /api/lead-scoring/link-clicked Track link click and redirect (use ?leadId=LEAD_ID&target=URL)
POST /api/lead-scoring/form-submitted Track form submission ({ leadId })
POST /api/lead-scoring/call-booked Track call/meeting booking ({ leadId })
POST /api/lead-scoring/call-attended Track attended call ({ leadId })
POST /api/lead-scoring/profile-completed Track profile completion ({ leadId })
POST /api/lead-scoring/lead-magnet-converted Track lead magnet conversion ({ leadId })
POST /api/lead-scoring/followup-added Track follow-up note added ({ leadId })
POST /api/lead-scoring/booking-recovered Track booking recovery ({ leadId })
POST /api/lead-scoring/inactivity-decay Track inactivity decay ({ leadId })
POST /api/lead-scoring/unsubscribed Track unsubscribe event ({ leadId })
POST /api/lead-scoring/email-bounced Track email bounce event ({ leadId })

🚀 NEW: COMPREHENSIVE COACH DASHBOARD FEATURES

Method Endpoint Description
INFO 📅 Calendar & Appointment System Complete appointment booking, scheduling, and calendar management with conflict detection and reminders
INFO 🛒 E-commerce & Payment Processing Multi-gateway payment processing (Stripe, PayPal, Razorpay), subscription management, shopping cart, and revenue analytics
INFO 🤖 AI Integration Sentiment analysis, lead qualification, performance insights, and automated content generation
INFO ⚡ Automation Engine Event-driven automation with RabbitMQ integration for seamless workflow orchestration
INFO 📊 Advanced Analytics Comprehensive dashboard with real-time metrics, performance tracking, and business intelligence
INFO 🔗 Integration Hub Seamless integration with existing automation rules, lead nurturing, and marketing campaigns