openapi: 3.1.0 info: title: Api version: 0.1.0 description: SHANAKHT AI - National Tax Intelligence & Compliance Platform API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: entities description: Resolved entity profiles - name: graph description: Knowledge graph - name: cases description: Case management and dossiers - name: ai description: AI Investigator - name: analytics description: Analytics and reporting paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /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/me: get: operationId: getMe tags: [auth] summary: Get current user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /entities: get: operationId: listEntities tags: [entities] summary: List resolved entities with optional filters parameters: - name: risk_band in: query schema: type: ["string", "null"] enum: [low, medium, high, critical, null] - name: province in: query schema: type: ["string", "null"] - name: q in: query schema: type: ["string", "null"] - name: limit in: query schema: type: ["integer", "null"] - name: offset in: query schema: type: ["integer", "null"] responses: "200": description: List of entities content: application/json: schema: $ref: "#/components/schemas/EntityListResponse" /entities/{id}: get: operationId: getEntity tags: [entities] summary: Get entity profile with linked records parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Entity profile content: application/json: schema: $ref: "#/components/schemas/EntityProfile" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /entities/{id}/score: get: operationId: getEntityScore tags: [entities] summary: Get deviation score and breakdown parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Deviation score content: application/json: schema: $ref: "#/components/schemas/DeviationScore" /entities/{id}/audit-trail: get: operationId: getEntityAuditTrail tags: [entities] summary: Get explainable AI audit trail parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Audit trail with explanations content: application/json: schema: $ref: "#/components/schemas/AuditTrailResponse" /entities/{id}/graph: get: operationId: getEntityGraph tags: [graph] summary: Get subgraph for entity (nodes + edges) parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Graph subgraph content: application/json: schema: $ref: "#/components/schemas/GraphData" /entities/{id}/case: post: operationId: createCase tags: [cases] summary: Create a case for an entity parameters: - name: id in: path required: true schema: type: integer responses: "201": description: Case created content: application/json: schema: $ref: "#/components/schemas/Case" /cases: get: operationId: listCases tags: [cases] summary: List all cases responses: "200": description: List of cases content: application/json: schema: type: array items: $ref: "#/components/schemas/Case" /cases/{id}: get: operationId: getCase tags: [cases] summary: Get case details parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Case details content: application/json: schema: $ref: "#/components/schemas/Case" /cases/{id}/dossier: post: operationId: generateDossier tags: [cases] summary: Generate case dossier parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Generated dossier content: application/json: schema: $ref: "#/components/schemas/Dossier" get: operationId: getDossier tags: [cases] summary: Get existing dossier for a case parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Dossier content: application/json: schema: $ref: "#/components/schemas/Dossier" /ai/chat: post: operationId: aiChat tags: [ai] summary: AI Investigator chat requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AiChatInput" responses: "200": description: AI response content: application/json: schema: $ref: "#/components/schemas/AiAnswer" /analytics/stats: get: operationId: getStats tags: [analytics] summary: Get dashboard summary stats responses: "200": description: Dashboard stats content: application/json: schema: $ref: "#/components/schemas/DashboardStats" /analytics/risk-distribution: get: operationId: getRiskDistribution tags: [analytics] summary: Get count of entities by risk band responses: "200": description: Risk distribution content: application/json: schema: $ref: "#/components/schemas/RiskDistribution" /analytics/top-flagged: get: operationId: getTopFlagged tags: [analytics] summary: Get top N highest risk entities parameters: - name: limit in: query schema: type: ["integer", "null"] responses: "200": description: Top flagged entities content: application/json: schema: type: array items: $ref: "#/components/schemas/EntitySummary" /analytics/compliance-index: get: operationId: getComplianceIndex tags: [analytics] summary: Get national compliance index responses: "200": description: Compliance index content: application/json: schema: $ref: "#/components/schemas/ComplianceIndex" /analytics/compliance-trend: get: operationId: getComplianceTrend tags: [analytics] summary: Get compliance trend over months responses: "200": description: Compliance trend data content: application/json: schema: type: array items: $ref: "#/components/schemas/TrendPoint" /resolution/pipeline: get: operationId: getResolutionPipeline tags: [resolution] summary: Run the 4-level unsupervised entity resolution pipeline responses: "200": description: Pipeline result content: application/json: schema: $ref: "#/components/schemas/ResolutionPipelineResult" /resolution/resolve: post: operationId: resolveName tags: [resolution] summary: Resolve a name (Urdu / Roman Urdu / English) to canonical entities requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ResolveNameInput" responses: "200": description: Resolution result content: application/json: schema: $ref: "#/components/schemas/ResolveNameResult" /resolution/transliteration: get: operationId: getTransliterationTable tags: [resolution] summary: Urdu transliteration layer demo table responses: "200": description: Transliteration examples content: application/json: schema: $ref: "#/components/schemas/TransliterationTable" /graph/intelligence: get: operationId: getGraphIntelligence tags: [graph] summary: Graph Intelligence Layer — embeddings, communities, risk propagation, anomalies responses: "200": description: Graph intelligence result content: application/json: schema: $ref: "#/components/schemas/GraphIntelligenceResult" /analytics/model-evaluation: get: operationId: getModelEvaluation tags: [analytics] summary: Precision / recall / F1 evaluation of the resolution pipeline responses: "200": description: Model evaluation metrics content: application/json: schema: $ref: "#/components/schemas/ModelEvaluationResult" /industry/applicability: get: operationId: getIndustryApplicability tags: [industry] summary: AML / KYC industry applicability (future deployment capability) responses: "200": description: Industry applicability findings content: application/json: schema: $ref: "#/components/schemas/IndustryApplicabilityResult" components: schemas: HealthStatus: type: object required: [status] properties: status: type: string ErrorResponse: type: object required: [error] properties: error: type: string 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] properties: id: type: integer name: type: string email: type: string role: type: string enum: [super_admin, senior_auditor, observer] EntitySummary: type: object required: [id, canonicalName, province, score, riskBand] properties: id: type: integer canonicalName: type: string canonicalNameUrdu: type: ["string", "null"] cnic: type: ["string", "null"] province: type: string score: type: integer riskBand: type: string enum: [low, medium, high, critical] EntityListResponse: type: object required: [entities, total] properties: entities: type: array items: $ref: "#/components/schemas/EntitySummary" total: type: integer LinkedRecord: type: object required: [id, source, rawName, matchConfidence, matchMethod] properties: id: type: integer source: type: string enum: [fbr, excise, utility, land_registry] rawName: type: string matchConfidence: type: number matchMethod: type: string payload: type: object additionalProperties: true EntityProfile: type: object required: [id, canonicalName, province, score, riskBand, linkedRecords] properties: id: type: integer canonicalName: type: string canonicalNameUrdu: type: ["string", "null"] cnic: type: ["string", "null"] province: type: string score: type: integer riskBand: type: string enum: [low, medium, high, critical] linkedRecords: type: array items: $ref: "#/components/schemas/LinkedRecord" createdAt: type: string ScoreBreakdown: type: object required: [component, score, weight, description, recordId] properties: component: type: string score: type: number weight: type: number description: type: string recordId: type: ["string", "null"] DeviationScore: type: object required: [entityId, score, riskBand, breakdown, computedAt] properties: entityId: type: integer score: type: integer riskBand: type: string enum: [low, medium, high, critical] breakdown: type: array items: $ref: "#/components/schemas/ScoreBreakdown" computedAt: type: string AuditTrailItem: type: object required: [component, explanation, contribution, recordRef] properties: component: type: string explanation: type: string contribution: type: integer recordRef: type: ["string", "null"] AuditTrailResponse: type: object required: [entityId, items, summary] properties: entityId: type: integer items: type: array items: $ref: "#/components/schemas/AuditTrailItem" summary: type: string evidenceChain: type: array items: $ref: "#/components/schemas/EvidenceItem" contributingFeatures: type: array items: $ref: "#/components/schemas/ContributingFeature" confidenceLevel: $ref: "#/components/schemas/ConfidenceLevel" graphPath: type: array items: $ref: "#/components/schemas/GraphPathStep" reasoningSummary: type: string EvidenceItem: type: object required: [recordId, source, rawName, matchConfidence, matchMethod, ingestedAt] properties: recordId: type: string source: type: string rawName: type: string matchConfidence: type: integer matchMethod: type: string ingestedAt: type: string ContributingFeature: type: object required: [feature, rawSignal, weight, points, description] properties: feature: type: string rawSignal: type: integer weight: type: number points: type: integer description: type: string ConfidenceLevel: type: object required: [overall, label, basis] properties: overall: type: integer label: type: string basis: type: string GraphPathStep: type: object required: [node] properties: node: type: string relationship: type: ["string", "null"] ResolutionPipelineResult: type: object required: [records, candidatePairs, totalDecisions, levelStats, confidenceDistribution, clusters, sampleDecisions] properties: records: type: integer candidatePairs: type: integer totalDecisions: type: integer levelStats: type: array items: type: object required: [level, name, matched, techniques] properties: level: type: integer name: type: string matched: type: integer techniques: type: array items: type: string confidenceDistribution: type: array items: $ref: "#/components/schemas/ConfidenceBucket" clusters: type: array items: type: object required: [clusterId, canonicalName, confidence, members] properties: clusterId: type: integer canonicalName: type: string confidence: type: integer members: type: array items: type: object required: [recordId, rawName, source] properties: recordId: type: integer rawName: type: string source: type: string sampleDecisions: type: array items: type: object required: [recordA, recordB, level, method, confidence, signals] properties: recordA: $ref: "#/components/schemas/RecordRef" recordB: $ref: "#/components/schemas/RecordRef" level: type: integer method: type: string confidence: type: integer signals: type: object additionalProperties: true RecordRef: type: object required: [id, name] properties: id: type: integer name: type: string ConfidenceBucket: type: object required: [bucket, count] properties: bucket: type: string count: type: integer ResolveNameInput: type: object required: [name] properties: name: type: string ResolveNameResult: type: object required: [query, matches] properties: query: type: object required: [raw, romanized, canonical, script, tokens] properties: raw: type: string romanized: type: string canonical: type: string script: type: string tokens: type: array items: type: string matches: type: array items: type: object required: [entityId, canonicalName, province, confidence, matchLevel, method, signals] properties: entityId: type: integer canonicalName: type: string canonicalNameUrdu: type: ["string", "null"] province: type: string confidence: type: integer matchLevel: type: integer method: type: string signals: type: object additionalProperties: true TransliterationTable: type: object required: [examples] properties: examples: type: array items: type: object required: [variants, canonical, scripts] properties: variants: type: array items: type: string canonical: type: string scripts: type: array items: type: string GraphIntelligenceResult: type: object required: [nodes, edges, communities, anomalies, riskPropagation] properties: nodes: type: array items: type: object required: [id, name, province, baseScore, propagatedScore, inheritedRisk, community, anomalyScore, degree, embedding2d] properties: id: type: integer name: type: string province: type: string baseScore: type: integer propagatedScore: type: integer inheritedRisk: type: integer community: type: integer anomalyScore: type: integer degree: type: integer embedding2d: type: object required: [x, y] properties: x: type: number y: type: number edges: type: array items: type: object required: [source, target, relationship, weight] properties: source: type: integer target: type: integer relationship: type: string weight: type: number communities: type: array items: type: object required: [id, size, avgRisk, maxRisk, label, memberIds, pattern] properties: id: type: integer size: type: integer avgRisk: type: integer maxRisk: type: integer label: type: string memberIds: type: array items: type: integer pattern: type: string anomalies: type: array items: type: object required: [id, name, anomalyScore, reason] properties: id: type: integer name: type: string anomalyScore: type: integer reason: type: string riskPropagation: type: array items: type: object required: [id, name, baseScore, propagatedScore, inheritedFrom] properties: id: type: integer name: type: string baseScore: type: integer propagatedScore: type: integer inheritedFrom: type: array items: type: object required: [id, name, relationship] properties: id: type: integer name: type: string relationship: type: string ModelEvaluationResult: type: object required: [precision, recall, f1, linkRate, truePositives, falsePositives, falseNegatives, trueNegativePairs, confidenceDistribution, graphDetectionAccuracy, perLevel, pipeline] properties: precision: type: number recall: type: number f1: type: number linkRate: type: number truePositives: type: integer falsePositives: type: integer falseNegatives: type: integer trueNegativePairs: type: integer confidenceDistribution: type: array items: $ref: "#/components/schemas/ConfidenceBucket" graphDetectionAccuracy: type: number perLevel: type: array items: type: object required: [level, name, matched, precision] properties: level: type: integer name: type: string matched: type: integer precision: type: number pipeline: type: object required: [records, candidatePairs, totalDecisions, clusters] properties: records: type: integer candidatePairs: type: integer totalDecisions: type: integer clusters: type: integer IndustryApplicabilityResult: type: object required: [deploymentNote, capabilities, shellCompanies, fraudRings, kycFindings, transferChains, ownershipNetworks] properties: deploymentNote: type: string capabilities: type: array items: type: object required: [domain, count, description] properties: domain: type: string count: type: integer description: type: string shellCompanies: type: array items: type: object additionalProperties: true fraudRings: type: array items: type: object additionalProperties: true kycFindings: type: array items: type: object additionalProperties: true transferChains: type: array items: type: object additionalProperties: true ownershipNetworks: type: array items: type: object additionalProperties: true GraphNode: type: object required: [id, type, label, properties] properties: id: type: string type: type: string label: type: string riskBand: type: ["string", "null"] properties: type: object additionalProperties: true GraphEdge: type: object required: [id, source, target, relationship] properties: id: type: string source: type: string target: type: string relationship: type: string GraphData: type: object required: [nodes, edges] properties: nodes: type: array items: $ref: "#/components/schemas/GraphNode" edges: type: array items: $ref: "#/components/schemas/GraphEdge" Case: type: object required: [id, entityId, status, createdAt] properties: id: type: integer entityId: type: integer entityName: type: ["string", "null"] status: type: string enum: [open, under_review, escalated, closed] createdAt: type: string DossierSection: type: object required: [title, content] properties: title: type: string content: type: string Dossier: type: object required: [id, caseId, sections, generatedAt] properties: id: type: integer caseId: type: integer sections: type: array items: $ref: "#/components/schemas/DossierSection" generatedAt: type: string AiChatInput: type: object required: [message] properties: message: type: string entityId: type: ["integer", "null"] AiAnswer: type: object required: [response, citations] properties: response: type: string citations: type: array items: type: string DashboardStats: type: object required: [totalEntities, linkedEntities, nonFilers, criticalCount, highRiskCount, revenueLeakageEst, complianceIndex] properties: totalEntities: type: integer linkedEntities: type: integer nonFilers: type: integer criticalCount: type: integer highRiskCount: type: integer revenueLeakageEst: type: number complianceIndex: type: number RiskBandCount: type: object required: [band, count] properties: band: type: string count: type: integer RiskDistribution: type: object required: [distribution] properties: distribution: type: array items: $ref: "#/components/schemas/RiskBandCount" ComplianceIndex: type: object required: [index, trend, description] properties: index: type: number trend: type: string enum: [improving, declining, stable] description: type: string TrendPoint: type: object required: [month, complianceScore, totalFilers, criticalCount] properties: month: type: string complianceScore: type: number totalFilers: type: integer criticalCount: type: integer