{"api":"TotalSchoolERP CRM REST API","version":"1.0.0","status":"online","description":"Stateless JSON REST API backend for TotalSchoolERP CRM and Flutter mobile applications. Authenticated purely via Authorization: Bearer JWT access token header without session cookies or UI redirects.","base_url":"https:\/\/crm.totalschoolerp.in","authentication":{"type":"JWT Bearer Authentication (RFC 7519)","headers":{"Authorization":{"type":"String (Required)","description":"JWT Bearer access token obtained from \/api\/login or \/api\/refresh (Format: Bearer eyJhbGciOi...). Required for all protected API endpoints."},"X-API-KEY":{"type":"String (Required for \/api\/login)","description":"Secret application API key required during initial authentication at \/api\/login. Default: TSERP_SECRET_KEY_2026"},"Content-Type":{"type":"String (Required for POST)","description":"Must be application\/json."},"Accept":{"type":"String (Required)","description":"Must be application\/json."}}},"categories":[{"name":"Authentication & JWT Rotation","description":"Stateless JWT login, Refresh token rotation, and MFA verification endpoints.","endpoints":[{"method":"POST","path":"\/api\/login","description":"Authenticate user credentials with email and password. Returns JWT access token (1 hour expiry) and Refresh token (30 days expiry).","headers":{"X-API-KEY":"TSERP_SECRET_KEY_2026","Content-Type":"application\/json"},"request_body":{"email":"rajesh.kumar@totalschoolerp.in","password":"password123"},"response_example":{"success":true,"mfa_required":false,"token_type":"Bearer","access_token":"eyJhbGciOi...","expires_in":3600,"refresh_token":"a8f9d0c1e2b3a4f5d6c7e8f90123456789abcdef0123456789abcdef01234567","user":{"id":105,"full_name":"Rajesh Kumar","email":"rajesh.kumar@totalschoolerp.in","role":"sales_rep","designation":"Senior Sales Executive"},"api_headers":{"Authorization":"Bearer eyJhbGciOi...","X-API-KEY":"TSERP_SECRET_KEY_2026","X-USER-ID":105}}},{"method":"POST","path":"\/api\/refresh","description":"Exchange a valid refresh token for a new JWT access token and rotated refresh token without logging in again.","headers":{"Content-Type":"application\/json"},"request_body":{"refresh_token":"a8f9d0c1e2b3a4f5d6c7e8f90123456789abcdef0123456789abcdef01234567"},"response_example":{"success":true,"message":"Token refreshed successfully","token_type":"Bearer","access_token":"eyJhbGciOi...","expires_in":3600,"refresh_token":"b9e0c1f2a3..."}},{"method":"POST","path":"\/api\/logout","description":"Revoke refresh token and terminate user session statelessly in database.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"refresh_token":"b9e0c1f2a3..."},"response_example":{"success":true,"message":"Logged out successfully."}},{"method":"POST","path":"\/api\/mfa","description":"Verify 6-digit Google Authenticator OTP code if mfa_required is true. Returns JWT token pair.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"user_id":105,"code":"123456"},"response_example":{"success":true,"message":"MFA verification successful.","token_type":"Bearer","access_token":"eyJhbGciOi...","expires_in":3600,"refresh_token":"a8f9d0c1e2b3...","user":{"id":105,"full_name":"Rajesh Kumar","role":"sales_rep"}}}]},{"name":"Dashboard & KPIs","description":"Executive summary analytics and KPI metrics.","endpoints":[{"method":"GET","path":"\/api\/dashboard","description":"Retrieve performance metrics (pipeline value, target progress, won deals), pending task count, and recent interactions.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"user":{"id":105,"full_name":"Rajesh Kumar","role":"sales_rep"},"metrics":{"pipeline_value":450000,"won_value":120000,"total_deals":8,"conversion_rate":25},"targetValue":200000,"targetProgress":60,"recent_tasks":[{"id":12,"title":"Follow up with DPS Principal","due_date":"2026-07-26","priority":"high"}],"recent_interactions":[{"id":5,"school_name":"Delhi Public School","type":"meeting","notes":"Demo scheduled"}]}}]},{"name":"Leads Management","description":"CRUD operations and status workflows for educational institution leads.","endpoints":[{"method":"GET","path":"\/api\/leads","description":"List all leads assigned to the authenticated user or all leads if admin.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"count":2,"leads":[{"id":1,"school_name":"Delhi Public School","city":"New Delhi","status":"contacted","lead_score":85}]}},{"method":"GET","path":"\/api\/leads\/detail?id=1","description":"Retrieve full lead profile including interaction history and notes.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"lead":{"id":1,"school_name":"Delhi Public School","contact_person":"Dr. Sharma","phone":"9876543210"},"interactions":[{"id":1,"interaction_date":"2026-07-20 14:30:00","type":"call","notes":"Discussed ERP modules"}]}},{"method":"POST","path":"\/api\/leads\/add","description":"Create a new prospective school lead.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"school_name":"St. Xaviers High School","contact_person":"Father Anthony","phone":"9811223344","email":"principal@stxaviers.edu","city":"Mumbai","state":"Maharashtra","student_count":2500},"response_example":{"success":true,"message":"Lead created successfully.","lead_id":15}},{"method":"POST","path":"\/api\/leads\/update-status","description":"Update the sales pipeline status of a lead.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"lead_id":1,"status":"qualified"},"response_example":{"success":true,"message":"Lead status updated."}}]},{"name":"Deals Pipeline","description":"Manage revenue opportunities and deal progression stages.","endpoints":[{"method":"GET","path":"\/api\/deals","description":"Retrieve all active deals grouped by stage (Discovery, Proposal, Negotiation, Won, Lost).","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"deals":[{"id":101,"deal_name":"DPS Cloud ERP Implementation","stage":"proposal","value":150000,"probability":60}]}},{"method":"POST","path":"\/api\/deals\/add","description":"Create a new deal opportunity linked to a lead.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"lead_id":1,"deal_name":"Annual License & Support","value":120000,"stage":"discovery","expected_close_date":"2026-08-30"},"response_example":{"success":true,"message":"Deal added successfully.","deal_id":102}},{"method":"POST","path":"\/api\/deals\/update-stage","description":"Move a deal to a new stage in the sales pipeline.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"deal_id":101,"stage":"won"},"response_example":{"success":true,"message":"Deal stage updated to won."}},{"method":"POST","path":"\/api\/deals\/delete","description":"Remove a deal from the pipeline.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"deal_id":101},"response_example":{"success":true,"message":"Deal deleted."}}]},{"name":"Tasks & Checklist","description":"Manage sales rep action items, follow-ups, and daily tasks.","endpoints":[{"method":"GET","path":"\/api\/tasks","description":"Get all pending and completed tasks assigned to the user.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"tasks":[{"id":1,"title":"Send quotation to DPS","due_date":"2026-07-26","status":"pending","priority":"high"}]}},{"method":"POST","path":"\/api\/tasks\/add","description":"Create a new task.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"title":"Schedule product demo with Trustees","due_date":"2026-07-28","priority":"medium","lead_id":1},"response_example":{"success":true,"message":"Task created successfully.","task_id":5}},{"method":"POST","path":"\/api\/tasks\/toggle","description":"Toggle task completion status between pending and completed.","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"task_id":1},"response_example":{"success":true,"status":"completed","message":"Task marked as completed."}}]},{"name":"Users & Profile","description":"Team management, user profiles, and two-factor authentication.","endpoints":[{"method":"GET","path":"\/api\/profile","description":"Retrieve logged-in user profile, monthly commission target, and 2FA status.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"user":{"id":105,"full_name":"Rajesh Kumar","email":"rajesh.kumar@totalschoolerp.in","role":"sales_rep","monthly_target":200000,"commission_rate":5,"google_2fa_enabled":1}}},{"method":"POST","path":"\/api\/profile\/disable-2fa","description":"Disable Google Authenticator 2FA for the current user.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"message":"Two-Factor Authentication disabled."}},{"method":"GET","path":"\/api\/users","description":"List all CRM users (Admin only).","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"users":[{"id":105,"full_name":"Rajesh Kumar","email":"rajesh.kumar@totalschoolerp.in","role":"sales_rep","is_active":1}]}},{"method":"POST","path":"\/api\/users\/add","description":"Provision a new CRM user account (Admin only).","headers":{"Authorization":"Bearer eyJhbGciOi...","Content-Type":"application\/json"},"request_body":{"full_name":"Anita Desai","email":"anita.desai@totalschoolerp.in","password":"SecurePass2026!","role":"sales_rep","designation":"Regional Sales Manager","department":"Sales","phone":"9822334455","monthly_target":250000},"response_example":{"success":true,"message":"User created successfully.","user_id":106}}]},{"name":"Organizations Management","description":"Manage client school ERP organizations and view institution details.","endpoints":[{"method":"GET","path":"\/api\/organizations","description":"Retrieve all school ERP organizations and their basic status.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"organizations":[{"organization_id":1,"organization_name":"Delhi Public School","city":"New Delhi","state":"Delhi","org_active":1}]}},{"method":"GET","path":"\/api\/organizations\/details?id=1","description":"Retrieve comprehensive details of a client school organization including database schema status and session dates.","headers":{"Authorization":"Bearer eyJhbGciOi..."},"request_body":null,"response_example":{"success":true,"organization":{"organization_id":1,"org_uuid":"a1b2c3d4-e5f6-7890-1234-56789abcdef0","organization_name":"Delhi Public School","org_email":"admin@dps.edu.in","org_phone":"+91 11 23456789","city":"New Delhi","state":"Delhi","subscription_plan":"Enterprise","hostname":"srv1.totalschoolerp.in","db_name":"erp_dps","db_active":1}}}]}]}