Classify support tickets using AI. Supports multiple LLM providers. Returns structured intent classification with confidence scores.

Authentication

All API requests require a Bearer token in the Authorization header. If API_SECRET_KEY is not set, auth is skipped (dev mode).

Authorization: Bearer <API_SECRET_KEY>

POST /api/classify

Classify a single support ticket. Returns intent, confidence, reasoning, and detected language.

Request body

FieldTypeRequiredDescription
subjectstringrequiredTicket subject line
descriptionstringoptionalTicket body text
providerstringoptionalopenai | anthropic | vertex. Default: openai
systemPromptstringoptionalCustom system prompt override

Example request

curl
curl -X POST https://your-domain.com/api/classify \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{
    "subject": "Cancel my subscription",
    "description": "I would like to cancel my subscription please.",
    "provider": "openai"
  }'

Response

200 OK
{
  "intent": "cancel_request",
  "confidence": 0.95,
  "reasoning": "User explicitly requests subscription cancellation.",
  "detectedLanguage": "en"
}

Errors

401 Unauthorized
{ "error": "Unauthorized" }
400 Bad Request
{ "error": "subject is required" }
500 Internal Server Error
{ "error": "Classification failed" }

POST /api/test-prompts

Batch test classification against existing Zendesk tickets. Fetches tickets by tag and classifies each one. Used by the Playground UI.

Request body

{
  "tag": "canc_queue",       // Zendesk tag to search, default: "canc_queue"
  "limit": 10,              // Max tickets to fetch, default: 10
  "provider": "openai",     // AI provider, default: "openai"
  "systemPrompt": "..."     // Optional custom prompt
}

Response

200 OK
{
  "results": [
    {
      "ticketId": 165779,
      "subject": "Cancel my subscription",
      "description": "...",
      "tags": ["canc_queue", "10_plan_offered"],
      "status": "open",
      "classification": {
        "intent": "cancel_request",
        "confidence": 0.95,
        "reasoning": "...",
        "detectedLanguage": "en"
      },
      "error": null
    }
  ],
  "total": 10,
  "provider": "openai",
  "testedAt": "2026-05-05T12:00:00.000Z"
}

Models

ProviderModelValue
OpenAIGPT-4oopenai
AnthropicClaude Sonnet 4anthropic
GoogleGemini 2.0 Flashvertex

Types

ClassificationResult

{
  "intent": "cancel_request" | "cancel_escalate" | "cancel_info" | "pause_active" | "not_cancel",
  "confidence": 0.0 - 1.0,
  "reasoning": "string",
  "detectedLanguage": "en" | "es" | "fr" | "de" | "it" | "pt"  // optional
}

Intent types

IntentDescription
cancel_requestSimple cancellation request, no financial disputes
cancel_escalateCancel + refund/dispute/chargeback — route to human agent
cancel_infoUser asking about cancellation policies or process
pause_activeUser has a paused subscription
not_cancelNot related to cancellation

Support AI Agent API