TypeScript

Type Definitions

All TypeScript interfaces used across the API. Copy these into your project for full type safety.

ID Types

TypeScript
1// ID Types — all string aliases for readability2type TenantId = string;    // "ten_xxx"3type UserId = string;      // "usr_xxx"4type CaseId = string;      // "cas_xxx"5type SnapshotId = string;  // "scs_xxx"6type MessageId = string;   // "msg_xxx"

Auth Payload

TypeScript
1interface WidgetAuthPayload {2  tenantId: TenantId;3  userId: UserId;4  userEmail: string;5  userRoles: string[];6  plan: string;7  iat: number;8  exp: number;9}

Case & Message

TypeScript
1interface Case {2  id: CaseId;3  tenantId: TenantId;4  userId: UserId;5  status: 'active' | 'resolved' | 'unresolved' | 'escalated';6  snapshotId: SnapshotId;7  createdAt: string;         // ISO 86018  updatedAt: string;9  resolvedAt: string | null;10  messageCount: number;11  feedback: 'positive' | 'negative' | null;12  rating: number | null;     // 1-1013}1415interface Message {16  id: MessageId;17  caseId: CaseId;18  role: 'user' | 'assistant' | 'system';19  content: string;20  actions: SuggestedAction[];21  evidence: Evidence[];22  confidence: number | null;  // 0-123  createdAt: string;24}2526interface SuggestedAction {27  type: 'retry' | 'open_docs' | 'create_ticket' | 'request_access' | 'custom';28  label: string;29  payload: Record<string, unknown>;30}3132interface Evidence {33  type: 'error_code' | 'job_id' | 'timestamp' | 'resource_id' | 'log_excerpt';34  label: string;35  value: string;36}

Support Context Snapshot

TypeScript
1interface SupportContextSnapshot {2  meta: {3    snapshotId: SnapshotId;4    createdAt: string;5    maxBytes: number;6    truncation: {7      eventsRemoved: number;8      logsTrimmed: boolean;9      docsRemoved: number;10    };11  };12  identity: {13    tenantId: TenantId;14    userId: UserId;15    roles: string[];16    plan: string;17    featuresEnabled: string[];18    profile?: { fullName?: string; email?: string; country?: string };19  };20  productState: {21    entities: ProductEntity[];22    activeErrors: ActiveError[];23    limitsReached: LimitReached[];24  };25  recentActivity: {26    windowHours: number;27    events: UserEvent[];28    clickTimeline: ClickTimelineEntry[];29  };30  backend: {31    recentRequests: ApiRequestLog[];32    jobs: JobState[];33    errors: BackendError[];34  };35  knowledgePack: {36    docs: KnowledgeDoc[];37    runbooks: KnowledgeDoc[];38    changelog: ChangelogEntry[];39  };40  privacy: {41    redactionVersion: string;42    fieldsRemoved: string[];43  };44}

Product State

TypeScript
1interface ProductEntity {2  type: string;3  id?: string;4  description?: string;5  status: string;6  metadata: Record<string, unknown>;7}89interface ActiveError {10  errorCode: string;11  errorClass: 'validation' | 'permission' | 'infra' | 'business';12  retryable: boolean;13  userActionable: boolean;14  resourceId: string;15  occurredAt: string;16}1718interface LimitReached {19  limit: string;20  current: number;21  max: number;22}