# API Reference Source: https://docs.winstory.io/advanced/api-reference High-level overview of the main REST API endpoints used by Winstory.io. ## Overview This page documents the **most important REST endpoints** exposed by `app.winstory.io`.\ It is intended for **internal engineering use** and for agency partners who need to integrate directly. Base URL: `https://app.winstory.io/api` Authentication: * Most endpoints used by the app are **server-side** and authenticated via **Supabase JWT** (handled internally). * Public endpoints are explicitly marked below. > Full OpenAPI/Swagger generation is planned as a next step. This page is the canonical source of truth until then. ## Campaigns ### `GET /campaigns/moderation` Fetch moderation data for one campaign or all campaigns of a creator. Query params: * `campaignId` (optional): string — specific campaign * `walletAddress` (optional): string — creator wallet * `page` / `pageSize` (optional): server-side pagination when querying by `walletAddress` Response: * `moderationData[]` with: * `campaignId`, `campaignTitle`, `campaignStatus`, `creatorType`, `campaignType` * `progress` (votes, staking, hybrid score) * `sessions[]` (individual moderator votes) * `blockchainMapping` (on-chain mapping info) ### `GET /campaigns/dashboard?campaignId={id}` Unified dashboard endpoint used by the **Validated Campaign** view. Returns: * `metrics` (ROI, completions, validated/refused history, vote history) * `platformFeeInfo` * `validationStatus` ### `GET /campaigns/metrics?campaignId={id}` Detailed metrics for a single campaign.\ Used internally by `metricsService` and `CampaignEconomics`. ### `GET /campaigns/metrics/batch?campaignIds=a,b,c` Batch metrics endpoint (used by MyWin/Creations): * Input: comma-separated list of `campaignIds` * Output: `{ metrics: Record, errors?: Record }` ### `POST /campaigns` Campaign creation endpoint (`/campaigns/create` in the codebase): * Validates pricing, duration, rewards, and payment * For B2C/Agency, **crypto/Stripe payment must be verified** before creation in production ## Completions ### `GET /completions/community-completions` Public endpoint used by community moderation tooling.\ Returns a curated list of completions with moderation and reward data. ### `POST /completions/submit` Create a new completion for a given campaign (B2C or Individual): * Validates user authentication * Validates that the campaign is open and budget is available * Handles payment (if required) ### `GET /completions/details?completionId={id}` Returns full moderation/score details for a single completion. ## Rewards ### `GET /rewards/individual/distribution-status` Returns detailed reward distribution status for **individual** campaigns: * Rankings, expected vs actual amounts * On-chain distribution status and tx hashes ### `GET /campaigns/[id]/rewards-monitoring` B2C/Agency reward monitoring endpoint used by the **Rewards Monitoring** dashboard. ## Short Links ### `GET /campaigns/short-link?campaignId={id}&devMode={true|false}` Returns or creates a **short completion link** for a campaign. * In production, only available when the campaign is **fully validated** * In development, `devMode=true` bypasses validation for faster testing ### `GET /campaigns/short-link/redirect?shortCode={code}` Resolves a short code to the full completion URL.\ Used by `https://app.winstory.io/c/{code}`. ## Cron & Monitoring ### `GET /cron/monitor-resources` Periodic resource monitoring (CPU, DB connections, storage).\ Configured via `vercel.json` cron. ### `GET /cron/monitor-onchain` On-chain consistency checker: * Samples recent crypto payments * Verifies on-chain status via RPC * Logs anomalies into `system_error_logs` # Architecture Overview Source: https://docs.winstory.io/advanced/architecture High-level technical architecture of Winstory.io and B2C/Agency flows. ## High-Level Architecture Winstory.io is a **Next.js 15** application with: * **App Router** for the main web app (`/app`) * **Mintlify** docs for `docs.winstory.io` * **Supabase** for database, auth, and storage * **Thirdweb** for blockchain integration (Base Sepolia / Base mainnet) ### Core Components * **Frontend**: Next.js (React, TypeScript) * **Backend**: Next.js API routes (edge & node runtimes) * **Database**: Supabase Postgres * **Blockchain**: Smart contracts (`WinstoryCampaigns.sol`, reward vaults) * **Monitoring**: Supabase `system_error_logs`, email alerts, cron jobs ## B2C/Agency Campaign Flow 1. **Campaign creation** * Route: `POST /api/campaigns/create` * Validates input, pricing config, and rewards * Verifies payment (Stripe or crypto) before persisting campaign 2. **Moderation (hybrid)** * Tables: `moderation_progress`, `moderation_votes` * Logic: `lib/moderation-engine.ts` 3. **Validation & activation** * Campaign status transitions to `APPROVED` * Short link becomes available (for B2C/Agency & Individual) 4. **Completions & rewards** * Completions: `/api/completions/submit` * Rewards: `reward_distributions`, reward vaults on-chain ## Data Flow: MyWin/Creations * **Listing**: `/api/campaigns/moderation?walletAddress=...` * Includes moderation progress, sessions, blockchain mapping, and agency info * Supports server-side pagination via `page` / `pageSize` * **Dashboard**: `/api/campaigns/dashboard?campaignId=...` * Returns aggregated metrics for a single campaign * **Metrics batch**: `/api/campaigns/metrics/batch` * Returns metrics for up to N campaigns in one call ## Error Handling & Monitoring * **Error logger**: `lib/error-logger.ts` * Functions: `logError`, `logApiError`, `resolveError` * Stores errors in `system_error_logs` * **Alerts**: `lib/alert-service.ts` * Sends email alerts for critical errors * **Cron jobs**: * `/api/cron/monitor-resources` — infra & quotas * `/api/cron/check-error-alerts` — error summaries * `/api/cron/monitor-onchain` — on-chain consistency ## Rate Limiting & Protection * **Middleware**: `middleware.ts` * Simple per-IP + path rate limiting for `/api/*` and `/c/*` * Intended as a baseline; should be complemented by WAF / external rate limiter in production ## Future Improvements * Full OpenAPI/Swagger spec generated from source * Central distributed tracing (OpenTelemetry) exported to Grafana/Datadog * Dedicated metrics pipeline for business KPIs (completion funnel, ROI per segment) # Authentication Source: https://docs.winstory.io/getting-started/authentication Learn about Winstory's authentication system using professional email verification # Authentication Winstory uses a secure authentication system that combines wallet connection with professional email verification. ## How It Works Winstory authentication has two steps: 1. **Wallet Connection**: Connect your crypto wallet (MetaMask, Coinbase Wallet, etc.) 2. **Email Verification**: Verify your identity with a professional email address ## Professional Email Requirement Winstory requires a **professional email address** for authentication. This helps ensure: * ✅ Account security * ✅ Spam prevention * ✅ Community quality * ✅ Business verification ### Accepted Email Domains Any email address from a **professional domain** is accepted. Examples: * ✅ `yourname@company.com` * ✅ `user@agency.io` * ✅ `contact@startup.co` * ✅ `team@organization.org` ### Blocked Email Domains Personal email providers are **not accepted**: * ❌ gmail.com * ❌ yahoo.com * ❌ hotmail.com * ❌ outlook.com * ❌ icloud.com * ❌ protonmail.com * ❌ aol.com * ❌ mail.com * ❌ live.com * ❌ msn.com If you don't have a professional email, you'll need to create one or use your company/agency email address. ## Authentication Flow ### Step 1: Connect Wallet 1. Visit [winstory.io](https://winstory.io) 2. Click **"Connect Wallet"** 3. Select your wallet provider 4. Approve the connection in your wallet ### Step 2: Enter Email 1. After wallet connection, you'll see the email authentication screen 2. Enter your **professional email address** 3. Click "Send Verification Code" The system validates your email domain before sending the code. Invalid domains are rejected immediately. ### Step 3: Verify Code 1. Check your email inbox 2. Enter the 6-digit verification code 3. Click "Verify" ### Step 4: You're In! Once verified, you're authenticated and can: * Create campaigns (creators) * Complete stories (completers) * Moderate content (moderators) * Access your MyWin dashboard ## Authentication Methods Winstory uses **Thirdweb** for authentication, which supports: * **Email Magic Link**: Receive a code via email * **OAuth Providers**: Google, Microsoft (for professional accounts) * **Wallet Signatures**: Cryptographic signatures from your wallet ## Session Management ### Automatic Login Once authenticated, your session is saved. You'll stay logged in until: * You disconnect your wallet * You clear browser data * Session expires (after 30 days of inactivity) ### Logout To logout: 1. Click your profile icon 2. Select "Disconnect Wallet" 3. Confirm logout ## Security Features ### Email Verification * ✅ One-time verification codes (expire after 10 minutes) * ✅ Rate limiting to prevent abuse * ✅ Domain validation before code sending ### Wallet Security * ✅ Cryptographic signatures (no passwords needed) * ✅ Private keys never leave your wallet * ✅ Transaction signing required for sensitive actions ### Account Protection * ✅ Email required for all actions * ✅ Wallet address linked to email * ✅ Suspicious activity detection ## Troubleshooting ### Email Not Received 1. **Check Spam Folder**: Verification emails sometimes go to spam 2. **Wait a Few Minutes**: Email delivery can take 1-2 minutes 3. **Verify Email Address**: Double-check you entered the correct email 4. **Check Domain**: Ensure your email domain is professional (not blocked) ### Code Expired Verification codes expire after 10 minutes. If expired: 1. Click "Resend Code" 2. Enter the new code you receive ### Invalid Email Domain If you see "Invalid email domain": * Your email is from a blocked provider (Gmail, Yahoo, etc.) * Use a professional email address instead * Contact support if you believe this is an error ### Wallet Connection Issues See our [Wallet Setup Guide](/getting-started/wallet-setup) for wallet troubleshooting. ## Best Practices * ✅ Use a professional email you can access regularly * ✅ Keep your wallet secure (never share private keys) * ✅ Enable 2FA on your email account * ✅ Verify you're on winstory.io (check the URL) * ❌ Don't share your verification codes * ❌ Don't use personal email addresses ## Next Steps Now that you're authenticated: * [Create Your First Campaign](/for-creators/campaign-creation) (creators) * [Explore Campaigns](/for-completers/explorer) (completers) * [Start Moderating](/features/moderation) (moderators) ## Need Help? * [FAQ](/support/faq) * [Troubleshooting](/support/troubleshooting) * [Contact Support](/support/contact) # Introduction to Winstory Source: https://docs.winstory.io/getting-started/introduction Learn about Winstory, the co-creative storytelling platform where creators and communities collaborate # Welcome to Winstory Winstory is a **co-creative storytelling platform** that revolutionizes how brands, agencies, and creators collaborate with communities to create engaging video campaigns. ## What is Winstory? Winstory enables three key user types to collaborate: * **Creators** (B2C Companies, Agencies, Individuals) launch video campaigns with customizable rewards * **Completers** contribute their creativity by completing story prompts and earn rewards * **Moderators** ensure quality through a decentralized moderation system ## Key Concepts ### Campaign Types Companies create campaigns with rewards for community completions Agencies create campaigns on behalf of their clients Individual creators launch their own campaigns ### Core Features Discover and browse active campaigns. Swipe through winStories, filter by type, and complete campaigns directly from the Explorer. Your personal dashboard to track campaigns, completions, rewards, earnings, and XP progress. Decentralized moderation where community members vote on campaign quality and completions. Earn rewards for accurate moderation. Multiple reward types: Standard (immediate), Premium (Top 3), Access (Digital/Physical), and Token rewards (ERC20, ERC1155, ERC721). Earn Experience Points (XP) for actions like creating campaigns, completing stories, moderating, and staking. Level up and unlock achievements. Built on Base Sepolia (testnet) with smart contracts for campaign minting, reward distribution, and staking. ## How It Works ### For Creators 1. **Create a Campaign** - Choose your campaign type (B2C, Agency, or Individual) 2. **Set Rewards** - Configure standard and premium rewards 3. **Submit for Moderation** - Community moderators review your campaign 4. **Launch** - Once approved, your campaign goes live in the Explorer 5. **Track Performance** - Monitor completions, rewards distribution, and economics ### For Completers 1. **Explore** - Browse active campaigns in the Explorer 2. **Complete** - Submit your creative completion of the story prompt 3. **Moderation** - Your completion is reviewed by moderators 4. **Earn Rewards** - Receive standard rewards immediately, premium if you're in Top 3 5. **Claim** - Claim your rewards (tokens, items, or access codes) ### For Moderators 1. **Stake** - Stake USDC tokens to participate in moderation 2. **Vote** - Review and vote on campaigns and completions 3. **Earn** - Receive rewards based on participation and accuracy 4. **Build Reputation** - Increase your moderator reputation score ## Getting Started Ready to start? Follow these guides: Get up and running in minutes Connect your wallet to Winstory Launch your first campaign Start completing campaigns ## Need Help? * Check our [FAQ](/support/faq) for common questions * Visit [Troubleshooting](/support/troubleshooting) for technical issues * [Contact Support](/support/contact) for personalized help *** **Welcome to Neo-Storytelling. Welcome to Winstory.** 🎬✨ # Litepaper Source: https://docs.winstory.io/getting-started/litepaper