openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: SafeLink IA API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication operations - name: analysis description: AI-powered threat analysis operations - name: users description: User management operations - name: admin description: Admin panel operations - name: threats description: Threat intelligence operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/register: post: operationId: register tags: [auth] summary: Register a new user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterInput" responses: "201": description: User registered content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "409": description: Email already in use content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/login: post: operationId: login tags: [auth] summary: Login with email and password requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginInput" responses: "200": description: Login successful content: application/json: schema: $ref: "#/components/schemas/AuthResponse" "401": description: Invalid credentials content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/logout: post: operationId: logout tags: [auth] summary: Logout current user responses: "200": description: Logged out content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /auth/me: get: operationId: getMe tags: [auth] summary: Get current authenticated user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /analysis/text: post: operationId: analyzeText tags: [analysis] summary: Analyze text for phishing, scam, and social engineering threats requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TextAnalysisInput" responses: "200": description: Analysis result content: application/json: schema: $ref: "#/components/schemas/Analysis" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /analysis/link: post: operationId: analyzeLink tags: [analysis] summary: Analyze a URL for malicious content requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LinkAnalysisInput" responses: "200": description: Link analysis result content: application/json: schema: $ref: "#/components/schemas/Analysis" /analysis/image: post: operationId: analyzeImage tags: [analysis] summary: Analyze an image for manipulation and forensic anomalies requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ImageAnalysisInput" responses: "200": description: Image forensics result content: application/json: schema: $ref: "#/components/schemas/Analysis" /analysis/deepfake: post: operationId: analyzeDeepfake tags: [analysis] summary: Analyze media for deepfake indicators requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DeepfakeAnalysisInput" responses: "200": description: Deepfake detection result content: application/json: schema: $ref: "#/components/schemas/Analysis" /analysis/history: get: operationId: listAnalyses tags: [analysis] summary: List user's analysis history parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 - name: type in: query schema: type: ["string", "null"] enum: [text, link, image, deepfake, null] responses: "200": description: Paginated analysis history content: application/json: schema: $ref: "#/components/schemas/AnalysisList" /analysis/{id}: get: operationId: getAnalysis tags: [analysis] summary: Get a single analysis by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Analysis detail content: application/json: schema: $ref: "#/components/schemas/Analysis" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /users/dashboard: get: operationId: getUserDashboard tags: [users] summary: Get user dashboard summary stats responses: "200": description: Dashboard stats content: application/json: schema: $ref: "#/components/schemas/UserDashboard" /users/profile: get: operationId: getUserProfile tags: [users] summary: Get user profile responses: "200": description: User profile content: application/json: schema: $ref: "#/components/schemas/User" patch: operationId: updateUserProfile tags: [users] summary: Update user profile requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UserProfileUpdate" responses: "200": description: Updated user content: application/json: schema: $ref: "#/components/schemas/User" /users/avatar: patch: operationId: updateAvatar tags: [users] summary: Update user avatar requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AvatarUpdate" responses: "200": description: Updated user content: application/json: schema: $ref: "#/components/schemas/User" /auth/password: put: operationId: changePassword tags: [auth] summary: Change user password requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ChangePasswordInput" responses: "200": description: Password changed content: application/json: schema: $ref: "#/components/schemas/MessageResponse" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Wrong current password content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /users/security-score: get: operationId: getUserSecurityScore tags: [users] summary: Get user's overall security score and threat breakdown responses: "200": description: Security score details content: application/json: schema: $ref: "#/components/schemas/SecurityScore" /admin/stats: get: operationId: getAdminStats tags: [admin] summary: Get platform-wide statistics responses: "200": description: Admin stats content: application/json: schema: $ref: "#/components/schemas/AdminStats" /admin/users: get: operationId: listAdminUsers tags: [admin] summary: List all users (admin) parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 responses: "200": description: Paginated user list content: application/json: schema: $ref: "#/components/schemas/UserList" /admin/users/{id}/block: patch: operationId: blockUser tags: [admin] summary: Block or unblock a user parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BlockUserInput" responses: "200": description: Updated user content: application/json: schema: $ref: "#/components/schemas/User" /admin/analyses: get: operationId: listAdminAnalyses tags: [admin] summary: List all analyses across all users (admin) parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 responses: "200": description: Paginated analyses content: application/json: schema: $ref: "#/components/schemas/AnalysisList" /admin/logs: get: operationId: listAdminLogs tags: [admin] summary: Get system activity logs parameters: - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 50 responses: "200": description: Activity logs content: application/json: schema: $ref: "#/components/schemas/ActivityLogList" /threats/recent: get: operationId: getRecentThreats tags: [threats] summary: Get recent threat intelligence reports parameters: - name: limit in: query schema: type: integer default: 10 responses: "200": description: Recent threats content: application/json: schema: type: array items: $ref: "#/components/schemas/ThreatReport" /threats/stats: get: operationId: getThreatStats tags: [threats] summary: Get threat category breakdown and trends responses: "200": description: Threat statistics content: application/json: schema: $ref: "#/components/schemas/ThreatStats" components: schemas: HealthStatus: type: object properties: status: type: string required: - status ErrorResponse: type: object required: [error] properties: error: type: string MessageResponse: type: object required: [message] properties: message: type: string RegisterInput: type: object required: [name, email, password] properties: name: type: string minLength: 1 email: type: string format: email password: type: string minLength: 8 LoginInput: type: object required: [email, password] properties: email: type: string password: type: string AuthResponse: type: object required: [token, user] properties: token: type: string user: $ref: "#/components/schemas/User" User: type: object required: [id, name, email, role, isActive, createdAt] properties: id: type: integer name: type: string email: type: string role: type: string enum: [admin, user] isActive: type: boolean avatarBase64: type: ["string", "null"] createdAt: type: string format: date-time updatedAt: type: ["string", "null"] format: date-time UserProfileUpdate: type: object properties: name: type: string minLength: 1 AvatarUpdate: type: object required: [avatarBase64] properties: avatarBase64: type: string ChangePasswordInput: type: object required: [currentPassword, newPassword] properties: currentPassword: type: string newPassword: type: string minLength: 8 TextAnalysisInput: type: object required: [content] properties: content: type: string minLength: 1 source: type: ["string", "null"] enum: [sms, email, whatsapp, telegram, social, null] LinkAnalysisInput: type: object required: [url] properties: url: type: string ImageAnalysisInput: type: object required: [imageBase64] properties: imageBase64: type: string filename: type: ["string", "null"] DeepfakeAnalysisInput: type: object required: [mediaBase64] properties: mediaBase64: type: string mediaType: type: string enum: [image, video, audio] filename: type: ["string", "null"] Analysis: type: object required: [id, type, content, riskScore, threatLevel, aiExplanation, indicators, recommendations, createdAt] properties: id: type: integer userId: type: ["integer", "null"] type: type: string enum: [text, link, image, deepfake] content: type: string riskScore: type: number minimum: 0 maximum: 100 threatLevel: type: string enum: [safe, low, medium, high, critical] aiExplanation: type: string indicators: type: array items: type: string recommendations: type: array items: type: string metadata: type: ["object", "null"] additionalProperties: true createdAt: type: string format: date-time AnalysisList: type: object required: [analyses, total, page, limit] properties: analyses: type: array items: $ref: "#/components/schemas/Analysis" total: type: integer page: type: integer limit: type: integer UserDashboard: type: object required: [totalAnalyses, threatsDetected, safeChecks, avgRiskScore, recentAnalyses, threatBreakdown] properties: totalAnalyses: type: integer threatsDetected: type: integer safeChecks: type: integer avgRiskScore: type: number recentAnalyses: type: array items: $ref: "#/components/schemas/Analysis" threatBreakdown: type: array items: $ref: "#/components/schemas/ThreatBreakdownItem" ThreatBreakdownItem: type: object required: [type, count] properties: type: type: string count: type: integer SecurityScore: type: object required: [score, grade, insights, riskByType] properties: score: type: number grade: type: string insights: type: array items: type: string riskByType: type: array items: $ref: "#/components/schemas/RiskByTypeItem" RiskByTypeItem: type: object required: [type, avgRisk, count] properties: type: type: string avgRisk: type: number count: type: integer AdminStats: type: object required: [totalUsers, activeUsers, totalAnalyses, analysesToday, threatsByLevel, analysisGrowth] properties: totalUsers: type: integer activeUsers: type: integer totalAnalyses: type: integer analysesToday: type: integer threatsByLevel: type: object additionalProperties: type: integer analysisGrowth: type: array items: $ref: "#/components/schemas/GrowthDataPoint" GrowthDataPoint: type: object required: [date, count] properties: date: type: string count: type: integer UserList: type: object required: [users, total, page, limit] properties: users: type: array items: $ref: "#/components/schemas/User" total: type: integer page: type: integer limit: type: integer BlockUserInput: type: object required: [isActive] properties: isActive: type: boolean ActivityLog: type: object required: [id, action, createdAt] properties: id: type: integer action: type: string userId: type: ["integer", "null"] metadata: type: ["object", "null"] additionalProperties: true createdAt: type: string format: date-time ActivityLogList: type: object required: [logs, total, page, limit] properties: logs: type: array items: $ref: "#/components/schemas/ActivityLog" total: type: integer page: type: integer limit: type: integer ThreatReport: type: object required: [id, title, description, severity, createdAt] properties: id: type: integer title: type: string description: type: string severity: type: string enum: [low, medium, high, critical] createdAt: type: string format: date-time ThreatStats: type: object required: [byType, bySeverity, topIndicators] properties: byType: type: array items: $ref: "#/components/schemas/ThreatBreakdownItem" bySeverity: type: array items: $ref: "#/components/schemas/ThreatBreakdownItem" topIndicators: type: array items: type: string