Admin Training

Platform administration: conversions, revenue, outreach, and monitoring.

Admin authentication is separate from the OTP system. All admin endpoints require the X-Admin-Key header.

X-Admin-Key: your-admin-api-key

How It Works

  • No JWT needed — admin uses a static API key
  • The key is set via the ADMIN_API_KEY environment variable
  • Every admin endpoint validates this header before processing
  • Missing or incorrect key returns 401 Unauthorized
The admin key should be treated as a secret. Never expose it in client-side code or public repositories.

Manually process a conversion (e.g. from a manual sale or reconciliation):

POST /api/clipdesk/admin/conversions/process

Required body:

  • affiliate_code — the clipper's unique code for that campaign
  • sale_amount — the total sale amount in ZAR
  • currency — typically ZAR

What Happens

  1. System looks up the clipper_campaign record by affiliate code
  2. Commission splits are calculated: 20% clipper, 10% platform, 70% client
  3. Records created in: conversions, commissions, platform_revenue
  4. World Model events emitted for intelligence tracking
  5. All writes are transactional — atomic success or failure
Duplicate conversions are prevented by unique constraints on sale_id. Safe to retry on network errors.

View platform-wide revenue analytics:

GET /api/clipdesk/admin/revenue

Returns:

  • platformRevenue — total ViralVid 10% share earned
  • totalCommissionsPaid — total paid out to clippers (20% shares)
  • totalConversions — number of conversions processed
  • totalSalesVolume — gross sales through the platform

Use this for financial reporting, reconciliation with Whop, and business metrics.

View all campaigns across all clients:

GET /api/clipdesk/admin/campaigns

Each campaign record includes:

  • Campaign name and product details
  • Client/business name
  • Number of clippers who've joined
  • Number of conversions
  • Status (active/inactive)

Use this to monitor marketplace health and identify top-performing campaigns.

Generate industry-specific pitches for potential clients:

POST /api/clipdesk/admin/outreach/pitch

Required body:

  • industry — target industry (e.g. health, beauty, fitness, education)
  • businessName — prospect company name
  • contactName — person to address
  • email — contact email

What You Get

  • An industry-tailored pitch message ready to send
  • Outreach logged in the outreach table for tracking
  • Follow-up status tracking
Pitches are generated using industry-specific templates. The more specific the industry, the better the pitch.

Whop sends webhooks to ClipDesk on successful payments:

POST /api/clipdesk/whop/webhook (public, no auth)

Webhook Flow

  1. Whop sends payment.succeeded event
  2. Payload includes metadata: clipper_campaign_id, affiliate_code
  3. System looks up the clipper_campaign record
  4. Calls processConversion() to split and record commissions
  5. Returns { received: true }

Error Handling

  • Failures return 400 (not 5xx) to prevent Whop retries that could cause double-processing
  • All events are logged with WHOP_CONVERSION_PROCESSED tag
  • Includes timestamp, paymentId, and amount in logs

Additional Whop Endpoints

POST /api/clipdesk/whop/checkout — Create checkout link
POST /api/clipdesk/whop/checkout-config — Embedded checkout config

Health Check

GET /api/clipdesk/health

Returns:

  • Database connection status
  • Phi verification (confirms 1.618033988875 is active)
  • Server uptime
  • Timestamp
  • Commission split configuration

Structured Logging

The platform uses structured JSON logging for all events:

  • WHOP_CONVERSION_PROCESSED — webhook conversion completed
  • CLIP_QUALIFIED / CLIP_REJECTED — phi scoring results
  • COMMISSION_EARNED — payout recorded
  • CAMPAIGN_CREATED — new campaign activated

Database Monitoring

  • Pool size: max 10 concurrent connections
  • Idle timeout: 30 seconds
  • Connection timeout: 5 seconds (fail-fast)
  • Graceful shutdown: 10-second drain before forced exit
Monitor the health endpoint regularly. If the DB status shows errors, check the PostgreSQL connection immediately.