{"openapi":"3.1.0","info":{"title":"AI Platform API","version":"2.0.0"},"paths":{"/health/live":{"get":{"summary":"Live","operationId":"live_health_live_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Live Health Live Get"}}}}}}},"/health/ready":{"get":{"summary":"Ready","operationId":"ready_health_ready_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Ready Health Ready Get"}}}}}}},"/v1/lead-scoring/score":{"post":{"summary":"Score","operationId":"score_v1_lead_scoring_score_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"X-Tenant-VKey","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Tenant-Vkey"}},{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","format":"uuid","title":"Idempotency-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunDetail"}}}},"401":{"description":"Missing, invalid or revoked app credential","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringError"}}}},"413":{"description":"Request body exceeds size limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringError"}}}},"422":{"description":"Invalid input, AI key or idempotency key reused with another body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringError"}}}},"503":{"description":"Database unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScoringError"}}}}}}},"/v1/admin/login":{"post":{"summary":"Login","operationId":"login_v1_admin_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminLoginRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/admin/me":{"get":{"summary":"Me","operationId":"me_v1_admin_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/admin/logout":{"post":{"summary":"Logout","operationId":"logout_v1_admin_logout_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/admin/ai-profiles":{"get":{"summary":"List Profiles","operationId":"list_profiles_v1_admin_ai_profiles_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"put":{"summary":"Create Profile","operationId":"create_profile_v1_admin_ai_profiles_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIProfileInput"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/admin/runs":{"get":{"summary":"List Runs","operationId":"list_runs_v1_admin_runs_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunList"}}}}}}},"/v1/admin/runs/{run_id}":{"get":{"summary":"Admin Run","operationId":"admin_run_v1_admin_runs__run_id__get","parameters":[{"name":"run_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Run Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunDetail"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/admin/apps":{"get":{"summary":"List Apps","operationId":"list_apps_v1_admin_apps_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppList"}}}}}}},"/v1/admin/apps/{app_id}":{"delete":{"summary":"Revoke","operationId":"revoke_v1_admin_apps__app_id__delete","parameters":[{"name":"app_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":128,"title":"App Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppSummary"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AIProfileInput":{"properties":{"version":{"type":"string","maxLength":64,"minLength":1,"title":"Version"},"provider":{"type":"string","enum":["aihub","openai_compatible"],"title":"Provider","default":"aihub"},"base_url":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Base Url"},"model":{"type":"string","maxLength":128,"minLength":1,"title":"Model"},"system_prompt":{"type":"string","maxLength":8000,"minLength":1,"title":"System Prompt"},"timeout_seconds":{"type":"integer","maximum":120.0,"minimum":1.0,"title":"Timeout Seconds"},"limits":{"additionalProperties":{"type":"integer"},"type":"object","title":"Limits"}},"additionalProperties":false,"type":"object","required":["version","model","system_prompt","timeout_seconds"],"title":"AIProfileInput"},"AdminLoginRequest":{"properties":{"email":{"type":"string","maxLength":254,"minLength":3,"title":"Email"},"password":{"type":"string","maxLength":1024,"minLength":1,"title":"Password"}},"additionalProperties":false,"type":"object","required":["email","password"],"title":"AdminLoginRequest"},"AppList":{"properties":{"apps":{"items":{"$ref":"#/components/schemas/AppSummary"},"type":"array","title":"Apps"}},"additionalProperties":false,"type":"object","required":["apps"],"title":"AppList"},"AppSummary":{"properties":{"app_id":{"type":"string","title":"App Id"},"active":{"type":"boolean","title":"Active"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"additionalProperties":false,"type":"object","required":["app_id","active","created_at","updated_at"],"title":"AppSummary"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"LeadScoringSnapshot":{"properties":{"version":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Version"},"scope":{"anyOf":[{"type":"string","enum":["trigger_only","linked_contact_history","multi_source_history"]},{"type":"null"}],"title":"Scope"},"captured_at":{"type":"string","format":"date-time","title":"Captured At"},"lead_profile":{"$ref":"#/components/schemas/SnapshotLeadProfile"},"conversations":{"items":{"$ref":"#/components/schemas/SnapshotConversation"},"type":"array","maxItems":10,"title":"Conversations"},"identity_context":{"anyOf":[{"$ref":"#/components/schemas/SnapshotIdentityContext"},{"type":"null"}]},"trigger_metadata":{"anyOf":[{"$ref":"#/components/schemas/SnapshotTriggerMetadata"},{"type":"null"}]},"truncation":{"anyOf":[{"$ref":"#/components/schemas/SnapshotTruncation"},{"type":"null"}]}},"additionalProperties":false,"type":"object","required":["captured_at","lead_profile"],"title":"LeadScoringSnapshot","description":"Bounded HTTP representation of Omni's captured lead evidence."},"RuleInput":{"properties":{"id":{"type":"string","maxLength":64,"minLength":1,"title":"Id"},"field":{"type":"string","maxLength":128,"minLength":1,"title":"Field"},"operator":{"type":"string","enum":["eq","ne","gt","gte","lt","lte","contains","exists"],"title":"Operator"},"value":{"title":"Value"},"points":{"type":"integer","maximum":100.0,"minimum":-100.0,"title":"Points"},"description":{"anyOf":[{"type":"string","maxLength":99},{"type":"null"}],"title":"Description","description":"Optional context for AI scoring; does not change rule matching or points."}},"additionalProperties":false,"type":"object","required":["id","field","operator","points"],"title":"RuleInput"},"RunDetail":{"properties":{"run_id":{"type":"string","format":"uuid","title":"Run Id"},"request_id":{"type":"string","format":"uuid","title":"Request Id"},"app_id":{"type":"string","title":"App Id"},"account_id":{"type":"string","title":"Account Id"},"status":{"type":"string","const":"completed","title":"Status"},"profile_version":{"type":"string","title":"Profile Version"},"rule_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rule Score"},"ai_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Ai Score"},"final_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Final Score"},"degraded":{"type":"boolean","title":"Degraded"},"result_mode":{"anyOf":[{"type":"string","enum":["rules_only","rules_only_fallback","hybrid"]},{"type":"null"}],"title":"Result Mode"},"error_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Code"},"breakdown":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Breakdown"},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At"},"completed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Completed At"},"snapshot":{"$ref":"#/components/schemas/LeadScoringSnapshot"},"metrics":{"$ref":"#/components/schemas/RunMetrics"},"ai_confidence":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Ai Confidence"},"ai_reasoning":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Ai Reasoning"},"ai_evidence":{"anyOf":[{"items":{"$ref":"#/components/schemas/RunEvidenceItem"},"type":"array","maxItems":20},{"type":"null"}],"title":"Ai Evidence"}},"additionalProperties":false,"type":"object","required":["run_id","request_id","app_id","account_id","status","profile_version","rule_score","ai_score","final_score","degraded","result_mode","error_code","breakdown","created_at","completed_at","snapshot","metrics","ai_confidence","ai_reasoning"],"title":"RunDetail","description":"Scoring result, metrics, extracted evidence, and bounded snapshot."},"RunEvidenceItem":{"properties":{"signal":{"type":"string","maxLength":80,"minLength":1,"title":"Signal"},"detail":{"type":"string","maxLength":500,"minLength":1,"title":"Detail"},"source":{"type":"string","maxLength":120,"minLength":1,"title":"Source"}},"additionalProperties":false,"type":"object","required":["signal","detail","source"],"title":"RunEvidenceItem"},"RunList":{"properties":{"runs":{"items":{"$ref":"#/components/schemas/RunSummary"},"type":"array","title":"Runs"}},"additionalProperties":false,"type":"object","required":["runs"],"title":"RunList"},"RunMetrics":{"properties":{"profile_field_count":{"type":"integer","minimum":0.0,"title":"Profile Field Count","description":"Count of non-null name, phone, email, and status fields."},"conversation_count":{"type":"integer","minimum":0.0,"title":"Conversation Count"},"message_count":{"type":"integer","minimum":0.0,"title":"Message Count"},"contact_message_count":{"type":"integer","minimum":0.0,"title":"Contact Message Count"},"customer_message_count":{"type":"integer","minimum":0.0,"title":"Customer Message Count","description":"Compatibility alias for contact_message_count."},"conversation_turn_count":{"type":"integer","minimum":0.0,"title":"Conversation Turn Count","description":"Consecutive sender groups after ordering conversation messages by sent_at."},"contact_started_conversation_count":{"type":"integer","minimum":0.0,"title":"Contact Started Conversation Count","description":"Count of non-empty conversations whose earliest valid sent_at message is from contact; equal message timestamps retain message snapshot order."},"contact_message_recency_days":{"anyOf":[{"type":"number","minimum":0.0},{"type":"null"}],"title":"Contact Message Recency Days"},"contact_message_recency_hours":{"anyOf":[{"type":"number","minimum":0.0},{"type":"null"}],"title":"Contact Message Recency Hours","description":"Hours from the newest contact message with a valid sent_at to captured_at, clamped to zero and rounded to two decimal places; null when either timestamp is unavailable."},"customer_initiated_return":{"type":"boolean","title":"Customer Initiated Return","description":"True only when more than one non-empty conversation has a valid message sent_at and at least one conversation after the first starts with a contact message. Conversations are ordered by earliest valid message sent_at, with equal start times retaining original snapshot position. A conversation starts with the sender of its earliest valid message; equal message timestamps retain message snapshot order. Empty conversations are ignored."}},"additionalProperties":false,"type":"object","required":["profile_field_count","conversation_count","message_count","contact_message_count","customer_message_count","conversation_turn_count","contact_started_conversation_count","contact_message_recency_hours","customer_initiated_return"],"title":"RunMetrics"},"RunRequest":{"properties":{"request_id":{"type":"string","format":"uuid","title":"Request Id"},"account_id":{"type":"string","maxLength":255,"minLength":1,"title":"Account Id"},"subject_ref":{"type":"string","maxLength":255,"minLength":1,"title":"Subject Ref"},"snapshot":{"$ref":"#/components/schemas/LeadScoringSnapshot"},"scoring_config":{"$ref":"#/components/schemas/ScoringConfigurationInput"},"ai_profile":{"type":"string","enum":["light","medium","heavy"],"title":"Ai Profile"}},"additionalProperties":false,"type":"object","required":["request_id","account_id","subject_ref","snapshot","scoring_config","ai_profile"],"title":"RunRequest"},"RunSummary":{"properties":{"run_id":{"type":"string","format":"uuid","title":"Run Id"},"request_id":{"type":"string","format":"uuid","title":"Request Id"},"app_id":{"type":"string","title":"App Id"},"account_id":{"type":"string","title":"Account Id"},"status":{"type":"string","const":"completed","title":"Status"},"profile_version":{"type":"string","title":"Profile Version"},"rule_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rule Score"},"ai_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Ai Score"},"final_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Final Score"},"degraded":{"type":"boolean","title":"Degraded"},"result_mode":{"anyOf":[{"type":"string","enum":["rules_only","rules_only_fallback","hybrid"]},{"type":"null"}],"title":"Result Mode"},"error_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Code"},"breakdown":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Breakdown"},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At"},"completed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Completed At"}},"additionalProperties":false,"type":"object","required":["run_id","request_id","app_id","account_id","status","profile_version","rule_score","ai_score","final_score","degraded","result_mode","error_code","breakdown","created_at","completed_at"],"title":"RunSummary","description":"Scoring outcome fields returned without the stored snapshot."},"ScoringConfigurationInput":{"properties":{"version":{"type":"string","maxLength":64,"minLength":1,"title":"Version"},"rules":{"items":{"$ref":"#/components/schemas/RuleInput"},"type":"array","maxItems":100,"title":"Rules"},"rule_weight":{"type":"number","maximum":1.0,"minimum":0.0,"title":"Rule Weight"},"ai_weight":{"type":"number","maximum":1.0,"minimum":0.0,"title":"Ai Weight"}},"additionalProperties":false,"type":"object","required":["version","rules","rule_weight","ai_weight"],"title":"ScoringConfigurationInput"},"ScoringError":{"properties":{"detail":{"type":"string","title":"Detail"}},"additionalProperties":false,"type":"object","required":["detail"],"title":"ScoringError"},"SnapshotConversation":{"properties":{"conversation_id":{"type":"string","maxLength":255,"minLength":1,"title":"Conversation Id"},"channel":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Channel"},"assigned_agent_id":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Assigned Agent Id"},"messages":{"items":{"$ref":"#/components/schemas/SnapshotMessage"},"type":"array","title":"Messages"}},"additionalProperties":false,"type":"object","required":["conversation_id"],"title":"SnapshotConversation"},"SnapshotIdentityContext":{"properties":{"match_quality":{"anyOf":[{"type":"string","enum":["direct","phone_and_email","phone_and_name","phone_only"]},{"type":"null"}],"title":"Match Quality"},"contact_id":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Contact Id"},"details":{"additionalProperties":true,"type":"object","title":"Details"}},"additionalProperties":false,"type":"object","title":"SnapshotIdentityContext"},"SnapshotLeadProfile":{"properties":{"ems_lead_id":{"type":"string","maxLength":255,"minLength":1,"title":"Ems Lead Id"},"name":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Name"},"phone":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Phone"},"email":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Email"},"status":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Status"},"custom_fields":{"additionalProperties":true,"type":"object","title":"Custom Fields"}},"additionalProperties":false,"type":"object","required":["ems_lead_id"],"title":"SnapshotLeadProfile"},"SnapshotMessage":{"properties":{"message_id":{"type":"string","maxLength":255,"minLength":1,"title":"Message Id"},"sender_type":{"type":"string","enum":["contact","agent","bot"],"title":"Sender Type"},"content":{"type":"string","minLength":1,"title":"Content"},"sent_at":{"type":"string","format":"date-time","title":"Sent At"}},"additionalProperties":false,"type":"object","required":["message_id","sender_type","content","sent_at"],"title":"SnapshotMessage"},"SnapshotTriggerMetadata":{"properties":{"trigger_type":{"anyOf":[{"type":"string","enum":["manual_omni","captain_tool","dev_console"]},{"type":"null"}],"title":"Trigger Type"},"trigger_conversation_id":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Trigger Conversation Id"},"actor_id":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Actor Id"}},"additionalProperties":false,"type":"object","title":"SnapshotTriggerMetadata"},"SnapshotTruncation":{"properties":{"truncated":{"type":"boolean","title":"Truncated","default":false},"dropped_conversations_count":{"type":"integer","minimum":0.0,"title":"Dropped Conversations Count","default":0},"dropped_messages_count":{"type":"integer","minimum":0.0,"title":"Dropped Messages Count","default":0},"reason":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Reason"}},"additionalProperties":false,"type":"object","title":"SnapshotTruncation"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}}}