{"message":"MongoDB Chatbot API - Enhanced with Manager Requested Session APIs","version":"4.4.0","architecture":"Phase 1 (Simple) → Phase 2 (Smart Limits + Hierarchy) → Phase 3 (Data) + Complete Session Management","manager_requested_apis":{"api_1_sessions_list":{"endpoint":"GET /api/user/sessions","purpose":"Get all session IDs with last conversation for UI list view","parameters":"?days_back=30&limit=50","returns":"List of sessions with last conversation preview","time_limit":"30 days maximum (enforced)","use_case":"Perfect for UI to show user all their sessions with preview"},"api_2_complete_history":{"endpoint":"GET /api/user/sessions/{session_id}/complete","purpose":"Get complete chat history for specific session","parameters":"?include_metadata=true","returns":"Complete conversation history with all queries and responses","security":"User can only access their own sessions","use_case":"Perfect for detailed view when user clicks on a session"},"bonus_api_validation":{"endpoint":"GET /api/user/sessions/{session_id}/exists","purpose":"Quick check if session exists and user has access","returns":"Boolean existence check","use_case":"UI validation before expensive API calls"}},"endpoints":{"chat":"/chat - Enhanced 3-phase chat with unified session tracking","manager_apis":{"sessions_list":"/api/user/sessions - All sessions with last conversation (Manager Req #1)","complete_history":"/api/user/sessions/{session_id}/complete - Complete chat history (Manager Req #2)","session_validation":"/api/user/sessions/{session_id}/exists - Quick session check"},"existing_apis":{"hierarchy_access":"/hierarchy/access - Team Lead/Manager access scope","limits":"/limits - System limits with hierarchy info","health":"/health - System health status"}},"manager_api_examples":{"api_1_example_request":{"method":"GET","url":"/api/user/sessions?days_back=30&limit=50","headers":{"Authorization":"Bearer your-jwt-token"},"description":"Get all user sessions for last 30 days"},"api_1_example_response":{"user_email":"user@company.com","time_period":{"days_requested":30,"start_date":"2025-01-20","end_date":"2025-02-19"},"sessions_summary":{"total_sessions_found":5},"sessions":[{"session_id":"abc123-def456-...","created_at":"2025-02-15T10:30:00Z","total_interactions":4,"last_conversation":{"user_message":"what is manish working on","assistant_response":"## Manish Kumar - Current Work Analysis...","processing_phase":"PHASE_3_COMPLETED"},"preview":{"user_query_preview":"what is manish working on","assistant_response_preview":"## Manish Kumar - Current Work Analysis. Total hours: 167.5..."}}]},"api_2_example_request":{"method":"GET","url":"/api/user/sessions/abc123-def456-ghi789/complete?include_metadata=true","headers":{"Authorization":"Bearer your-jwt-token"},"description":"Get complete history for specific session"},"api_2_example_response":{"session_info":{"session_id":"abc123-def456-ghi789","user_email":"user@company.com","total_interactions":4,"duration_minutes":15},"conversation_statistics":{"phase_breakdown":{"PHASE_1_QUICK":1,"PHASE_2_BLOCKED":1,"PHASE_3_COMPLETED":2},"success_rate_percent":75.0},"complete_conversation_history":[{"interaction_number":1,"user_query":{"content":"hi","timestamp":"2025-02-15T10:30:00Z"},"assistant_response":{"content":"Hello! As a TEAM_LEAD...","timestamp":"2025-02-15T10:30:01Z"},"processing_info":{"phase":"PHASE_1_QUICK","processing_time_ms":85}}]}},"technical_implementation":{"leverages_existing_infrastructure":"Uses unified session tracking from existing development","storage_location":"MongoDB 'sessions' collection (same as agent conversation storage)","security":"Company ID isolation, user can only access own sessions","time_limit_enforcement":"30 days maximum automatically enforced","performance":"Optimized queries with indexes on user_email, company_id, created_at"},"ui_integration_guide":{"list_view":{"api":"GET /api/user/sessions","display":"Show session previews in a list/table","fields_to_show":["created_at","total_interactions","user_query_preview","assistant_response_preview"],"click_action":"Use session_id to call API 2 for complete history"},"detail_view":{"api":"GET /api/user/sessions/{session_id}/complete","display":"Show complete conversation like a chat interface","fields_to_show":["user_query.content","assistant_response.content","processing_info.phase"],"metadata":"Show processing times, phases, verification results"}},"benefits_over_existing":{"manager_specific":"APIs designed exactly for manager's requirements","ui_optimized":"Response format perfect for UI consumption","performance":"Separate APIs avoid over-fetching data","security":"Built-in access control and company isolation","time_limited":"30-day limit prevents expensive queries","complete_reuse":"Leverages all existing unified session tracking infrastructure"}}