INTEGRATION SPECIFICATIONS

Data Contracts.

SortMail enforces strict schemas between the Gemini 2.0 parser, the FastAPI application, and client-side React Query subscribers.

Schema SpecificationTypeScript / Pydantic

Thread Intelligence Schema (V1)

Output shape produced by the single-pass Gemini 2.0 Flash extractor function.

type ThreadIntelV1 = {
  thread_id: string;
  summary: {
    bluf: string;
    key_points: string[];
  };
  tasks: Array<{
    id: string;
    description: string;
    priority: "low" | "medium" | "high";
    deadline_iso: string | null;
  }>;
  sentiment: "urgent" | "neutral" | "frustrated";
  attachments_parsed: boolean;
};
Event StreamServer-Sent Events

SSE Notification Payload

Dispatched by Redis Pub/Sub to invalidate client-side caches when a thread finishes processing.

event: intel_ready
data: {
  "thread_id": "18f4a9b2",
  "status": "processed",
  "timestamp": 1729124400
}