Services SDK
Dispute Service

Dispute Service

Case management, resolution workflows, and SLA tracking.

Installation

pnpm add @aicr/dispute-core

Quick Start

import { createCase, resolveCase, getCaseStatus } from '@aicr/dispute-core';
 
// Create a dispute case
const case = await createCase({
  type: 'payment-discrepancy',
  claimant: userId,
  description: 'Commission calculation error for Q4',
  evidence: [documentId],
  slaHours: 72
});
 
// Check status
const status = await getCaseStatus(case.id);
 
// Resolve
await resolveCase(case.id, {
  resolution: 'approved',
  adjustmentAmount: 1500,
  notes: 'Commission recalculated per policy'
});

API Reference

createCase(input)

Create a new dispute case.

interface CreateCaseInput {
  type: 'payment-discrepancy' | 'policy-violation' | 'territory-dispute' | 'quota-challenge' | 'other';
  claimant: string;        // User ID
  description: string;
  evidence?: string[];     // Document IDs
  slaHours?: number;       // SLA deadline in hours
  priority?: 'low' | 'medium' | 'high' | 'critical';
  assignTo?: string;       // Resolver ID
}
 
interface Case {
  id: string;
  type: string;
  status: 'open' | 'in-review' | 'pending-info' | 'resolved' | 'escalated';
  claimant: string;
  assignedTo?: string;
  slaDeadline: Date;
  createdAt: Date;
  updatedAt: Date;
}

resolveCase(caseId, resolution)

Resolve a dispute case.

interface Resolution {
  resolution: 'approved' | 'denied' | 'partial' | 'withdrawn';
  adjustmentAmount?: number;
  notes: string;
  evidence?: string[];
}

escalateCase(caseId, reason)

Escalate a case to higher authority.

await escalateCase(caseId, {
  reason: 'Policy exception required',
  escalateTo: 'compensation-committee'
});

addCaseNote(caseId, note)

Add a note to a case.

await addCaseNote(caseId, {
  content: 'Requested additional documentation from claimant',
  visibility: 'internal'
});

HTTP API

POST /api/dispute/cases

curl -X POST /api/dispute/cases \
  -d '{"type": "payment-discrepancy", "claimant": "user-123", "description": "..."}'

PUT /api/dispute/cases/:id/resolve

curl -X PUT /api/dispute/cases/case-123/resolve \
  -d '{"resolution": "approved", "notes": "..."}'

GET /api/dispute/cases/:id

curl /api/dispute/cases/case-123

SLA Tracking

import { getSLAStatus, getOverdueCases } from '@aicr/dispute-core';
 
// Check SLA status
const sla = await getSLAStatus(caseId);
console.log(sla.hoursRemaining);
console.log(sla.isOverdue);
 
// Get all overdue cases
const overdue = await getOverdueCases({ assignedTo: 'user-123' });