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: LegalEasy API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: analyze description: Contract analysis operations - name: history description: Analysis history 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" /analyze: post: operationId: analyzeDocument tags: [analyze] summary: Analyze a legal document description: Takes raw legal text and returns a plain-English analysis with risk flags, hidden clauses, and a readability summary requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AnalyzeDocumentBody" responses: "200": description: Analysis result content: application/json: schema: $ref: "#/components/schemas/AnalysisResult" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /compare: post: operationId: compareDocuments tags: [analyze] summary: Compare two legal documents side by side description: Analyzes two documents and returns a structured comparison across key legal aspects requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CompareDocumentsBody" responses: "200": description: Comparison result content: application/json: schema: $ref: "#/components/schemas/CompareResult" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: Server error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /analyses: get: operationId: listAnalyses tags: [history] summary: List recent analyses description: Returns the most recent document analyses parameters: - name: limit in: query schema: type: integer default: 10 responses: "200": description: List of analyses content: application/json: schema: type: array items: $ref: "#/components/schemas/AnalysisSummary" /analyses/{id}: get: operationId: getAnalysis tags: [history] summary: Get a specific analysis by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Analysis result content: application/json: schema: $ref: "#/components/schemas/AnalysisResult" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /stats: get: operationId: getStats tags: [analyze] summary: Get overall analysis statistics description: Returns aggregate stats across all analyses responses: "200": description: Aggregated stats content: application/json: schema: $ref: "#/components/schemas/AnalysisStats" components: schemas: HealthStatus: type: object properties: status: type: string required: - status AnalyzeDocumentBody: type: object properties: text: type: string description: The raw legal document text to analyze documentName: type: string description: Optional name/title for the document jurisdiction: type: string description: Country or jurisdiction whose laws apply (e.g. "India", "United States") required: - text CompareDocumentsBody: type: object properties: documentAText: type: string description: Raw text of the first document documentBText: type: string description: Raw text of the second document documentAName: type: string description: Optional name for document A documentBName: type: string description: Optional name for document B jurisdiction: type: string description: Country or jurisdiction whose laws apply required: - documentAText - documentBText ComparisonAspect: type: object properties: name: type: string description: Name of the comparison aspect (e.g. "Payment Terms", "Liability") documentA: type: string description: How document A handles this aspect documentB: type: string description: How document B handles this aspect advantage: type: string enum: [A, B, tie] description: Which document is more favorable for this aspect notes: type: string description: Plain-English explanation of the difference required: - name - documentA - documentB - advantage - notes CompareResult: type: object properties: overallVerdict: type: string description: Plain-English overall verdict recommendation: type: string description: Which document to prefer and why documentAScore: type: integer description: Risk score for document A (0-100) documentBScore: type: integer description: Risk score for document B (0-100) documentARiskLevel: type: string enum: [low, medium, high, critical] documentBRiskLevel: type: string enum: [low, medium, high, critical] aspects: type: array items: $ref: "#/components/schemas/ComparisonAspect" required: - overallVerdict - recommendation - documentAScore - documentBScore - documentARiskLevel - documentBRiskLevel - aspects RiskItem: type: object properties: title: type: string description: type: string severity: type: string enum: [low, medium, high] originalClause: type: string required: - title - description - severity ClauseItem: type: object properties: title: type: string plainEnglish: type: string originalText: type: string category: type: string required: - title - plainEnglish - originalText - category AnalysisResult: type: object properties: id: type: integer documentName: type: string summary: type: string description: Plain-English summary of the document overallRiskScore: type: integer description: Risk score from 0-100 (higher = riskier) riskLevel: type: string enum: [low, medium, high, critical] keyRisks: type: array items: $ref: "#/components/schemas/RiskItem" hiddenClauses: type: array items: $ref: "#/components/schemas/ClauseItem" importantClauses: type: array items: $ref: "#/components/schemas/ClauseItem" redFlags: type: array items: type: string jurisdiction: type: string createdAt: type: string format: date-time required: - id - summary - overallRiskScore - riskLevel - keyRisks - hiddenClauses - importantClauses - redFlags - createdAt AnalysisSummary: type: object properties: id: type: integer documentName: type: string riskLevel: type: string enum: [low, medium, high, critical] overallRiskScore: type: integer createdAt: type: string format: date-time summary: type: string required: - id - riskLevel - overallRiskScore - createdAt - summary AnalysisStats: type: object properties: totalAnalyses: type: integer averageRiskScore: type: number riskDistribution: type: object properties: low: type: integer medium: type: integer high: type: integer critical: type: integer required: [low, medium, high, critical] mostCommonRedFlags: type: array items: type: string required: - totalAnalyses - averageRiskScore - riskDistribution - mostCommonRedFlags ErrorResponse: type: object properties: error: type: string message: type: string required: - error - message