API Documentation

REST endpoints for health checks and automated ticket classification.

GET
/api/health
Check API availability.

Response

{ "status": "healthy" }
curl -X GET http://localhost:3000/api/health
POST
/api/sort-ticket
Classify a customer support ticket using Groq AI with rule-based fallback.

Request Schema

{
  ticket_id: string;          // required
  message: string;            // required
  channel?: "app" | "sms" | "call_center" | "merchant_portal";  // default: "app"
  locale?: "en" | "bn" | "mixed";                                 // default: "en"
}

Response Schema

{
  ticket_id: string;
  case_type: "wrong_transfer" | "payment_failed" | "refund_request"
           | "phishing_or_social_engineering" | "other";
  severity: "critical" | "high" | "medium" | "low";
  department: "dispute_resolution" | "payments_ops"
            | "customer_support" | "fraud_risk";
  agent_summary: string;
  human_review_required: boolean;
  confidence: number;  // 0.0 – 1.0
}

Sample Request

{
  "ticket_id": "T-001",
  "channel": "app",
  "locale": "en",
  "message": "I sent 5000 taka to a wrong number this morning, please help me get it back"
}

Sample Response

{
  "ticket_id": "T-001",
  "case_type": "wrong_transfer",
  "severity": "high",
  "department": "dispute_resolution",
  "agent_summary": "Customer reports sending 5000 BDT to an incorrect recipient and requests recovery assistance.",
  "human_review_required": true,
  "confidence": 0.91
}
curl -X POST http://localhost:3000/api/sort-ticket \
  -H "Content-Type: application/json" \
  -d '{
    "ticket_id": "T-001",
    "channel": "app",
    "locale": "en",
    "message": "I sent 5000 taka to a wrong number this morning, please help me get it back"
  }'
HTTP Status Codes
Error responses never include stack traces.
200Successful classification
400Invalid request body or missing required fields
422Validation error (invalid enum values)
429Rate limit exceeded (20 requests/minute per IP)
500Internal server error