{"openapi":"3.0.3","info":{"title":"Exactor Cloud API","description":"High-performance API for the Exactor Engine. Proprietary boolean logic minimization with O(n) linear complexity. Supports native XOR, AND, OR, and NOT operations for synthesis up to 64 variables.","license":{"name":""},"version":"1.0.0"},"paths":{"/api/admin/marketplace/{id}":{"delete":{"tags":["handlers::admin"],"summary":"Delete a marketplace item (Admin only)","operationId":"delete_marketplace_item","parameters":[{"name":"id","in":"path","description":"Item ID","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Marketplace item deleted successfully"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden (Admin only)"},"500":{"description":"Internal server error"}},"security":[{"bearer_auth":[]}]}},"/api/admin/stats":{"get":{"tags":["handlers::admin"],"summary":"Get global system statistics (Admin only)","operationId":"get_system_stats","responses":{"200":{"description":"System statistics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminStats"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden (Admin only)"}},"security":[{"bearer_auth":[]}]}},"/api/admin/users":{"get":{"tags":["handlers::admin"],"summary":"List all users (Admin only)","operationId":"list_users","responses":{"200":{"description":"List of all users","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/User"}}}}},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden (Admin only)"}},"security":[{"bearer_auth":[]}]}},"/api/admin/users/{id}":{"put":{"tags":["handlers::admin"],"summary":"Update user subscription plan (Admin only)","operationId":"update_user_plan","parameters":[{"name":"id","in":"path","description":"User ID","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUserPlanRequest"}}},"required":true},"responses":{"200":{"description":"User plan updated successfully"},"401":{"description":"Unauthorized"},"403":{"description":"Forbidden (Admin only)"},"500":{"description":"Internal server error"}},"security":[{"bearer_auth":[]}]}},"/api/auth/api-keys":{"get":{"tags":["handlers::apikeys"],"summary":"List user API keys","operationId":"list_api_keys","responses":{"200":{"description":"List of user API keys","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ApiKeyDto"}}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]},"post":{"tags":["handlers::apikeys"],"summary":"Create a new API key","operationId":"create_api_key","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateApiKeyRequest"}}},"required":true},"responses":{"200":{"description":"API key created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateApiKeyResponse"}}}},"401":{"description":"Unauthorized"},"429":{"description":"API key limit reached"}},"security":[{"bearer_auth":[]}]}},"/api/auth/api-keys/{id}":{"delete":{"tags":["handlers::apikeys"],"summary":"Revoke an API key","operationId":"revoke_api_key","parameters":[{"name":"id","in":"path","description":"API key ID","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"API key revoked successfully"},"401":{"description":"Unauthorized"},"404":{"description":"API key not found"}},"security":[{"bearer_auth":[]}]}},"/api/auth/balance":{"get":{"tags":["handlers::apikeys"],"summary":"Get user SU balance","operationId":"get_balance","responses":{"200":{"description":"User balance information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BalanceResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]},{"api_key":[]}]}},"/api/auth/change-password":{"post":{"tags":["handlers"],"summary":"Change current user password","operationId":"change_password","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangePasswordRequest"}}},"required":true},"responses":{"200":{"description":"Password changed successfully"},"401":{"description":"Unauthorized or incorrect current password"}},"security":[{"bearer_auth":[]}]}},"/api/auth/forgot-password":{"post":{"tags":["handlers"],"summary":"Request a password reset email","operationId":"forgot_password","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgotPasswordRequest"}}},"required":true},"responses":{"200":{"description":"If email exists, reset instructions sent"}}}},"/api/auth/login":{"post":{"tags":["handlers"],"summary":"Login an existing user","operationId":"login","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}},"required":true},"responses":{"200":{"description":"Login successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"401":{"description":"Invalid credentials"}}}},"/api/auth/logout":{"post":{"tags":["handlers::apikeys"],"summary":"Logout (revoke refresh token)","operationId":"logout","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LogoutRequest"}}},"required":true},"responses":{"200":{"description":"Logout successful"}}}},"/api/auth/me":{"get":{"tags":["handlers"],"summary":"Get current user profile","operationId":"me","responses":{"200":{"description":"Current user profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MeResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/auth/refresh":{"post":{"tags":["handlers::apikeys"],"summary":"Refresh access token","operationId":"refresh_token","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefreshRequest"}}},"required":true},"responses":{"200":{"description":"Token refreshed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefreshResponse"}}}},"401":{"description":"Invalid or expired refresh token"}}}},"/api/auth/register":{"post":{"tags":["handlers"],"summary":"Register a new user","operationId":"register","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterRequest"}}},"required":true},"responses":{"200":{"description":"User registered successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"409":{"description":"User already exists"}}}},"/api/auth/reset-password":{"post":{"tags":["handlers"],"summary":"Reset password using a token","operationId":"reset_password","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordRequest"}}},"required":true},"responses":{"200":{"description":"Password reset successfully"},"400":{"description":"Invalid, expired, or already used token"}}}},"/api/history":{"get":{"tags":["handlers::history"],"summary":"Get user's simplification history","operationId":"get_history","responses":{"200":{"description":"List of history entries","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/HistoryEntryDto"}}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]},"post":{"tags":["handlers::history"],"summary":"Save a history entry","operationId":"save_history_entry","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistoryEntryDto"}}},"required":true},"responses":{"201":{"description":"History saved successfully"},"401":{"description":"Unauthorized"},"500":{"description":"Internal server error"}},"security":[{"bearer_auth":[]}]},"delete":{"tags":["handlers::history"],"summary":"Clear user's history","operationId":"clear_history","responses":{"200":{"description":"History cleared successfully"},"401":{"description":"Unauthorized"},"500":{"description":"Internal server error"}},"security":[{"bearer_auth":[]}]}},"/api/payments/cancel":{"post":{"tags":["handlers::billing"],"summary":"Cancel current subscription","operationId":"cancel_subscription","responses":{"200":{"description":"Subscription cancelled successfully"},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/payments/consumption":{"get":{"tags":["handlers::billing"],"summary":"Get user consumption statistics","operationId":"get_consumption_stats","responses":{"200":{"description":"Consumption statistics mapping","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ConsumptionDataDto"}}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/payments/invoices":{"get":{"tags":["handlers::billing"],"summary":"List user invoices","operationId":"get_invoices","responses":{"200":{"description":"List of user invoices","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceDto"}}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/payments/webhook":{"post":{"tags":["handlers"],"summary":"Handle PayPal Webhook","operationId":"paypal_webhook","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayPalWebhook"}}},"required":true},"responses":{"200":{"description":"Webhook processed"},"401":{"description":"Unauthorized Webhook Secret"}}}},"/api/paypal/capture-order":{"post":{"tags":["handlers"],"summary":"Capture a PayPal order","operationId":"paypal_capture_order","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaptureOrderRequest"}}},"required":true},"responses":{"200":{"description":"Order captured successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaptureOrderResponse"}}}},"401":{"description":"Unauthorized"},"409":{"description":"Capture status not completed"}},"security":[{"bearer_auth":[]}]}},"/api/paypal/create-order":{"post":{"tags":["handlers"],"summary":"Create a PayPal order","operationId":"paypal_create_order","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderRequest"}}},"required":true},"responses":{"200":{"description":"Order created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/predict":{"post":{"tags":["handlers"],"summary":"Predict using a logic model","operationId":"predict","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictRequest"}}},"required":true},"responses":{"200":{"description":"Prediction successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictResponse"}}}}}}},"/api/simplify":{"post":{"tags":["handlers"],"summary":"Simplify logic expression using the Exactor Engine (O(n) linear complexity).","description":"Supports native XOR, AND, OR, and NOT operations for high-complexity boolean synthesis.","operationId":"simplify","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimplifyRequest"}}},"required":true},"responses":{"200":{"description":"Logic simplified successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimplifyResponse"}}}},"401":{"description":"Unauthorized"},"402":{"description":"Payment required (Insufficient SU)"},"413":{"description":"Payload too large"}},"security":[{"bearer_auth":[]}]}},"/api/train":{"post":{"tags":["handlers"],"summary":"Train a logic model","operationId":"train","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrainRequest"}}},"required":true},"responses":{"200":{"description":"Model trained successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrainResponse"}}}}}}},"/api/waitlist/join":{"post":{"tags":["handlers"],"summary":"Join the waitlist for a specific plan","operationId":"join_waitlist","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JoinWaitlistRequest"}}},"required":true},"responses":{"200":{"description":"Successfully joined waitlist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JoinWaitlistResponse"}}}},"400":{"description":"Email required when not authenticated"},"500":{"description":"Internal server error"}},"security":[{"bearer_auth":[]}]}},"/api/waitlist/status":{"get":{"tags":["handlers"],"summary":"Check waitlist status","operationId":"waitlist_status","parameters":[{"name":"email","in":"query","required":false,"schema":{"type":"string","nullable":true}},{"name":"plan","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Waitlist status information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WaitlistStatusResponse"}}}},"400":{"description":"Email required when not authenticated"}},"security":[{"bearer_auth":[]}]}}},"components":{"schemas":{"AdminStats":{"type":"object","required":["totalUsers","activeSubscriptions","marketplaceItems","totalSimulations","totalRevenueEst"],"properties":{"activeSubscriptions":{"type":"integer","format":"int64"},"marketplaceItems":{"type":"integer","format":"int64"},"totalRevenueEst":{"type":"number","format":"double"},"totalSimulations":{"type":"integer","format":"int64"},"totalUsers":{"type":"integer","format":"int64"}}},"ApiKeyDto":{"type":"object","required":["id","name","prefix","isActive","createdAt"],"properties":{"createdAt":{"type":"string"},"expiresAt":{"type":"string","nullable":true},"id":{"type":"integer","format":"int64"},"isActive":{"type":"boolean"},"lastUsedAt":{"type":"string","nullable":true},"name":{"type":"string"},"prefix":{"type":"string"}}},"AuthResponse":{"type":"object","required":["token","refresh_token","user"],"properties":{"refresh_token":{"type":"string"},"token":{"type":"string"},"user":{"$ref":"#/components/schemas/UserDto"}}},"BalanceResponse":{"type":"object","required":["suAvailable","subscriptionTier","subscriptionStatus"],"properties":{"suAvailable":{"type":"integer","format":"int64"},"suExpiresAt":{"type":"string","nullable":true},"subscriptionExpiresAt":{"type":"string","nullable":true},"subscriptionStatus":{"type":"string"},"subscriptionTier":{"type":"string"}}},"CaptureOrderRequest":{"type":"object","required":["orderID"],"properties":{"orderID":{"type":"string"}}},"CaptureOrderResponse":{"type":"object","required":["status"],"properties":{"captureID":{"type":"string","nullable":true},"status":{"type":"string"}}},"ChangePasswordRequest":{"type":"object","required":["current_password","new_password"],"properties":{"current_password":{"type":"string"},"new_password":{"type":"string"}}},"ConsumptionDataDto":{"type":"object","required":["date","amount"],"properties":{"amount":{"type":"integer","format":"int64"},"date":{"type":"string"}}},"CreateApiKeyRequest":{"type":"object","properties":{"expiresInDays":{"type":"integer","format":"int64","description":"Optional expiry in days (null = never)","nullable":true},"name":{"type":"string","nullable":true}}},"CreateApiKeyResponse":{"type":"object","required":["secret","key"],"properties":{"key":{"$ref":"#/components/schemas/ApiKeyDto"},"secret":{"type":"string","description":"Shown only once — never retrievable again"}}},"CreateOrderRequest":{"type":"object","properties":{"packageId":{"type":"string","nullable":true},"planId":{"type":"string","nullable":true}}},"CreateOrderResponse":{"type":"object","required":["orderID"],"properties":{"orderID":{"type":"string"}}},"ForgotPasswordRequest":{"type":"object","required":["email"],"properties":{"email":{"type":"string"}}},"HistoryEntryDto":{"type":"object","required":["id","timestamp","inputSummary","variables","minterms","dontCares","equation","executionTimeMs","hardwareTimeMs","softwareTimeMs","complexityReduction","method","mintermsProcessed","outputTerms"],"properties":{"aiDerivedEquation":{"type":"string","nullable":true},"complexityReduction":{"type":"integer","format":"int64"},"dontCares":{"type":"array","items":{"type":"integer","format":"int64"}},"equation":{"type":"string"},"executionTimeMs":{"type":"integer","format":"int64"},"hardwareTimeMs":{"type":"integer","format":"int64"},"id":{"type":"string"},"inputSummary":{"type":"string"},"method":{"type":"string"},"minterms":{"type":"array","items":{"type":"integer","format":"int64"}},"mintermsProcessed":{"type":"integer","format":"int64"},"outputTerms":{"type":"integer","format":"int64"},"refactoringAnalysis":{"type":"string","nullable":true},"softwareTimeMs":{"type":"integer","format":"int64"},"timestamp":{"type":"string"},"variables":{"type":"integer","format":"int64"}}},"InvoiceDto":{"type":"object","required":["id","date","amount","currency","status"],"properties":{"amount":{"type":"number","format":"double"},"currency":{"type":"string"},"date":{"type":"string"},"id":{"type":"integer","format":"int64"},"status":{"type":"string"}}},"JoinWaitlistRequest":{"type":"object","required":["plan"],"properties":{"email":{"type":"string","nullable":true},"plan":{"type":"string"}}},"JoinWaitlistResponse":{"type":"object","required":["email","plan","status"],"properties":{"email":{"type":"string"},"plan":{"type":"string"},"status":{"type":"string"}}},"LoginRequest":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string"},"password":{"type":"string"}}},"LogoutRequest":{"type":"object","required":["refresh_token"],"properties":{"refresh_token":{"type":"string"}}},"PayPalAmount":{"type":"object","required":["value","currency_code"],"properties":{"currency_code":{"type":"string"},"value":{"type":"string"}}},"PayPalResource":{"type":"object","required":["id","status","amount"],"properties":{"amount":{"$ref":"#/components/schemas/PayPalAmount"},"custom_id":{"type":"string","nullable":true},"id":{"type":"string"},"status":{"type":"string"}}},"PayPalWebhook":{"type":"object","required":["id","event_type","resource"],"properties":{"event_type":{"type":"string"},"id":{"type":"string"},"resource":{"$ref":"#/components/schemas/PayPalResource"}}},"PredictRequest":{"type":"object","required":["minterm","terms","weights","bias","var_count"],"properties":{"bias":{"type":"number","format":"float"},"minterm":{"type":"integer","format":"int64","minimum":0},"terms":{"type":"array","items":{"$ref":"#/components/schemas/TermDto"}},"var_count":{"type":"integer","minimum":0},"weights":{"type":"array","items":{"type":"number","format":"float"}}}},"PredictResponse":{"type":"object","required":["prediction"],"properties":{"prediction":{"type":"number","format":"float"}}},"RefreshRequest":{"type":"object","required":["refresh_token"],"properties":{"refresh_token":{"type":"string"}}},"RefreshResponse":{"type":"object","required":["token","refresh_token"],"properties":{"refresh_token":{"type":"string"},"token":{"type":"string"}}},"RegisterRequest":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string"},"password":{"type":"string"}}},"ResetPasswordRequest":{"type":"object","required":["token","new_password"],"properties":{"new_password":{"type":"string"},"token":{"type":"string"}}},"SimplificationHistory":{"type":"object","required":["id","user_id","variables","minterms","dont_cares","input_summary","equation","execution_time_ms","hardware_time_ms","software_time_ms","complexity_reduction","method","minterms_processed","output_terms","created_at"],"properties":{"ai_derived_equation":{"type":"string","nullable":true},"complexity_reduction":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"date-time"},"dont_cares":{"type":"string"},"equation":{"type":"string"},"execution_time_ms":{"type":"integer","format":"int64"},"hardware_time_ms":{"type":"integer","format":"int64"},"id":{"type":"integer","format":"int64"},"input_summary":{"type":"string"},"method":{"type":"string"},"minterms":{"type":"string"},"minterms_processed":{"type":"integer","format":"int64"},"output_terms":{"type":"integer","format":"int64"},"refactoring_analysis":{"type":"string","nullable":true},"software_time_ms":{"type":"integer","format":"int64"},"user_id":{"type":"integer","format":"int64"},"variables":{"type":"integer","format":"int64"}}},"SimplifyRequest":{"type":"object","required":["variables","minterms"],"properties":{"dont_cares":{"type":"array","items":{"type":"integer","format":"int64","minimum":0},"nullable":true},"format":{"type":"string","nullable":true},"minterms":{"type":"array","items":{"type":"integer","format":"int64","minimum":0}},"variables":{"type":"array","items":{"type":"string"}}}},"SimplifyResponse":{"type":"object","required":["result","variable_count","reduction_percent","original_gates","new_gates","execution_time_ms"],"properties":{"espresso":{"type":"string","nullable":true},"execution_time_ms":{"type":"integer","format":"int64","minimum":0},"new_gates":{"type":"integer","minimum":0},"original_gates":{"type":"integer","minimum":0},"reduction_percent":{"type":"number","format":"double"},"result":{"type":"string"},"variable_count":{"type":"integer","minimum":0},"verilog":{"type":"string","nullable":true},"vhdl":{"type":"string","nullable":true}}},"TrainRequest":{"type":"object","required":["data","variables","epochs","learning_rate"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Sample"}},"epochs":{"type":"integer","minimum":0},"learning_rate":{"type":"number","format":"float"},"variables":{"type":"array","items":{"type":"string"}}}},"TrainResponse":{"type":"object","required":["terms","weights","bias","final_error"],"properties":{"bias":{"type":"number","format":"float"},"final_error":{"type":"number","format":"float"},"terms":{"type":"array","items":{"$ref":"#/components/schemas/TermDto"}},"weights":{"type":"array","items":{"type":"number","format":"float"}}}},"UpdateUserPlanRequest":{"type":"object","required":["subscription_tier","subscription_status"],"properties":{"subscription_status":{"type":"string"},"subscription_tier":{"type":"string"}}},"User":{"type":"object","required":["id","email","role","subscription_status","subscription_tier","created_at"],"properties":{"created_at":{"type":"string","format":"date-time"},"email":{"type":"string"},"id":{"type":"integer","format":"int64"},"role":{"type":"string"},"subscription_expires_at":{"type":"string","format":"date-time","nullable":true},"subscription_status":{"type":"string"},"subscription_tier":{"type":"string"}}},"UserDto":{"type":"object","required":["id","email","role","subscriptionStatus","subscriptionTier","suAvailable"],"properties":{"email":{"type":"string"},"id":{"type":"integer","format":"int64"},"role":{"type":"string"},"suAvailable":{"type":"integer","format":"int64"},"suExpiresAt":{"type":"string","nullable":true},"subscriptionExpiresAt":{"type":"string","nullable":true},"subscriptionStatus":{"type":"string"},"subscriptionTier":{"type":"string"}}},"WaitlistStatusResponse":{"type":"object","required":["email","plan","joined"],"properties":{"email":{"type":"string"},"joined":{"type":"boolean"},"plan":{"type":"string"},"status":{"type":"string","nullable":true}}}},"securitySchemes":{"api_key":{"type":"apiKey","in":"header","name":"X-API-Key"},"bearer_auth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}}