Skip to main content

Case Intelligence API

Decision support endpoint aggregating AI assessment, similar cases, applicable rules, and officer corrections for a specific compliance case.

Endpoints

Get Case Intelligence

GET /api/cases/{workflow_id}/case-intelligence
GET /api/cases/{workflow_id}/case-intelligence?retry=true

Query Parameters:

ParameterTypeDefaultDescription
retrybooleanfalseClear cached assessment and re-trigger generation

Response:

{
"assessment": {
"summary": "Based on 3 similar Belgian PSP cases, this case aligns with the approved pattern. Key risk: single-director control structure matches 2 prior escalations.",
"pattern": "approved",
"key_differences": [
"Revenue decline exceeds threshold seen in approved cases",
"Single-director pattern flagged in 2 of 3 precedents"
],
"assessment_confidence": 0.82,
"similar_count": 3,
"approved_count": 2,
"generated_at": "2026-03-17T14:23:00Z"
},
"assessment_status": "ready",
"similar_cases": [
{
"workflow_id": "wf-abc-123",
"company_name": "FinTech Solutions BV",
"registration_number": "BE0123456789",
"country": "BE",
"template_type": "PSP Merchant",
"risk_score": 0.35,
"outcome": "approved",
"decided_at": "2026-03-10T09:15:00Z",
"similarity_score": 0.87,
"key_shared_factors": ["BE", "PSP Merchant"]
}
],
"applicable_rules": [
{
"text": "For Belgian management companies where a single natural person occupies all key roles, always require a live interview before approval.",
"scope": "BE management companies",
"trigger": "sole natural person in all key roles",
"action": "create live interview task",
"risk_rationale": "Single-person control structures elevate risk",
"source": "officer-taught",
"created_at": "2026-02-15T10:30:00Z"
}
],
"officer_corrections": [
{
"id": "corr-456",
"finding_category": "financial_health",
"signal_type": "finding_rejected",
"rejection_reason": "Revenue decline is seasonal, not structural",
"description": "Revenue declined 34% YoY — HIGH risk signal",
"created_at": "2026-03-16T11:00:00Z",
"has_analysis": true
}
]
}

Assessment Status Values:

StatusMeaningFrontend Behavior
readyAssessment cached and availableDisplay assessment
generatingBackground task runningShow spinner, poll every 2s
failedGeneration failedShow retry button

Authentication: Bearer JWT token required. Officer must have access to the case's tenant.

Multi-tenancy: All database queries use get_tenant_session(tenant_id) for RLS enforcement.

Response Types

CaseAssessment

FieldTypeDescription
summarystring2-4 sentence prose assessment
patternenumapproved, rejected, mixed, insufficient
key_differencesstring[]Max 3 differences that could change outcome
assessment_confidencefloat0-1, distinct from 4-dimension confidence scoring
similar_countintNumber of similar cases considered
approved_countintNumber approved among similar cases
generated_atstringISO timestamp

SimilarCaseMatch

FieldTypeDescription
workflow_idstringDeep-linkable case identifier
company_namestringReal company name from cases table
registration_numberstringEnterprise/registration number
countrystringISO country code
template_typestringWorkflow template ID
risk_scorefloat?From confidence_score JSONB
outcomeenumapproved, rejected, follow_up, escalated, pending
decided_atstring?ISO timestamp of latest decision
similarity_scorefloat0-1 from Letta archival search
key_shared_factorsstring[]Common attributes

CaseIntelligenceRule

FieldTypeDescription
textstringRule description
scopestringApplicability scope
triggerstring?Activation condition
actionstring?Required response
risk_rationalestring?Why this rule exists
sourceenumauto-learned or officer-taught
created_atstring?ISO timestamp

OfficerCorrection

FieldTypeDescription
idstringCorrection identifier
finding_categorystringRisk domain category
signal_typeenumfinding_confirmed or finding_rejected
rejection_reasonstring?Why finding was rejected
descriptionstringOriginal finding text
created_atstringISO timestamp
has_analysisbooleanWhether FindingAnalysis exists