{"openapi":"3.0.3","info":{"title":"Lendify API","version":"1.0.0","description":"Enterprise-grade multi-tenant loan management API built with Hono.js. Offering flexible subscription plans for financial institutions, community banks, and savings groups.","contact":{"name":"Lendify API Support","email":"support@loannexus.com","url":"https://loannexus.com/support"},"license":{"name":"MIT","url":"https://opensource.org/licenses/MIT"},"termsOfService":"https://loannexus.com/terms","x-rateLimit":{"requests":1000,"per":"15 minutes","description":"Rate limiting is applied globally. Authenticated users may receive higher limits."}},"servers":[{"url":"http://13.246.240.180/api","description":"Production server"},{"url":"http://localhost:8088/api","description":"Development server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token obtained from login endpoint"}},"schemas":{"ApiResponse":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"data":{"type":"object"}}},"Error":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"error":{"type":"string"}}},"User":{"type":"object"},"Borrower":{"type":"object"},"Loan":{"type":"object"},"Payment":{"type":"object"},"StokvelGroup":{"type":"object"},"StokvelMember":{"type":"object"},"StokvelPayment":{"type":"object"},"UserSettings":{"type":"object"},"OrganizationSettings":{"type":"object"},"Subscription":{"type":"object"},"SubscriptionPlan":{"type":"object"},"SubscriptionPayment":{"type":"object"},"ActivityLog":{"type":"object"}}},"paths":{"/auth/login":{"post":{"summary":"User login","description":"Authenticate user with email and password","tags":["Authentication"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"password":{"type":"string"},"organizationId":{"type":"string","format":"uuid"}},"required":["email","password","organizationId"]}}}},"responses":{"200":{"description":"Login successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"401":{"description":"Authentication failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/auth/register":{"post":{"summary":"User registration","description":"Register a new user for an organization","tags":["Authentication"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"email":{"type":"string","format":"email"},"password":{"type":"string"},"organizationId":{"type":"string","format":"uuid"},"role":{"type":"string","enum":["ADMIN","LOAN_MANAGER","STOKVEL_MANAGER","USER"]}},"required":["name","email","password","organizationId"]}}}},"responses":{"201":{"description":"User created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/auth/logout":{"post":{"summary":"User logout","description":"End user session","tags":["Authentication"],"responses":{"200":{"description":"Logout successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}},"/auth/me":{"get":{"summary":"Get current user","description":"Get the currently authenticated user's profile","tags":["Authentication"],"responses":{"200":{"description":"User profile retrieved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/borrowers":{"get":{"summary":"Get all borrowers","description":"Retrieve all borrowers for the organization","tags":["Borrowers"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}},{"name":"search","in":"query","description":"Search term","schema":{"type":"string"}}],"responses":{"200":{"description":"Borrowers retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}},"post":{"summary":"Create borrower","description":"Create a new borrower","tags":["Borrowers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"contactNumber":{"type":"string"},"email":{"type":"string","format":"email"},"address":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":"string"}},"required":["name","relationshipType"]}}}},"responses":{"201":{"description":"Borrower created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/borrowers/{id}":{"get":{"summary":"Get borrower by ID","description":"Retrieve a specific borrower","tags":["Borrowers"],"parameters":[{"name":"id","in":"path","required":true,"description":"Borrower ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Borrower retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Borrower not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update borrower","description":"Update an existing borrower","tags":["Borrowers"],"parameters":[{"name":"id","in":"path","required":true,"description":"Borrower ID","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"contactNumber":{"type":"string"},"email":{"type":"string","format":"email"},"address":{"type":"string"},"relationshipType":{"type":"string"},"notes":{"type":"string"}}}}}},"responses":{"200":{"description":"Borrower updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Borrower not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete borrower","description":"Delete a borrower","tags":["Borrowers"],"parameters":[{"name":"id","in":"path","required":true,"description":"Borrower ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Borrower deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Borrower not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/loans":{"get":{"summary":"Get all loans","description":"Retrieve all loans for the organization","tags":["Loans"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}},{"name":"status","in":"query","description":"Filter by loan status","schema":{"type":"string","enum":["PENDING","APPROVED","REJECTED","ACTIVE","PAID","DEFAULTED"]}},{"name":"borrowerId","in":"query","description":"Filter by borrower","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Loans retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}},"post":{"summary":"Create loan","description":"Create a new loan","tags":["Loans"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"borrowerId":{"type":"string","format":"uuid"},"managedById":{"type":"string","format":"uuid"},"name":{"type":"string"},"comment":{"type":"string"},"month":{"type":"string"},"loanedAmount":{"type":"number"},"interestRate":{"type":"number"},"currency":{"type":"string"}},"required":["borrowerId","name","loanedAmount","interestRate","currency"]}}}},"responses":{"201":{"description":"Loan created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/loans/{id}":{"get":{"summary":"Get loan by ID","description":"Retrieve a specific loan","tags":["Loans"],"parameters":[{"name":"id","in":"path","required":true,"description":"Loan ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Loan retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Loan not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update loan","description":"Update an existing loan","tags":["Loans"],"parameters":[{"name":"id","in":"path","required":true,"description":"Loan ID","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"comment":{"type":"string"},"managedById":{"type":"string","format":"uuid"},"isInterestPaused":{"type":"boolean"},"status":{"type":"string","enum":["PENDING","APPROVED","REJECTED","ACTIVE","PAID","DEFAULTED"]}}}}}},"responses":{"200":{"description":"Loan updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Loan not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete loan","description":"Delete a loan","tags":["Loans"],"parameters":[{"name":"id","in":"path","required":true,"description":"Loan ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Loan deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Loan not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/loans/{id}/pause-interest":{"post":{"summary":"Pause loan interest","description":"Pause interest calculation for a loan","tags":["Loans"],"parameters":[{"name":"id","in":"path","required":true,"description":"Loan ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Interest paused successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}},"/loans/{id}/resume-interest":{"post":{"summary":"Resume loan interest","description":"Resume interest calculation for a loan","tags":["Loans"],"parameters":[{"name":"id","in":"path","required":true,"description":"Loan ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Interest resumed successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}},"/payments":{"get":{"summary":"Get all payments","description":"Retrieve all payments for the organization","tags":["Payments"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}},{"name":"loanId","in":"query","description":"Filter by loan","schema":{"type":"string","format":"uuid"}},{"name":"isPaid","in":"query","description":"Filter by payment status","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Payments retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}},"post":{"summary":"Create payment","description":"Record a new payment","tags":["Payments"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"loanId":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"isPaid":{"type":"boolean"},"notes":{"type":"string"}},"required":["loanId","date","amount","isPaid"]}}}},"responses":{"201":{"description":"Payment created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/payments/{id}":{"get":{"summary":"Get payment by ID","description":"Retrieve a specific payment","tags":["Payments"],"parameters":[{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Payment retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Payment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update payment","description":"Update an existing payment","tags":["Payments"],"parameters":[{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"amount":{"type":"number"},"isPaid":{"type":"boolean"},"notes":{"type":"string"}}}}}},"responses":{"200":{"description":"Payment updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Payment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete payment","description":"Delete a payment","tags":["Payments"],"parameters":[{"name":"id","in":"path","required":true,"description":"Payment ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Payment deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Payment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/stokvel-groups":{"get":{"summary":"Get all stokvel groups","description":"Retrieve all stokvel groups for the organization","tags":["Stokvel Groups"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}},{"name":"managedById","in":"query","description":"Filter by manager","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel groups retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}},"post":{"summary":"Create stokvel group","description":"Create a new stokvel group","tags":["Stokvel Groups"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"targetAmount":{"type":"number"},"managedById":{"type":"string","format":"uuid"},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}},"required":["name","description","targetAmount","managedById","startDate","endDate"]}}}},"responses":{"201":{"description":"Stokvel group created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/stokvel-groups/{id}":{"get":{"summary":"Get stokvel group by ID","description":"Retrieve a specific stokvel group","tags":["Stokvel Groups"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel group ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel group retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel group not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update stokvel group","description":"Update an existing stokvel group","tags":["Stokvel Groups"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel group ID","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"targetAmount":{"type":"number"},"managedById":{"type":"string","format":"uuid"},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"Stokvel group updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel group not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete stokvel group","description":"Delete a stokvel group","tags":["Stokvel Groups"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel group ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel group deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel group not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/stokvel-members":{"get":{"summary":"Get all stokvel members","description":"Retrieve all stokvel members","tags":["Stokvel Members"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}},{"name":"stokvelGroupId","in":"query","description":"Filter by stokvel group","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel members retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}},"post":{"summary":"Create stokvel member","description":"Add a new member to a stokvel group","tags":["Stokvel Members"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"stokvelGroupId":{"type":"string","format":"uuid"},"name":{"type":"string"},"contribution":{"type":"number"},"joinDate":{"type":"string","format":"date-time"}},"required":["stokvelGroupId","name","contribution","joinDate"]}}}},"responses":{"201":{"description":"Stokvel member created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/stokvel-members/{id}":{"get":{"summary":"Get stokvel member by ID","description":"Retrieve a specific stokvel member","tags":["Stokvel Members"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel member ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel member retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel member not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update stokvel member","description":"Update an existing stokvel member","tags":["Stokvel Members"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel member ID","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"contribution":{"type":"number"}}}}}},"responses":{"200":{"description":"Stokvel member updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel member not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete stokvel member","description":"Remove a member from a stokvel group","tags":["Stokvel Members"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel member ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel member deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel member not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/stokvel-payments":{"get":{"summary":"Get all stokvel payments","description":"Retrieve all stokvel payments","tags":["Stokvel Payments"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}},{"name":"memberId","in":"query","description":"Filter by member","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel payments retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}},"post":{"summary":"Create stokvel payment","description":"Record a new stokvel payment","tags":["Stokvel Payments"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"memberId":{"type":"string","format":"uuid"},"date":{"type":"string","format":"date-time"},"amount":{"type":"number"}},"required":["memberId","date","amount"]}}}},"responses":{"201":{"description":"Stokvel payment created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/stokvel-payments/{id}":{"get":{"summary":"Get stokvel payment by ID","description":"Retrieve a specific stokvel payment","tags":["Stokvel Payments"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel payment ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel payment retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel payment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update stokvel payment","description":"Update an existing stokvel payment","tags":["Stokvel Payments"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel payment ID","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"date":{"type":"string","format":"date-time"},"amount":{"type":"number"}}}}}},"responses":{"200":{"description":"Stokvel payment updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel payment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Delete stokvel payment","description":"Delete a stokvel payment","tags":["Stokvel Payments"],"parameters":[{"name":"id","in":"path","required":true,"description":"Stokvel payment ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Stokvel payment deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"Stokvel payment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/settings":{"get":{"summary":"Get settings","description":"Retrieve user and organization settings","tags":["Settings"],"responses":{"200":{"description":"Settings retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}}},"/settings/user":{"put":{"summary":"Update user settings","description":"Update current user's settings","tags":["Settings"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"language":{"type":"string"},"darkMode":{"type":"boolean"},"notificationsEnabled":{"type":"boolean"},"emailNotifications":{"type":"boolean"}},"required":["language","darkMode","notificationsEnabled","emailNotifications"]}}}},"responses":{"200":{"description":"User settings updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/settings/organization":{"put":{"summary":"Update organization settings","description":"Update organization settings (admin only)","tags":["Settings"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"defaultCurrency":{"type":"string"},"defaultInterestRate":{"type":"number"},"defaultPaymentDay":{"type":"integer"},"interestCalculationDay":{"type":"integer"},"customFields":{"type":"object"}},"required":["defaultCurrency","defaultInterestRate","defaultPaymentDay","interestCalculationDay"]}}}},"responses":{"200":{"description":"Organization settings updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Unauthorized - Admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/subscriptions/subscription":{"get":{"summary":"Get current subscription","description":"Retrieve the organization's current subscription","tags":["Subscriptions"],"responses":{"200":{"description":"Subscription retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"No subscription found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"summary":"Update subscription","description":"Update subscription (admin only)","tags":["Subscriptions"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"planId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["ACTIVE","CANCELED","PAST_DUE","TRIALING"]},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"isTrial":{"type":"boolean"}},"required":["planId"]}}}},"responses":{"200":{"description":"Subscription updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Unauthorized - Admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Cancel subscription","description":"Cancel the organization's subscription","tags":["Subscriptions"],"responses":{"200":{"description":"Subscription canceled successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"403":{"description":"Unauthorized - Admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/subscriptions/plans":{"get":{"summary":"Get all subscription plans","description":"Retrieve all available subscription plans","tags":["Subscription Plans"],"responses":{"200":{"description":"Subscription plans retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}}}},"post":{"summary":"Create subscription plan","description":"Create a new subscription plan (super admin only)","tags":["Subscription Plans"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"price":{"type":"number"},"currency":{"type":"string"},"features":{"type":"array","items":{"type":"string"}},"trialPeriod":{"type":"integer"},"interval":{"type":"string","enum":["monthly","yearly"]},"isActive":{"type":"boolean"}},"required":["name","price","currency"]}}}},"responses":{"201":{"description":"Subscription plan created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Unauthorized - Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/subscriptions/plans/{id}":{"put":{"summary":"Update subscription plan","description":"Update an existing subscription plan (super admin only)","tags":["Subscription Plans"],"parameters":[{"name":"id","in":"path","required":true,"description":"Subscription plan ID","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"price":{"type":"number"},"currency":{"type":"string"},"features":{"type":"array","items":{"type":"string"}},"trialPeriod":{"type":"integer"},"interval":{"type":"string","enum":["monthly","yearly"]},"isActive":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Subscription plan updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"403":{"description":"Unauthorized - Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription plan not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"summary":"Deactivate subscription plan","description":"Deactivate a subscription plan (super admin only)","tags":["Subscription Plans"],"parameters":[{"name":"id","in":"path","required":true,"description":"Subscription plan ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Subscription plan deactivated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Cannot deactivate plan with active subscriptions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Unauthorized - Super admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription plan not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/subscriptions/payments":{"get":{"summary":"Get subscription payments","description":"Retrieve subscription payment history","tags":["Subscription Payments"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}}],"responses":{"200":{"description":"Subscription payments retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"404":{"description":"No subscription found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"summary":"Create subscription payment","description":"Record a subscription payment (admin only)","tags":["Subscription Payments"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"subscriptionId":{"type":"string","format":"uuid"},"amount":{"type":"number"},"currency":{"type":"string"},"paidAt":{"type":"string","format":"date-time"},"receiptUrl":{"type":"string"},"method":{"type":"string"},"status":{"type":"string","enum":["SUCCESS","FAILED","PENDING"]}},"required":["subscriptionId","amount","currency","paidAt"]}}}},"responses":{"201":{"description":"Subscription payment created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Unauthorized - Admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/subscriptions/payments/{id}":{"get":{"summary":"Get subscription payment by ID","description":"Retrieve a specific subscription payment","tags":["Subscription Payments"],"parameters":[{"name":"id","in":"path","required":true,"description":"Subscription payment ID","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Subscription payment retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"403":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Subscription payment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/activity":{"get":{"summary":"Get activity logs","description":"Retrieve activity logs for the organization","tags":["Activity Logs"],"parameters":[{"name":"page","in":"query","description":"Page number","schema":{"type":"integer","default":1}},{"name":"limit","in":"query","description":"Items per page","schema":{"type":"integer","default":10}},{"name":"userId","in":"query","description":"Filter by user","schema":{"type":"string","format":"uuid"}},{"name":"action","in":"query","description":"Filter by action","schema":{"type":"string","enum":["LOGIN","LOGOUT","CREATE","UPDATE","DELETE","VIEW","ACTIVATE","DEACTIVATE"]}},{"name":"entityType","in":"query","description":"Filter by entity type","schema":{"type":"string","enum":["USER","LOAN","STOKVEL","SETTINGS","ORGANIZATION","SUBSCRIPTION"]}}],"responses":{"200":{"description":"Activity logs retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiResponse"}}}},"403":{"description":"Unauthorized - Admin access required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"tags":[{"name":"Authentication","description":"User authentication and session management"},{"name":"Borrowers","description":"Borrower management operations"},{"name":"Loans","description":"Loan lifecycle management"},{"name":"Payments","description":"Payment processing and tracking"},{"name":"Stokvel Groups","description":"Community savings group management"},{"name":"Stokvel Members","description":"Stokvel member management"},{"name":"Stokvel Payments","description":"Stokvel payment tracking"},{"name":"Settings","description":"User and organization settings"},{"name":"Subscriptions","description":"Subscription management"},{"name":"Subscription Plans","description":"Subscription plan administration"},{"name":"Subscription Payments","description":"Subscription billing and payments"},{"name":"Activity Logs","description":"System activity monitoring and audit trails"}]}