{"openapi":"3.0.0","info":{"title":"K - Chatbot API","version":"2.0.0","description":"\n# K - Chatbot API Documentation\n\n## Overview\nThis API provides comprehensive AI-powered chat assistant functionality integrated with Stream Chat. \nIt includes features for AI agent management, knowledge base operations, PDF processing, and more.\n\n## Authentication\nMost endpoints require either API Key or JWT Bearer token authentication.\n- **API Key**: Include `X-API-Key` header\n- **JWT Token**: Include `Authorization: Bearer <token>` header\n\n## Base URLs\n- **Production**: `https://your-domain.com/api/v2`\n- **Development**: `http://localhost:3000/api/v2`\n- **Legacy (Deprecated)**: `/api` (will be removed in v3.0.0)\n\n## Rate Limiting\n- Default: 100 requests per minute per IP\n- Authenticated: 1000 requests per minute per user\n\n## Response Format\nAll responses follow a consistent format:\n```json\n{\n  \"success\": true,\n  \"data\": { ... },\n  \"message\": \"Operation successful\",\n  \"metadata\": { ... }\n}\n```\n\n## Error Handling\nErrors are returned with appropriate HTTP status codes:\n- **400**: Bad Request - Invalid parameters\n- **401**: Unauthorized - Missing or invalid authentication\n- **403**: Forbidden - Insufficient permissions\n- **404**: Not Found - Resource not found\n- **429**: Too Many Requests - Rate limit exceeded\n- **500**: Internal Server Error\n      ","contact":{"name":"Koding","url":"https://koding.com","email":"support@koding.com"},"license":{"name":"MIT","url":"https://opensource.org/licenses/MIT"}},"servers":[{"url":"/api/v2","description":"API v2 Base URL"},{"url":"/api","description":"Legacy API Base URL (Deprecated - will be removed in v3.0.0)"}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"BadRequestError":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"UnauthorizedError":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"ForbiddenError":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFoundError":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"schemas":{"User":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"name":{"type":"string"},"username":{"type":"string"},"role":{"type":"string","enum":["admin","user","guest"]},"status":{"type":"string","enum":["active","inactive","suspended"]},"profile":{"type":"object","properties":{"avatar":{"type":"string"},"bio":{"type":"string"},"location":{"type":"string"},"timezone":{"type":"string"}}},"preferences":{"type":"object","properties":{"language":{"type":"string"},"theme":{"type":"string","enum":["light","dark","auto"]},"notifications":{"type":"object","properties":{"email":{"type":"boolean"},"push":{"type":"boolean"},"inApp":{"type":"boolean"}}}}},"streamChatId":{"type":"string"},"lastLoginAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"Document":{"type":"object","properties":{"id":{"type":"string","description":"Document ID"},"filename":{"type":"string","description":"Original filename"},"mimeType":{"type":"string","description":"MIME type of the document"},"size":{"type":"integer","description":"File size in bytes"},"namespace":{"type":"string","description":"Document namespace"},"metadata":{"type":"object","additionalProperties":true,"description":"Additional metadata"},"uploadedAt":{"type":"string","format":"date-time","description":"Upload timestamp"},"processedAt":{"type":"string","format":"date-time","description":"Processing completion timestamp"},"status":{"type":"string","enum":["pending","processing","completed","failed"],"description":"Processing status"}}},"SearchResult":{"type":"object","properties":{"documentId":{"type":"string","description":"Document ID"},"filename":{"type":"string","description":"Document filename"},"content":{"type":"string","description":"Relevant content excerpt"},"score":{"type":"number","description":"Relevance score (0-1)","minimum":0,"maximum":1},"metadata":{"type":"object","additionalProperties":true}}},"Tool":{"type":"object","properties":{"id":{"type":"string","description":"Tool ID","example":"flight-status"},"name":{"type":"string","description":"Tool display name","example":"Flight Status"},"description":{"type":"string","description":"Tool description"},"category":{"type":"string","enum":["aviation","web","knowledge","general"],"description":"Tool category"},"enabled":{"type":"boolean","description":"Whether tool is enabled"},"configuration":{"type":"object","additionalProperties":true,"description":"Tool-specific configuration"},"parameters":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"},"required":{"type":"boolean"},"description":{"type":"string"}}}}}},"PaginationParams":{"type":"object","properties":{"limit":{"type":"integer","description":"Number of items to return","default":20,"minimum":1,"maximum":100},"offset":{"type":"integer","description":"Number of items to skip","default":0,"minimum":0},"sort":{"type":"string","description":"Sort field","example":"createdAt"},"order":{"type":"string","enum":["asc","desc"],"description":"Sort order","default":"desc"}}},"PaginatedResponse":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object"},"description":"Array of items"},"total":{"type":"integer","description":"Total number of items"},"limit":{"type":"integer","description":"Number of items returned"},"offset":{"type":"integer","description":"Number of items skipped"},"hasMore":{"type":"boolean","description":"Whether more items are available"}}},"Timestamp":{"type":"object","properties":{"createdAt":{"type":"string","format":"date-time","description":"Creation timestamp"},"updatedAt":{"type":"string","format":"date-time","description":"Last update timestamp"}}},"Agent":{"type":"object","properties":{"id":{"type":"string","description":"Agent ID","example":"ai-bot-messaging-general"},"name":{"type":"string","description":"Agent display name","example":"General Assistant"},"description":{"type":"string","description":"Agent description"},"platform":{"type":"string","enum":["openai","langchain"],"description":"AI platform","default":"openai"},"model":{"type":"string","description":"AI model name","example":"gpt-4"},"status":{"type":"string","enum":["active","inactive","initializing","error"],"description":"Agent status"},"configuration":{"$ref":"#/components/schemas/AgentConfiguration"},"tools":{"type":"array","description":"Enabled tools for this agent","items":{"type":"string"}},"knowledge":{"type":"array","description":"Associated knowledge bases","items":{"type":"string"}},"metadata":{"type":"object","additionalProperties":true,"description":"Additional agent metadata"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"AgentConfiguration":{"type":"object","properties":{"temperature":{"type":"number","minimum":0,"maximum":2,"description":"Temperature for response generation","example":0.7},"maxTokens":{"type":"integer","description":"Maximum tokens for response","example":1000},"systemPrompt":{"type":"string","description":"System prompt for the agent"},"responseFormat":{"type":"string","enum":["text","markdown","json"],"description":"Preferred response format","default":"text"},"enableStreaming":{"type":"boolean","description":"Enable response streaming","default":true},"enableTools":{"type":"boolean","description":"Enable function tools","default":true},"enableKnowledge":{"type":"boolean","description":"Enable knowledge base access","default":true},"threadPersistence":{"type":"boolean","description":"Enable thread persistence","default":true},"timeout":{"type":"integer","description":"Response timeout in seconds","default":30}}},"AgentStatus":{"type":"object","properties":{"agentId":{"type":"string","description":"Agent ID"},"channelId":{"type":"string","description":"Associated channel ID"},"status":{"type":"string","enum":["active","inactive","initializing","error"],"description":"Current agent status"},"platform":{"type":"string","enum":["openai","langchain"],"description":"AI platform"},"lastActive":{"type":"string","format":"date-time","description":"Last activity timestamp"},"messageCount":{"type":"integer","description":"Total messages processed"},"tokenUsage":{"type":"object","properties":{"total":{"type":"integer","description":"Total tokens used"},"input":{"type":"integer","description":"Input tokens"},"output":{"type":"integer","description":"Output tokens"}}},"error":{"type":"string","description":"Error message if status is error"}}},"Assistant":{"type":"object","properties":{"id":{"type":"string","description":"OpenAI Assistant ID","example":"asst_abc123"},"name":{"type":"string","description":"Assistant name"},"description":{"type":"string","description":"Assistant description"},"model":{"type":"string","description":"Model used by assistant","example":"gpt-4-turbo"},"instructions":{"type":"string","description":"System instructions for the assistant"},"tools":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["code_interpreter","file_search","function"]},"function":{"type":"object","description":"Function definition for function tools"}}}},"fileIds":{"type":"array","items":{"type":"string"},"description":"Associated file IDs"},"metadata":{"type":"object","additionalProperties":true},"createdAt":{"type":"string","format":"date-time"}}},"Thread":{"type":"object","properties":{"id":{"type":"string","description":"Thread ID","example":"thread_abc123"},"agentId":{"type":"string","description":"Associated agent ID"},"channelId":{"type":"string","description":"Associated channel ID"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ThreadMessage"}},"metadata":{"type":"object","additionalProperties":true},"createdAt":{"type":"string","format":"date-time"},"lastMessageAt":{"type":"string","format":"date-time"}}},"ThreadMessage":{"type":"object","properties":{"id":{"type":"string","description":"Message ID"},"role":{"type":"string","enum":["user","assistant","system"],"description":"Message role"},"content":{"type":"string","description":"Message content"},"attachments":{"type":"array","items":{"type":"object","properties":{"fileId":{"type":"string"},"filename":{"type":"string"}}}},"createdAt":{"type":"string","format":"date-time"}}},"Channel":{"type":"object","properties":{"id":{"type":"string","description":"Channel ID","example":"messaging:general"},"type":{"type":"string","enum":["messaging","team","livestream"],"description":"Channel type","default":"messaging"},"name":{"type":"string","description":"Channel name","example":"General Discussion"},"description":{"type":"string","description":"Channel description"},"image":{"type":"string","description":"Channel avatar/image URL"},"aiConfig":{"$ref":"#/components/schemas/ChannelAIConfig"},"members":{"type":"array","items":{"$ref":"#/components/schemas/ChannelMember"}},"memberCount":{"type":"integer","description":"Total number of members"},"messageCount":{"type":"integer","description":"Total messages in channel"},"createdBy":{"type":"string","description":"User ID who created the channel"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"lastMessageAt":{"type":"string","format":"date-time","description":"Timestamp of last message"},"metadata":{"type":"object","additionalProperties":true,"description":"Additional channel metadata"}}},"ChannelAIConfig":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Whether AI is enabled for this channel","default":false},"agentId":{"type":"string","description":"Associated AI agent ID","example":"ai-bot-messaging-general"},"platform":{"type":"string","enum":["openai","langchain"],"description":"AI platform to use","default":"openai"},"model":{"type":"string","description":"AI model to use","example":"gpt-4"},"autoStart":{"type":"boolean","description":"Automatically start AI agent when channel is created","default":true},"welcomeMessage":{"type":"string","description":"Custom welcome message for AI agent"},"systemPrompt":{"type":"string","description":"Custom system prompt for this channel"},"tools":{"type":"array","description":"Enabled tools for this channel","items":{"type":"string"}},"knowledge":{"type":"array","description":"Knowledge bases available in this channel","items":{"type":"string"}},"responseMode":{"type":"string","enum":["immediate","delayed","manual"],"description":"How AI responds to messages","default":"immediate"},"messageHandling":{"type":"string","enum":["api","event","hybrid"],"description":"Message handling mode","default":"event"},"maxResponseLength":{"type":"integer","description":"Maximum response length in characters","default":2000},"enableThreading":{"type":"boolean","description":"Enable conversation threading","default":true}}},"ChannelMember":{"type":"object","properties":{"userId":{"type":"string","description":"User ID"},"user":{"$ref":"#/components/schemas/User"},"role":{"type":"string","enum":["owner","moderator","member"],"description":"Member role in channel","default":"member"},"joinedAt":{"type":"string","format":"date-time","description":"When user joined the channel"},"lastReadAt":{"type":"string","format":"date-time","description":"Last read message timestamp"},"unreadCount":{"type":"integer","description":"Number of unread messages"},"isMuted":{"type":"boolean","description":"Whether user has muted this channel","default":false},"notifications":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"mentions":{"type":"boolean","default":true},"replies":{"type":"boolean","default":true}}}}},"ChannelMessage":{"type":"object","properties":{"id":{"type":"string","description":"Message ID"},"text":{"type":"string","description":"Message text content"},"html":{"type":"string","description":"HTML formatted content"},"type":{"type":"string","enum":["regular","system","ai","ephemeral"],"description":"Message type"},"user":{"$ref":"#/components/schemas/User"},"attachments":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["image","video","file","audio"]},"url":{"type":"string"},"name":{"type":"string"},"size":{"type":"integer"},"mimeType":{"type":"string"}}}},"mentionedUsers":{"type":"array","items":{"type":"string"},"description":"User IDs mentioned in message"},"parentId":{"type":"string","description":"Parent message ID for threads"},"replyCount":{"type":"integer","description":"Number of replies","default":0},"reactions":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"count":{"type":"integer"},"users":{"type":"array","items":{"type":"string"}}}}},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","format":"date-time","description":"Soft delete timestamp"}}},"KnowledgeCollection":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"documentIds":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object","additionalProperties":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"KnowledgeBase":{"type":"object","properties":{"id":{"type":"string","description":"Knowledge base ID"},"name":{"type":"string","description":"Knowledge base name","example":"Product Documentation"},"description":{"type":"string","description":"Knowledge base description"},"namespace":{"type":"string","description":"Namespace for organization","example":"product-docs"},"vectorStore":{"type":"string","enum":["openai","pinecone"],"description":"Vector store type","default":"openai"},"documents":{"type":"array","items":{"$ref":"#/components/schemas/Document"}},"documentCount":{"type":"integer","description":"Total number of documents"},"totalSize":{"type":"integer","description":"Total size in bytes"},"embeddingModel":{"type":"string","description":"Embedding model used","example":"text-embedding-3-small"},"chunkSize":{"type":"integer","description":"Document chunk size","default":1000},"chunkOverlap":{"type":"integer","description":"Chunk overlap size","default":200},"metadata":{"type":"object","additionalProperties":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"PDFProcessingResult":{"type":"object","properties":{"documentId":{"type":"string","description":"Document ID"},"filename":{"type":"string","description":"Original filename"},"processingMode":{"type":"string","enum":["basic","enhanced","smart","vision-only"],"description":"Processing mode used"},"pages":{"type":"integer","description":"Number of pages processed"},"extractedText":{"type":"string","description":"Extracted text content"},"readabilityScore":{"type":"number","description":"Text readability score (0-1)","minimum":0,"maximum":1},"visionProcessed":{"type":"boolean","description":"Whether vision processing was used"},"chunks":{"type":"array","items":{"type":"object","properties":{"content":{"type":"string"},"pageNumber":{"type":"integer"},"chunkIndex":{"type":"integer"}}}},"metadata":{"type":"object","properties":{"title":{"type":"string"},"author":{"type":"string"},"subject":{"type":"string"},"keywords":{"type":"array","items":{"type":"string"}},"creationDate":{"type":"string","format":"date-time"}}},"processingTime":{"type":"number","description":"Processing time in seconds"},"status":{"type":"string","enum":["success","partial","failed"],"description":"Processing status"},"errors":{"type":"array","items":{"type":"string"},"description":"Processing errors if any"}}},"VectorSearchQuery":{"type":"object","required":["query"],"properties":{"query":{"type":"string","description":"Search query text","example":"How do I configure authentication?"},"namespace":{"type":"string","description":"Limit search to namespace"},"topK":{"type":"integer","description":"Number of results to return","default":10,"minimum":1,"maximum":100},"scoreThreshold":{"type":"number","description":"Minimum similarity score","minimum":0,"maximum":1,"default":0.7},"filters":{"type":"object","additionalProperties":true,"description":"Metadata filters"},"includeMetadata":{"type":"boolean","description":"Include document metadata","default":true},"includeContent":{"type":"boolean","description":"Include full content","default":true}}},"VectorSearchResult":{"type":"object","properties":{"id":{"type":"string","description":"Document chunk ID"},"score":{"type":"number","description":"Similarity score (0-1)","minimum":0,"maximum":1},"content":{"type":"string","description":"Chunk content"},"documentId":{"type":"string","description":"Source document ID"},"filename":{"type":"string","description":"Source filename"},"pageNumber":{"type":"integer","description":"Page number if applicable"},"metadata":{"type":"object","additionalProperties":true}}},"WebPageFetch":{"type":"object","properties":{"jobId":{"type":"string","description":"Fetch job ID"},"url":{"type":"string","format":"uri","description":"Web page URL"},"status":{"type":"string","enum":["pending","processing","completed","failed"],"description":"Job status"},"content":{"type":"string","description":"Extracted content"},"title":{"type":"string","description":"Page title"},"description":{"type":"string","description":"Page description"},"images":{"type":"array","items":{"type":"string","format":"uri"},"description":"Extracted image URLs"},"links":{"type":"array","items":{"type":"object","properties":{"text":{"type":"string"},"url":{"type":"string","format":"uri"}}},"description":"Extracted links"},"metadata":{"type":"object","properties":{"author":{"type":"string"},"publishDate":{"type":"string","format":"date-time"},"keywords":{"type":"array","items":{"type":"string"}}}},"fetchedAt":{"type":"string","format":"date-time"},"processingTime":{"type":"number","description":"Processing time in seconds"},"error":{"type":"string","description":"Error message if failed"}}},"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message"},"code":{"type":"string","description":"Error code"},"statusCode":{"type":"integer","description":"HTTP status code"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message","example":"Invalid request parameters"},"code":{"type":"string","description":"Error code","example":"INVALID_REQUEST"},"statusCode":{"type":"integer","description":"HTTP status code","example":400},"details":{"type":"object","additionalProperties":true,"description":"Additional error details"},"timestamp":{"type":"string","format":"date-time","description":"Error timestamp"},"path":{"type":"string","description":"Request path that caused the error","example":"/api/v2/agents/start"},"requestId":{"type":"string","description":"Request ID for tracking","example":"req_abc123"}}},"ValidationError":{"type":"object","required":["error","validation"],"properties":{"error":{"type":"string","description":"General error message","example":"Validation failed"},"code":{"type":"string","description":"Error code","example":"VALIDATION_ERROR"},"statusCode":{"type":"integer","description":"HTTP status code","example":400},"validation":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","description":"Field name","example":"email"},"message":{"type":"string","description":"Validation message","example":"Must be a valid email address"},"value":{"description":"Provided value"}}}}}},"AuthenticationError":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message","example":"Authentication failed"},"code":{"type":"string","description":"Error code","example":"AUTH_FAILED"},"statusCode":{"type":"integer","description":"HTTP status code","example":401},"reason":{"type":"string","enum":["missing_token","invalid_token","expired_token","invalid_credentials"],"description":"Authentication failure reason"}}},"AuthorizationError":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message","example":"Insufficient permissions"},"code":{"type":"string","description":"Error code","example":"FORBIDDEN"},"statusCode":{"type":"integer","description":"HTTP status code","example":403},"requiredPermissions":{"type":"array","items":{"type":"string"},"description":"Required permissions for this operation"},"userPermissions":{"type":"array","items":{"type":"string"},"description":"User's current permissions"}}},"NotFoundError":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message","example":"Resource not found"},"code":{"type":"string","description":"Error code","example":"NOT_FOUND"},"statusCode":{"type":"integer","description":"HTTP status code","example":404},"resource":{"type":"string","description":"Type of resource not found","example":"Agent"},"id":{"type":"string","description":"Resource ID that was not found","example":"agent123"}}},"RateLimitError":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message","example":"Rate limit exceeded"},"code":{"type":"string","description":"Error code","example":"RATE_LIMIT_EXCEEDED"},"statusCode":{"type":"integer","description":"HTTP status code","example":429},"limit":{"type":"integer","description":"Rate limit","example":100},"remaining":{"type":"integer","description":"Remaining requests","example":0},"resetAt":{"type":"string","format":"date-time","description":"When rate limit resets"}}},"ServerError":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Error message","example":"Internal server error"},"code":{"type":"string","description":"Error code","example":"INTERNAL_ERROR"},"statusCode":{"type":"integer","description":"HTTP status code","example":500},"message":{"type":"string","description":"User-friendly error message","example":"An unexpected error occurred. Please try again later."},"requestId":{"type":"string","description":"Request ID for support","example":"req_xyz789"}}},"FlightStatus":{"type":"object","properties":{"flightNumber":{"type":"string","example":"AA100"},"airline":{"type":"string","example":"American Airlines"},"departure":{"type":"object","properties":{"airport":{"type":"string","example":"LAX"},"terminal":{"type":"string","example":"T4"},"gate":{"type":"string","example":"B12"},"scheduledTime":{"type":"string","format":"date-time"},"actualTime":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["on-time","delayed","cancelled","departed"]}}},"arrival":{"type":"object","properties":{"airport":{"type":"string","example":"JFK"},"terminal":{"type":"string","example":"T8"},"gate":{"type":"string"},"scheduledTime":{"type":"string","format":"date-time"},"estimatedTime":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["on-time","delayed","early","arrived"]}}},"status":{"type":"string","enum":["scheduled","active","landed","cancelled","diverted","unknown"]}}},"FlightSchedule":{"type":"object","properties":{"flightNumber":{"type":"string"},"airline":{"type":"string"},"departure":{"type":"object","properties":{"airport":{"type":"string"},"time":{"type":"string","format":"date-time"}}},"arrival":{"type":"object","properties":{"airport":{"type":"string"},"time":{"type":"string","format":"date-time"}}},"duration":{"type":"integer","description":"Flight duration in minutes"},"aircraft":{"type":"string"}}},"FlightTracking":{"type":"object","properties":{"flightNumber":{"type":"string"},"currentPosition":{"type":"object","properties":{"latitude":{"type":"number"},"longitude":{"type":"number"},"altitude":{"type":"integer","description":"Altitude in feet"},"speed":{"type":"integer","description":"Speed in knots"},"heading":{"type":"integer","description":"Heading in degrees"}}},"progress":{"type":"integer","description":"Flight progress percentage","minimum":0,"maximum":100}}},"AirlineInfo":{"type":"object","properties":{"name":{"type":"string"},"iataCode":{"type":"string"},"icaoCode":{"type":"string"},"country":{"type":"string"},"website":{"type":"string"}}},"AirportInfo":{"type":"object","properties":{"name":{"type":"string"},"iataCode":{"type":"string"},"icaoCode":{"type":"string"},"city":{"type":"string"},"country":{"type":"string"},"timezone":{"type":"string"}}},"AIAssistant":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"platform":{"type":"string","enum":["openai","langchain"]},"model":{"type":"string"},"instructions":{"type":"string"},"tools":{"type":"array","items":{"type":"string"}},"knowledgeDocuments":{"type":"array","items":{"type":"string"}},"knowledgeCollections":{"type":"array","items":{"type":"string"}},"webSources":{"type":"array","items":{"type":"string"}},"settings":{"type":"object","properties":{"temperature":{"type":"number","minimum":0,"maximum":2},"maxTokens":{"type":"number"},"topP":{"type":"number","minimum":0,"maximum":1},"frequencyPenalty":{"type":"number","minimum":-2,"maximum":2},"presencePenalty":{"type":"number","minimum":-2,"maximum":2},"useKnowledge":{"type":"boolean"},"knowledgeSearchConfig":{"type":"object","properties":{"topK":{"type":"number"},"threshold":{"type":"number"}}}}},"status":{"type":"string","enum":["active","inactive"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"CreateAIAssistantRequest":{"type":"object","required":["name","platform"],"properties":{"name":{"type":"string"},"description":{"type":"string"},"platform":{"type":"string","enum":["openai","langchain"]},"model":{"type":"string"},"instructions":{"type":"string"},"tools":{"type":"array","items":{"type":"string"}},"settings":{"type":"object","properties":{"temperature":{"type":"number","minimum":0,"maximum":2},"maxTokens":{"type":"number"},"topP":{"type":"number","minimum":0,"maximum":1},"frequencyPenalty":{"type":"number","minimum":-2,"maximum":2},"presencePenalty":{"type":"number","minimum":-2,"maximum":2}}}}},"UpdateAIAssistantRequest":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"model":{"type":"string"},"instructions":{"type":"string"},"tools":{"type":"array","items":{"type":"string"}},"settings":{"type":"object","properties":{"temperature":{"type":"number","minimum":0,"maximum":2},"maxTokens":{"type":"number"},"topP":{"type":"number","minimum":0,"maximum":1},"frequencyPenalty":{"type":"number","minimum":-2,"maximum":2},"presencePenalty":{"type":"number","minimum":-2,"maximum":2}}},"status":{"type":"string","enum":["active","inactive"]}}},"AIAssistantTemplate":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"category":{"type":"string"},"platform":{"type":"string","enum":["openai","langchain"]},"model":{"type":"string"},"instructions":{"type":"string"},"tools":{"type":"array","items":{"type":"string"}},"settings":{"type":"object","properties":{"temperature":{"type":"number"},"maxTokens":{"type":"number"},"topP":{"type":"number"}}}}},"WebSource":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"url":{"type":"string","format":"uri"},"type":{"type":"string","enum":["page","sitemap"]},"status":{"type":"string","enum":["active","inactive","error"]},"schedule":{"type":"string","description":"Cron expression for automatic scraping"},"config":{"type":"object","properties":{"includePatterns":{"type":"array","items":{"type":"string"}},"excludePatterns":{"type":"array","items":{"type":"string"}},"maxPages":{"type":"number","default":100},"waitForSelector":{"type":"string","description":"CSS selector to wait for before extraction"},"depth":{"type":"number","description":"Maximum crawl depth","default":2},"followLinks":{"type":"boolean","description":"Whether to follow links on pages","default":false}}},"lastCrawl":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"pagesScraped":{"type":"number"},"duration":{"type":"number"},"status":{"type":"string","enum":["success","partial","failed"]},"error":{"type":"string"}}},"nextCrawl":{"type":"string","format":"date-time"},"statistics":{"type":"object","properties":{"totalPages":{"type":"number"},"totalSize":{"type":"number"},"averagePageSize":{"type":"number"},"lastUpdated":{"type":"string","format":"date-time"}}},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"WebPage":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string","format":"uri"},"title":{"type":"string"},"description":{"type":"string"},"content":{"type":"string"},"contentType":{"type":"string","enum":["html","pdf","text","markdown"]},"metadata":{"type":"object","properties":{"author":{"type":"string"},"publishedDate":{"type":"string","format":"date-time"},"modifiedDate":{"type":"string","format":"date-time"},"keywords":{"type":"array","items":{"type":"string"}},"language":{"type":"string"},"canonicalUrl":{"type":"string"}}},"webSourceId":{"type":"string"},"extractedAt":{"type":"string","format":"date-time"},"lastChecked":{"type":"string","format":"date-time"},"contentHash":{"type":"string"},"status":{"type":"string","enum":["active","stale","error","deleted"]},"error":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}}},"tags":[{"name":"Health","description":"Health check and system status endpoints for monitoring"},{"name":"Authentication","description":"User authentication, registration, and session management"},{"name":"AI Agents","description":"AI agent lifecycle management, configuration, and streaming responses"},{"name":"AI Assistants","description":"AI Assistant management with tools and knowledge integration"},{"name":"Tools","description":"AI tool management and configuration for assistants"},{"name":"Channels","description":"Stream Chat channel management with AI integration"},{"name":"Knowledge Management","description":"Knowledge base operations including document upload and search"},{"name":"PDF Processing","description":"PDF document processing with OCR and knowledge extraction"},{"name":"Thread Management","description":"AI conversation thread persistence and recovery"},{"name":"Vector Store","description":"Vector database operations for semantic search"},{"name":"Web Scraping","description":"Web page fetching and content extraction"},{"name":"Analytics","description":"Usage analytics and performance metrics"},{"name":"Widget","description":"Embedded chat widget configuration and management"},{"name":"Voice","description":"Voice input/output and transcription services"},{"name":"Observability","description":"Logs, metrics, and system monitoring"},{"name":"Aviation","description":"Aviation-specific tools and data services"},{"name":"Dashboard","description":"Management dashboard data and metrics"},{"name":"Users","description":"User management and profile operations"},{"name":"Settings","description":"System configuration and preferences"},{"name":"Debug","description":"Debugging and troubleshooting endpoints (development only)"}],"paths":{"/health":{"get":{"tags":["Health"],"summary":"Basic health check","description":"Returns the health status of the API server","operationId":"getHealth","responses":{"200":{"description":"Server is healthy","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"healthy"},"timestamp":{"type":"string","format":"date-time"},"version":{"type":"string","example":"2.0.0"}}}}}}}}},"/health/ready":{"get":{"tags":["Health"],"summary":"Readiness check","description":"Checks if the server is ready to accept requests (database connected, etc.)","operationId":"getReadiness","responses":{"200":{"description":"Server is ready","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ready"},"services":{"type":"object","properties":{"database":{"type":"string","enum":["connected","disconnected"]},"streamChat":{"type":"string","enum":["connected","disconnected"]},"openai":{"type":"string","enum":["configured","not_configured"]}}}}}}}},"503":{"description":"Server is not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/health/live":{"get":{"tags":["Health"],"summary":"Liveness check","description":"Simple check to verify the server is running","operationId":"getLiveness","responses":{"200":{"description":"Server is alive","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"alive"}}}}}}}}},"/auth/register":{"post":{"tags":["Authentication"],"summary":"Register a new user","description":"Creates a new user account with the provided credentials","operationId":"registerUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password","name"],"properties":{"email":{"type":"string","format":"email","description":"User email address"},"password":{"type":"string","minLength":8,"description":"User password (min 8 characters)"},"name":{"type":"string","description":"User full name"}}}}}},"responses":{"201":{"description":"User registered successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/User"},"token":{"type":"string","description":"JWT authentication token"}}}}}}}},"400":{"description":"Invalid input data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"User already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/auth/login":{"post":{"tags":["Authentication"],"summary":"User login","description":"Authenticates a user and returns a JWT token","operationId":"loginUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email","description":"User email address"},"password":{"type":"string","description":"User password"}}}}}},"responses":{"200":{"description":"Login successful","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/User"},"token":{"type":"string","description":"JWT authentication token"},"expiresIn":{"type":"string","example":"24h"}}}}}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/auth/logout":{"post":{"tags":["Authentication"],"summary":"User logout","description":"Invalidates the current user session","operationId":"logoutUser","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Logout successful","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"message":{"type":"string","example":"Logged out successfully"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/auth/me":{"get":{"tags":["Authentication"],"summary":"Get current user","description":"Returns the currently authenticated user's information","operationId":"getCurrentUser","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Current user information","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"$ref":"#/components/schemas/User"}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/auth/refresh":{"post":{"tags":["Authentication"],"summary":"Refresh authentication token","description":"Generates a new JWT token using the refresh token","operationId":"refreshToken","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["refreshToken"],"properties":{"refreshToken":{"type":"string","description":"Refresh token"}}}}}},"responses":{"200":{"description":"Token refreshed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"token":{"type":"string","description":"New JWT authentication token"},"expiresIn":{"type":"string","example":"24h"}}}}}}}},"401":{"description":"Invalid refresh token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/agent/start":{"post":{"tags":["AI Agents"],"summary":"Create and start an AI agent for a channel","description":"Starts an AI agent for a specified channel with automatic AI configuration enablement","operationId":"startAgent","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["channel_id"],"properties":{"channel_id":{"type":"string","description":"The ID of the channel","example":"messaging:general"},"channel_type":{"type":"string","description":"The type of channel","default":"messaging","enum":["messaging","team","livestream"]},"platform":{"type":"string","description":"The AI platform to use","default":"openai","enum":["openai","langchain"]}}}}}},"responses":{"200":{"description":"AI agent started successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"AI agent started successfully"},"agentId":{"type":"string","example":"ai-bot-messaging-general"},"channelId":{"type":"string","example":"messaging:general"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/agent/stop":{"post":{"tags":["AI Agents"],"summary":"Stop an AI agent for a channel","description":"Stops an AI agent for a specified channel with automatic AI configuration disablement","operationId":"stopAgent","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["channel_id"],"properties":{"channel_id":{"type":"string","description":"The ID of the channel","example":"messaging:general"},"channel_type":{"type":"string","description":"The type of channel","default":"messaging","enum":["messaging","team","livestream"]}}}}}},"responses":{"200":{"description":"AI agent stopped successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"AI agent stopped successfully"},"channelId":{"type":"string","example":"messaging:general"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/agent/status":{"get":{"tags":["AI Agents"],"summary":"Get AI agent status for all channels","description":"Returns the status of all AI agents across all channels","operationId":"getAllAgentStatus","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Agent status retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AgentStatus"}}}}}}}},"/agent/status/{channelId}":{"get":{"tags":["AI Agents"],"summary":"Get AI agent status for a specific channel","description":"Returns the status of the AI agent for a specific channel","operationId":"getAgentStatus","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}},{"name":"channelType","in":"query","description":"The type of channel","schema":{"type":"string","default":"messaging"}}],"responses":{"200":{"description":"Agent status retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentStatus"}}}},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/agent/stream":{"post":{"tags":["AI Agents"],"summary":"Stream AI agent response","description":"Streams an AI agent response for a message in a channel","operationId":"streamAgentResponse","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["message","channel_id"],"properties":{"message":{"type":"string","description":"The user message","example":"What is the weather today?"},"channel_id":{"type":"string","description":"The ID of the channel","example":"messaging:general"},"channel_type":{"type":"string","description":"The type of channel","default":"messaging"},"user_id":{"type":"string","description":"The ID of the user","example":"user123"},"message_id":{"type":"string","description":"The ID of the message","example":"msg123"}}}}}},"responses":{"200":{"description":"Streaming response","content":{"text/event-stream":{"schema":{"type":"string","description":"Server-sent events stream"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/agents":{"get":{"tags":["AI Agents"],"summary":"List all AI agents","description":"Returns a list of all configured AI agents","operationId":"listAgents","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"List of agents","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Agent"}}}}}}}},"/agents/{agentId}":{"get":{"tags":["AI Agents"],"summary":"Get agent details","description":"Returns details of a specific AI agent","operationId":"getAgent","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"agentId","in":"path","required":true,"description":"The ID of the agent","schema":{"type":"string"}}],"responses":{"200":{"description":"Agent details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Agent"}}}},"404":{"description":"Agent not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/channels":{"get":{"tags":["Channels"],"summary":"List all channels","description":"Returns a list of all channels with their AI configuration","operationId":"listChannels","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"type","in":"query","description":"Filter by channel type","schema":{"type":"string","enum":["messaging","team","livestream"]}},{"name":"ai_enabled","in":"query","description":"Filter by AI enabled status","schema":{"type":"boolean"}},{"name":"limit","in":"query","description":"Number of channels to return","schema":{"type":"integer","default":20,"minimum":1,"maximum":100}},{"name":"offset","in":"query","description":"Number of channels to skip","schema":{"type":"integer","default":0,"minimum":0}}],"responses":{"200":{"description":"List of channels","content":{"application/json":{"schema":{"type":"object","properties":{"channels":{"type":"array","items":{"$ref":"#/components/schemas/Channel"}},"total":{"type":"integer","description":"Total number of channels"}}}}}}}},"post":{"tags":["Channels"],"summary":"Create a new channel","description":"Creates a new channel with optional AI configuration","operationId":"createChannel","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string","description":"Channel ID","example":"general"},"name":{"type":"string","description":"Channel name","example":"General Discussion"},"type":{"type":"string","description":"Channel type","default":"messaging","enum":["messaging","team","livestream"]},"description":{"type":"string","description":"Channel description"},"ai_config":{"$ref":"#/components/schemas/ChannelAIConfig"},"members":{"type":"array","description":"Initial channel members","items":{"type":"string"}}}}}}},"responses":{"201":{"description":"Channel created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Channel"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Channel already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/channels/{channelId}":{"get":{"tags":["Channels"],"summary":"Get channel details","description":"Returns details of a specific channel including AI configuration","operationId":"getChannel","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}}],"responses":{"200":{"description":"Channel details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Channel"}}}},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Channels"],"summary":"Update channel","description":"Updates a channel configuration","operationId":"updateChannel","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Channel name"},"description":{"type":"string","description":"Channel description"},"ai_config":{"$ref":"#/components/schemas/ChannelAIConfig"}}}}}},"responses":{"200":{"description":"Channel updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Channel"}}}},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Channels"],"summary":"Delete channel","description":"Deletes a channel and its associated AI agent","operationId":"deleteChannel","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}}],"responses":{"204":{"description":"Channel deleted successfully"},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/channels/{channelId}/ai-config":{"get":{"tags":["Channels"],"summary":"Get channel AI configuration","description":"Returns the AI configuration for a specific channel","operationId":"getChannelAIConfig","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}}],"responses":{"200":{"description":"Channel AI configuration","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelAIConfig"}}}},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Channels"],"summary":"Update channel AI configuration","description":"Updates the AI configuration for a specific channel","operationId":"updateChannelAIConfig","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelAIConfig"}}}},"responses":{"200":{"description":"AI configuration updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelAIConfig"}}}},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/channels/{channelId}/members":{"get":{"tags":["Channels"],"summary":"Get channel members","description":"Returns a list of channel members","operationId":"getChannelMembers","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}}],"responses":{"200":{"description":"List of channel members","content":{"application/json":{"schema":{"type":"object","properties":{"members":{"type":"array","items":{"$ref":"#/components/schemas/ChannelMember"}},"total":{"type":"integer","description":"Total number of members"}}}}}},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Channels"],"summary":"Add members to channel","description":"Adds one or more members to a channel","operationId":"addChannelMembers","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"channelId","in":"path","required":true,"description":"The ID of the channel","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["user_ids"],"properties":{"user_ids":{"type":"array","description":"User IDs to add","items":{"type":"string"},"minItems":1}}}}}},"responses":{"200":{"description":"Members added successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Members added successfully"},"added":{"type":"integer","description":"Number of members added"}}}}}},"404":{"description":"Channel not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/knowledge/upload":{"post":{"tags":["Knowledge Management"],"summary":"Upload documents to knowledge base","description":"Uploads one or more documents for processing and storage in the knowledge base","operationId":"uploadKnowledge","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["files"],"properties":{"files":{"type":"array","description":"Documents to upload","items":{"type":"string","format":"binary"}},"namespace":{"type":"string","description":"Namespace for organizing documents","example":"product-docs"},"metadata":{"type":"string","description":"JSON string containing metadata","example":"{\"category\":\"technical\",\"version\":\"2.0\"}"}}}}}},"responses":{"200":{"description":"Documents uploaded successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Documents uploaded successfully"},"documents":{"type":"array","items":{"$ref":"#/components/schemas/Document"}},"processed":{"type":"integer","description":"Number of documents processed"}}}}}},"400":{"description":"Invalid request or unsupported file type","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/knowledge/search":{"post":{"tags":["Knowledge Management"],"summary":"Search knowledge base","description":"Performs semantic search across the knowledge base","operationId":"searchKnowledge","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["query"],"properties":{"query":{"type":"string","description":"Search query","example":"How do I configure authentication?"},"namespace":{"type":"string","description":"Limit search to specific namespace"},"limit":{"type":"integer","description":"Maximum number of results","default":10,"minimum":1,"maximum":50},"filters":{"type":"object","description":"Additional filters","properties":{"category":{"type":"string"},"date_from":{"type":"string","format":"date-time"},"date_to":{"type":"string","format":"date-time"}}}}}}}},"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/SearchResult"}},"total":{"type":"integer","description":"Total matching documents"},"query":{"type":"string","description":"Original query"}}}}}}}}},"/knowledge/documents":{"get":{"tags":["Knowledge Management"],"summary":"List documents","description":"Returns a list of all documents in the knowledge base","operationId":"listDocuments","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"namespace","in":"query","description":"Filter by namespace","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Number of documents to return","schema":{"type":"integer","default":20,"minimum":1,"maximum":100}},{"name":"offset","in":"query","description":"Number of documents to skip","schema":{"type":"integer","default":0,"minimum":0}}],"responses":{"200":{"description":"List of documents","content":{"application/json":{"schema":{"type":"object","properties":{"documents":{"type":"array","items":{"$ref":"#/components/schemas/Document"}},"total":{"type":"integer","description":"Total number of documents"}}}}}}}}},"/knowledge/documents/{documentId}":{"get":{"tags":["Knowledge Management"],"summary":"Get document details","description":"Returns details of a specific document","operationId":"getDocument","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"documentId","in":"path","required":true,"description":"The ID of the document","schema":{"type":"string"}}],"responses":{"200":{"description":"Document details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"404":{"description":"Document not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Knowledge Management"],"summary":"Delete document","description":"Deletes a document from the knowledge base","operationId":"deleteDocument","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"documentId","in":"path","required":true,"description":"The ID of the document","schema":{"type":"string"}}],"responses":{"204":{"description":"Document deleted successfully"},"404":{"description":"Document not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/pdf/upload":{"post":{"tags":["PDF Processing"],"summary":"Upload PDF for processing","description":"Uploads a PDF document for intelligent processing with text and vision analysis","operationId":"uploadPDF","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"PDF file to upload"},"mode":{"type":"string","description":"Processing mode","enum":["basic","enhanced","smart","vision-only"],"default":"smart"},"namespace":{"type":"string","description":"Namespace for organizing PDFs"}}}}}},"responses":{"200":{"description":"PDF processed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"PDF processed successfully"},"documentId":{"type":"string","description":"Document ID"},"processingMode":{"type":"string","description":"Mode used for processing"},"pages":{"type":"integer","description":"Number of pages processed"},"extractedText":{"type":"string","description":"Extracted text content"}}}}}},"400":{"description":"Invalid PDF or processing error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai/pdf-processing/status":{"get":{"tags":["PDF Processing"],"summary":"Get PDF processing status","description":"Returns the current PDF processing configuration and status","operationId":"getPDFProcessingStatus","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"PDF processing status","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Whether PDF processing is enabled"},"mode":{"type":"string","description":"Current processing mode","enum":["basic","enhanced","smart","vision-only"]},"visionEnabled":{"type":"boolean","description":"Whether vision processing is enabled"},"maxPages":{"type":"integer","description":"Maximum pages to process"},"readabilityThreshold":{"type":"number","description":"Text readability threshold"}}}}}}}}},"/analytics/usage":{"get":{"tags":["Analytics"],"summary":"Get usage analytics","description":"Returns usage statistics for AI agents and channels","operationId":"getUsageAnalytics","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"start_date","in":"query","description":"Start date for analytics period","schema":{"type":"string","format":"date-time"}},{"name":"end_date","in":"query","description":"End date for analytics period","schema":{"type":"string","format":"date-time"}},{"name":"channel_id","in":"query","description":"Filter by specific channel","schema":{"type":"string"}},{"name":"agent_id","in":"query","description":"Filter by specific agent","schema":{"type":"string"}}],"responses":{"200":{"description":"Usage analytics data","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"}}},"metrics":{"type":"object","properties":{"total_messages":{"type":"integer","description":"Total messages processed"},"ai_responses":{"type":"integer","description":"Total AI responses generated"},"tokens_used":{"type":"integer","description":"Total tokens consumed"},"active_channels":{"type":"integer","description":"Number of active channels"},"active_agents":{"type":"integer","description":"Number of active agents"},"average_response_time":{"type":"number","description":"Average response time in seconds"}}},"breakdown":{"type":"object","properties":{"by_channel":{"type":"array","items":{"type":"object","properties":{"channel_id":{"type":"string"},"messages":{"type":"integer"},"tokens":{"type":"integer"}}}},"by_agent":{"type":"array","items":{"type":"object","properties":{"agent_id":{"type":"string"},"messages":{"type":"integer"},"tokens":{"type":"integer"}}}}}}}}}}}}}},"/analytics/performance":{"get":{"tags":["Analytics"],"summary":"Get performance metrics","description":"Returns performance metrics for the system","operationId":"getPerformanceMetrics","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"interval","in":"query","description":"Time interval for metrics","schema":{"type":"string","enum":["1h","24h","7d","30d"],"default":"24h"}}],"responses":{"200":{"description":"Performance metrics","content":{"application/json":{"schema":{"type":"object","properties":{"interval":{"type":"string"},"metrics":{"type":"object","properties":{"response_times":{"type":"object","properties":{"p50":{"type":"number","description":"50th percentile response time (ms)"},"p95":{"type":"number","description":"95th percentile response time (ms)"},"p99":{"type":"number","description":"99th percentile response time (ms)"},"average":{"type":"number","description":"Average response time (ms)"}}},"error_rate":{"type":"number","description":"Error rate percentage"},"uptime":{"type":"number","description":"System uptime percentage"},"throughput":{"type":"object","properties":{"messages_per_second":{"type":"number"},"requests_per_second":{"type":"number"}}}}},"timeseries":{"type":"array","items":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"response_time":{"type":"number"},"error_count":{"type":"integer"},"request_count":{"type":"integer"}}}}}}}}}}}},"/dashboard/metrics":{"get":{"tags":["Dashboard"],"summary":"Get dashboard metrics","description":"Returns comprehensive metrics for the management dashboard","operationId":"getDashboardMetrics","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Dashboard metrics","content":{"application/json":{"schema":{"type":"object","properties":{"overview":{"type":"object","properties":{"total_users":{"type":"integer"},"active_channels":{"type":"integer"},"active_agents":{"type":"integer"},"messages_today":{"type":"integer"}}},"ai_usage":{"type":"object","properties":{"tokens_used_today":{"type":"integer"},"tokens_used_month":{"type":"integer"},"cost_today":{"type":"number"},"cost_month":{"type":"number"}}},"system_health":{"type":"object","properties":{"api_status":{"type":"string","enum":["healthy","degraded","down"]},"database_status":{"type":"string","enum":["healthy","degraded","down"]},"stream_chat_status":{"type":"string","enum":["healthy","degraded","down"]},"openai_status":{"type":"string","enum":["healthy","degraded","down"]}}},"recent_activity":{"type":"array","items":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"type":{"type":"string","enum":["message","agent_start","agent_stop","error"]},"description":{"type":"string"},"channel_id":{"type":"string"}}}}}}}}}}}},"/tools":{"get":{"tags":["Tools"],"summary":"List all available tools","description":"Returns a list of all available AI tools and their configurations","operationId":"listTools","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"category","in":"query","description":"Filter by tool category","schema":{"type":"string","enum":["aviation","web","knowledge","general"]}},{"name":"enabled","in":"query","description":"Filter by enabled status","schema":{"type":"boolean"}}],"responses":{"200":{"description":"List of tools","content":{"application/json":{"schema":{"type":"object","properties":{"tools":{"type":"array","items":{"$ref":"#/components/schemas/Tool"}},"total":{"type":"integer","description":"Total number of tools"},"categories":{"type":"array","items":{"type":"string"},"description":"Available tool categories"}}}}}}}}},"/tools/{toolId}":{"get":{"tags":["Tools"],"summary":"Get tool details","description":"Returns details of a specific tool","operationId":"getTool","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"toolId","in":"path","required":true,"description":"The ID of the tool","schema":{"type":"string"}}],"responses":{"200":{"description":"Tool details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tool"}}}},"404":{"description":"Tool not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Tools"],"summary":"Update tool configuration","description":"Updates the configuration of a specific tool","operationId":"updateTool","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"toolId","in":"path","required":true,"description":"The ID of the tool","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Enable or disable the tool"},"configuration":{"type":"object","description":"Tool-specific configuration","additionalProperties":true}}}}}},"responses":{"200":{"description":"Tool updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tool"}}}},"404":{"description":"Tool not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tools/aviation/flight-status":{"post":{"tags":["Aviation"],"summary":"Get flight status","description":"Retrieves current status for a specific flight","operationId":"getFlightStatus","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["flight_number"],"properties":{"flight_number":{"type":"string","description":"Flight number (e.g., AA100)","example":"AA100"},"date":{"type":"string","format":"date","description":"Flight date (YYYY-MM-DD)","example":"2025-01-15"}}}}}},"responses":{"200":{"description":"Flight status information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlightStatus"}}}},"404":{"description":"Flight not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tools/aviation/flight-schedule":{"post":{"tags":["Aviation"],"summary":"Get flight schedule","description":"Retrieves flight schedule between airports","operationId":"getFlightSchedule","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["departure","arrival"],"properties":{"departure":{"type":"string","description":"Departure airport code (IATA)","example":"LAX"},"arrival":{"type":"string","description":"Arrival airport code (IATA)","example":"JFK"},"date":{"type":"string","format":"date","description":"Travel date","example":"2025-01-15"},"limit":{"type":"integer","description":"Maximum number of results","default":10}}}}}},"responses":{"200":{"description":"Flight schedule","content":{"application/json":{"schema":{"type":"object","properties":{"flights":{"type":"array","items":{"$ref":"#/components/schemas/FlightSchedule"}},"total":{"type":"integer"}}}}}}}}},"/tools/aviation/flight-tracker":{"post":{"tags":["Aviation"],"summary":"Track flight in real-time","description":"Provides real-time tracking information for a flight","operationId":"trackFlight","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["flight_number"],"properties":{"flight_number":{"type":"string","description":"Flight number to track","example":"UA328"}}}}}},"responses":{"200":{"description":"Flight tracking information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlightTracking"}}}}}}},"/tools/aviation/airline-info":{"post":{"tags":["Aviation"],"summary":"Get airline information","description":"Retrieves detailed information about an airline","operationId":"getAirlineInfo","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["airline_code"],"properties":{"airline_code":{"type":"string","description":"Airline IATA or ICAO code","example":"AA"}}}}}},"responses":{"200":{"description":"Airline information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AirlineInfo"}}}}}}},"/tools/aviation/airport-city":{"post":{"tags":["Aviation"],"summary":"Get airports by city","description":"Retrieves list of airports serving a specific city","operationId":"getAirportsByCity","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["city"],"properties":{"city":{"type":"string","description":"City name","example":"New York"},"country":{"type":"string","description":"Country name (optional)","example":"United States"}}}}}},"responses":{"200":{"description":"List of airports","content":{"application/json":{"schema":{"type":"object","properties":{"airports":{"type":"array","items":{"$ref":"#/components/schemas/AirportInfo"}},"total":{"type":"integer"}}}}}}}}},"/widget/session":{"post":{"tags":["Widget"],"summary":"Create widget session","description":"Creates or retrieves a guest session for the chat widget","operationId":"createWidgetSession","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"sessionId":{"type":"string","description":"Existing session ID to restore"},"metadata":{"type":"object","description":"Additional session metadata","additionalProperties":true}}}}}},"responses":{"200":{"description":"Widget session created/retrieved","content":{"application/json":{"schema":{"type":"object","properties":{"sessionId":{"type":"string","description":"Session identifier"},"userId":{"type":"string","description":"Guest user ID"},"token":{"type":"string","description":"Stream Chat token"},"apiKey":{"type":"string","description":"Stream API key"},"channelId":{"type":"string","description":"Widget channel ID"},"channelType":{"type":"string","description":"Channel type","default":"messaging"},"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"image":{"type":"string"}}}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/widget/config":{"get":{"tags":["Widget"],"summary":"Get widget configuration","description":"Returns the current widget configuration and customization settings","operationId":"getWidgetConfig","responses":{"200":{"description":"Widget configuration","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Whether widget is enabled"},"theme":{"type":"object","properties":{"primaryColor":{"type":"string","example":"#007bff"},"backgroundColor":{"type":"string","example":"#ffffff"},"textColor":{"type":"string","example":"#333333"},"borderRadius":{"type":"string","example":"8px"}}},"features":{"type":"object","properties":{"voiceInput":{"type":"boolean","description":"Enable voice input"},"fileUpload":{"type":"boolean","description":"Enable file uploads"},"videoIntro":{"type":"boolean","description":"Show video introduction"},"typing":{"type":"boolean","description":"Show typing indicators"}}},"position":{"type":"object","properties":{"bottom":{"type":"string","example":"20px"},"right":{"type":"string","example":"20px"}}},"branding":{"type":"object","properties":{"logo":{"type":"string","description":"Logo URL"},"title":{"type":"string","example":"Chat with us"},"subtitle":{"type":"string","example":"We typically reply within minutes"}}}}}}}}}},"put":{"tags":["Widget"],"summary":"Update widget configuration","description":"Updates the widget configuration and customization settings","operationId":"updateWidgetConfig","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"theme":{"type":"object","additionalProperties":true},"features":{"type":"object","additionalProperties":true},"position":{"type":"object","additionalProperties":true},"branding":{"type":"object","additionalProperties":true}}}}}},"responses":{"200":{"description":"Configuration updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Widget configuration updated successfully"},"config":{"type":"object","description":"Updated configuration"}}}}}}}}},"/widget/analytics":{"get":{"tags":["Widget"],"summary":"Get widget analytics","description":"Returns usage analytics for the chat widget","operationId":"getWidgetAnalytics","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"start_date","in":"query","description":"Start date for analytics","schema":{"type":"string","format":"date-time"}},{"name":"end_date","in":"query","description":"End date for analytics","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Widget analytics data","content":{"application/json":{"schema":{"type":"object","properties":{"sessions":{"type":"object","properties":{"total":{"type":"integer","description":"Total sessions"},"unique_users":{"type":"integer","description":"Unique users"},"average_duration":{"type":"number","description":"Average session duration in seconds"}}},"messages":{"type":"object","properties":{"total":{"type":"integer","description":"Total messages"},"user_messages":{"type":"integer"},"ai_responses":{"type":"integer"}}},"engagement":{"type":"object","properties":{"conversion_rate":{"type":"number","description":"Percentage of visitors who started a chat"},"resolution_rate":{"type":"number","description":"Percentage of resolved conversations"},"satisfaction_score":{"type":"number","description":"Average satisfaction score (1-5)"}}},"popular_topics":{"type":"array","items":{"type":"object","properties":{"topic":{"type":"string"},"count":{"type":"integer"}}}}}}}}}}}},"/widget/embed-code":{"get":{"tags":["Widget"],"summary":"Get widget embed code","description":"Returns the JavaScript embed code for the chat widget","operationId":"getWidgetEmbedCode","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Widget embed code","content":{"application/json":{"schema":{"type":"object","properties":{"embedCode":{"type":"string","description":"HTML/JavaScript embed code"},"scriptUrl":{"type":"string","description":"Widget script URL"},"instructions":{"type":"string","description":"Installation instructions"}}}}}}}}},"/api/v2/ai-assistants":{"get":{"tags":["AI Assistants"],"summary":"Get all AI Assistants","description":"Retrieve a list of all AI Assistants with optional filtering","operationId":"getAllAIAssistants","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"platform","in":"query","description":"Filter by AI platform","required":false,"schema":{"type":"string","enum":["openai","langchain"]}},{"name":"status","in":"query","description":"Filter by status","required":false,"schema":{"type":"string","enum":["active","inactive"]}}],"responses":{"200":{"description":"List of AI Assistants retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AIAssistant"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"post":{"tags":["AI Assistants"],"summary":"Create a new AI Assistant","description":"Create a new AI Assistant with specified configuration","operationId":"createAIAssistant","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAIAssistantRequest"}}}},"responses":{"201":{"description":"AI Assistant created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/available-models":{"get":{"tags":["AI Assistants"],"summary":"Get available AI models","description":"Retrieve a list of available AI models for each platform","operationId":"getAvailableModels","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Available models retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"openai":{"type":"array","items":{"type":"string"}},"langchain":{"type":"array","items":{"type":"string"}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/statistics":{"get":{"tags":["AI Assistants"],"summary":"Get AI Assistant statistics","description":"Retrieve statistics about AI Assistants usage","operationId":"getAIStatistics","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Statistics retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"number"},"active":{"type":"number"},"byPlatform":{"type":"object","properties":{"openai":{"type":"number"},"langchain":{"type":"number"}}},"byModel":{"type":"object","additionalProperties":{"type":"number"}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/templates":{"get":{"tags":["AI Assistants"],"summary":"Get AI Assistant templates","description":"Retrieve available AI Assistant templates","operationId":"getAITemplates","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Templates retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AIAssistantTemplate"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}":{"get":{"tags":["AI Assistants"],"summary":"Get AI Assistant by ID","description":"Retrieve a specific AI Assistant by its ID","operationId":"getAIAssistantById","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"AI Assistant retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"put":{"tags":["AI Assistants"],"summary":"Update AI Assistant","description":"Update an existing AI Assistant","operationId":"updateAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAIAssistantRequest"}}}},"responses":{"200":{"description":"AI Assistant updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"delete":{"tags":["AI Assistants"],"summary":"Delete AI Assistant","description":"Delete an AI Assistant","operationId":"deleteAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"AI Assistant deleted successfully"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/duplicate":{"post":{"tags":["AI Assistants"],"summary":"Duplicate AI Assistant","description":"Create a duplicate of an existing AI Assistant","operationId":"duplicateAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID to duplicate","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Name for the duplicated assistant"}}}}}},"responses":{"201":{"description":"AI Assistant duplicated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/documents":{"get":{"tags":["AI Assistants"],"summary":"Get AI Assistant documents","description":"Get documents assigned to an AI Assistant","operationId":"getAIAssistantDocuments","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Documents retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Document"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/documents/assign":{"post":{"tags":["AI Assistants"],"summary":"Assign documents to AI Assistant","description":"Assign one or more documents to an AI Assistant","operationId":"assignDocumentsToAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["documentIds"],"properties":{"documentIds":{"type":"array","items":{"type":"string"},"description":"Array of document IDs to assign"}}}}}},"responses":{"200":{"description":"Documents assigned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/documents/{documentId}":{"delete":{"tags":["AI Assistants"],"summary":"Unassign document from AI Assistant","description":"Remove a document assignment from an AI Assistant","operationId":"unassignDocumentFromAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}},{"name":"documentId","in":"path","description":"Document ID to unassign","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Document unassigned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/knowledge-config":{"put":{"tags":["AI Assistants"],"summary":"Update AI Assistant knowledge config","description":"Update knowledge configuration for an AI Assistant","operationId":"updateAIAssistantKnowledgeConfig","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"useKnowledge":{"type":"boolean","description":"Enable or disable knowledge base usage"},"knowledgeSearchConfig":{"type":"object","properties":{"topK":{"type":"number"},"threshold":{"type":"number"}}}}}}}},"responses":{"200":{"description":"Knowledge config updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/collections":{"get":{"tags":["AI Assistants"],"summary":"Get AI Assistant collections","description":"Get knowledge collections assigned to an AI Assistant","operationId":"getAIAssistantCollections","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Collections retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeCollection"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/collections/assign":{"post":{"tags":["AI Assistants"],"summary":"Assign collections to AI Assistant","description":"Assign knowledge collections to an AI Assistant","operationId":"assignCollectionsToAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["collectionIds"],"properties":{"collectionIds":{"type":"array","items":{"type":"string"},"description":"Array of collection IDs to assign"}}}}}},"responses":{"200":{"description":"Collections assigned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/collections/{collectionId}":{"delete":{"tags":["AI Assistants"],"summary":"Unassign collection from AI Assistant","description":"Remove a collection assignment from an AI Assistant","operationId":"unassignCollectionFromAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}},{"name":"collectionId","in":"path","description":"Collection ID to unassign","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Collection unassigned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai-assistants/{id}/web-sources/assign":{"post":{"tags":["AI Assistants"],"summary":"Assign web sources to AI Assistant","description":"Assign web source pages to an AI Assistant","operationId":"assignWebSourceToAIAssistant","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"AI Assistant ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["webSourceIds"],"properties":{"webSourceIds":{"type":"array","items":{"type":"string"},"description":"Array of web source IDs to assign"}}}}}},"responses":{"200":{"description":"Web sources assigned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIAssistant"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai/threads/stats":{"get":{"tags":["Thread Management"],"summary":"Get thread statistics","description":"Retrieve statistics about AI conversation threads","operationId":"getThreadStats","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Thread statistics retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"number","description":"Total number of threads"},"active":{"type":"number","description":"Number of active threads"},"byAgent":{"type":"object","description":"Thread count by agent","additionalProperties":{"type":"number"}},"byChannel":{"type":"object","description":"Thread count by channel","additionalProperties":{"type":"number"}},"oldestThread":{"type":"string","format":"date-time","description":"Timestamp of oldest thread"},"newestThread":{"type":"string","format":"date-time","description":"Timestamp of newest thread"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai/threads/list":{"get":{"tags":["Thread Management"],"summary":"List all threads","description":"Get a list of all AI conversation threads","operationId":"listThreads","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"agentId","in":"query","description":"Filter by agent ID","required":false,"schema":{"type":"string"}},{"name":"channelId","in":"query","description":"Filter by channel ID","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"Maximum number of threads to return","required":false,"schema":{"type":"integer","default":100,"minimum":1,"maximum":1000}},{"name":"offset","in":"query","description":"Number of threads to skip","required":false,"schema":{"type":"integer","default":0,"minimum":0}}],"responses":{"200":{"description":"Threads retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"threads":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"threadId":{"type":"string"},"agentId":{"type":"string"},"channelId":{"type":"string"},"userId":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"messageCount":{"type":"number"}}}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai/threads/cleanup":{"post":{"tags":["Thread Management"],"summary":"Clean up old threads","description":"Remove old AI conversation threads to free up resources","operationId":"cleanupOldThreads","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"olderThanDays":{"type":"integer","description":"Delete threads older than this many days","default":30,"minimum":1},"dryRun":{"type":"boolean","description":"If true, only simulate deletion without actually removing","default":false}}}}}},"responses":{"200":{"description":"Cleanup completed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"number","description":"Number of threads deleted"},"remaining":{"type":"number","description":"Number of threads remaining"},"dryRun":{"type":"boolean","description":"Whether this was a dry run"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai/pdf-processing/status":{"get":{"tags":["Thread Management"],"summary":"Get PDF processing status","description":"Check the status and configuration of the PDF processing service","operationId":"checkPDFProcessingStatus","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"PDF processing status retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean","description":"Whether PDF processing is enabled"},"mode":{"type":"string","enum":["basic","enhanced","smart","vision-only"],"description":"Current PDF processing mode"},"visionEnabled":{"type":"boolean","description":"Whether vision processing is enabled"},"maxPagesToConvert":{"type":"number","description":"Maximum pages to convert for vision processing"},"imageQuality":{"type":"string","enum":["low","medium","high"],"description":"Image quality for vision processing"},"readabilityThreshold":{"type":"number","description":"Text readability threshold"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/ai/pdf-processing/test":{"get":{"tags":["Thread Management"],"summary":"Test PDF processing","description":"Test the PDF processing service integration","operationId":"testPDFProcessing","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"PDF processing test completed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the test was successful"},"message":{"type":"string","description":"Test result message"},"details":{"type":"object","description":"Additional test details"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/web-preview":{"post":{"tags":["Web Scraping"],"summary":"Preview URL content","description":"Preview the content that would be extracted from a URL","operationId":"previewUrl","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri","description":"URL to preview"},"options":{"type":"object","properties":{"waitForSelector":{"type":"string","description":"CSS selector to wait for before extraction"},"timeout":{"type":"number","description":"Timeout in milliseconds","default":30000}}}}}}}},"responses":{"200":{"description":"URL content preview successful","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"},"title":{"type":"string"},"description":{"type":"string"},"content":{"type":"string"},"metadata":{"type":"object","properties":{"author":{"type":"string"},"publishedDate":{"type":"string"},"keywords":{"type":"array","items":{"type":"string"}}}},"extractedAt":{"type":"string","format":"date-time"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/sitemap-preview":{"post":{"tags":["Web Scraping"],"summary":"Preview sitemap URLs","description":"Preview URLs that would be extracted from a sitemap","operationId":"previewSitemap","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["sitemapUrl"],"properties":{"sitemapUrl":{"type":"string","format":"uri","description":"URL of the sitemap"},"filters":{"type":"object","properties":{"includePatterns":{"type":"array","items":{"type":"string"},"description":"Regex patterns for URLs to include"},"excludePatterns":{"type":"array","items":{"type":"string"},"description":"Regex patterns for URLs to exclude"},"maxUrls":{"type":"number","description":"Maximum number of URLs to return","default":100}}}}}}}},"responses":{"200":{"description":"Sitemap preview successful","content":{"application/json":{"schema":{"type":"object","properties":{"sitemapUrl":{"type":"string"},"totalUrls":{"type":"number"},"filteredUrls":{"type":"number"},"urls":{"type":"array","items":{"type":"object","properties":{"loc":{"type":"string"},"lastmod":{"type":"string"},"changefreq":{"type":"string"},"priority":{"type":"number"}}}}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/discover-sitemaps":{"post":{"tags":["Web Scraping"],"summary":"Discover sitemaps for a domain","description":"Automatically discover sitemap URLs for a given domain","operationId":"discoverSitemaps","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"Domain to search for sitemaps","example":"example.com"}}}}}},"responses":{"200":{"description":"Sitemap discovery successful","content":{"application/json":{"schema":{"type":"object","properties":{"domain":{"type":"string"},"sitemaps":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"type":{"type":"string","enum":["index","standard","news","video","image"]},"found":{"type":"boolean"}}}}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/web-sources":{"get":{"tags":["Web Scraping"],"summary":"Get all web sources","description":"Retrieve all configured web sources","operationId":"getWebSources","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"status","in":"query","description":"Filter by status","required":false,"schema":{"type":"string","enum":["active","inactive","error"]}}],"responses":{"200":{"description":"Web sources retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/WebSource"}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"post":{"tags":["Web Scraping"],"summary":"Create a web source","description":"Create a new web source for automatic content scraping","operationId":"createWebSource","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","url","type"],"properties":{"name":{"type":"string","description":"Name of the web source"},"url":{"type":"string","format":"uri","description":"URL to scrape (can be a page or sitemap)"},"type":{"type":"string","enum":["page","sitemap"],"description":"Type of web source"},"schedule":{"type":"string","description":"Cron expression for automatic scraping","example":"0 0 * * *"},"config":{"type":"object","properties":{"includePatterns":{"type":"array","items":{"type":"string"}},"excludePatterns":{"type":"array","items":{"type":"string"}},"maxPages":{"type":"number","default":100},"waitForSelector":{"type":"string"}}}}}}}},"responses":{"201":{"description":"Web source created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebSource"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/web-sources/{id}":{"put":{"tags":["Web Scraping"],"summary":"Update a web source","description":"Update an existing web source configuration","operationId":"updateWebSource","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"Web source ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"url":{"type":"string","format":"uri"},"schedule":{"type":"string"},"config":{"type":"object","properties":{"includePatterns":{"type":"array","items":{"type":"string"}},"excludePatterns":{"type":"array","items":{"type":"string"}},"maxPages":{"type":"number"},"waitForSelector":{"type":"string"}}},"status":{"type":"string","enum":["active","inactive"]}}}}}},"responses":{"200":{"description":"Web source updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebSource"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"delete":{"tags":["Web Scraping"],"summary":"Delete a web source","description":"Delete a web source and optionally its scraped content","operationId":"deleteWebSource","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"Web source ID","required":true,"schema":{"type":"string"}},{"name":"deleteContent","in":"query","description":"Also delete scraped content","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"204":{"description":"Web source deleted successfully"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/scraper/status":{"get":{"tags":["Web Scraping"],"summary":"Get scraper status","description":"Get the status of the web scraping service","operationId":"getScraperStatus","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Scraper status retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["running","stopped","error"]},"activeJobs":{"type":"number"},"queuedJobs":{"type":"number"},"completedToday":{"type":"number"},"failedToday":{"type":"number"},"lastRun":{"type":"string","format":"date-time"},"nextScheduledRun":{"type":"string","format":"date-time"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/voice/voices":{"get":{"tags":["Voice"],"summary":"Get available voices","description":"Retrieve a list of all available text-to-speech voices","operationId":"getAvailableVoices","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"language","in":"query","description":"Filter by language code","required":false,"schema":{"type":"string","example":"en-US"}},{"name":"gender","in":"query","description":"Filter by voice gender","required":false,"schema":{"type":"string","enum":["male","female","neutral"]}}],"responses":{"200":{"description":"Voices retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"voiceId":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"gender":{"type":"string"},"provider":{"type":"string"},"sampleUrl":{"type":"string"},"description":{"type":"string"}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/voice/voice/{voiceId}":{"get":{"tags":["Voice"],"summary":"Get voice information","description":"Get detailed information about a specific voice","operationId":"getVoiceInfo","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"voiceId","in":"path","description":"Voice ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Voice information retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"voiceId":{"type":"string"},"name":{"type":"string"},"language":{"type":"string"},"gender":{"type":"string"},"provider":{"type":"string"},"sampleUrl":{"type":"string"},"description":{"type":"string"},"capabilities":{"type":"object","properties":{"ssml":{"type":"boolean"},"streaming":{"type":"boolean"},"customProsody":{"type":"boolean"}}},"supportedFormats":{"type":"array","items":{"type":"string"}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/voice/user-info":{"get":{"tags":["Voice"],"summary":"Get user voice settings","description":"Get current user's voice service information and settings","operationId":"getUserInfo","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"User info retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string"},"preferredVoice":{"type":"string"},"preferredLanguage":{"type":"string"},"settings":{"type":"object","properties":{"speed":{"type":"number"},"pitch":{"type":"number"},"volume":{"type":"number"}}},"usage":{"type":"object","properties":{"charactersUsed":{"type":"number"},"charactersLimit":{"type":"number"},"period":{"type":"string"}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/voice/test-tts":{"post":{"tags":["Voice"],"summary":"Test TTS generation","description":"Test text-to-speech generation with specified parameters","operationId":"testTTS","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","description":"Text to convert to speech","maxLength":5000},"voiceId":{"type":"string","description":"Voice ID to use"},"language":{"type":"string","description":"Language code","default":"en-US"},"format":{"type":"string","enum":["mp3","wav","ogg"],"default":"mp3"},"settings":{"type":"object","properties":{"speed":{"type":"number","minimum":0.5,"maximum":2},"pitch":{"type":"number","minimum":-20,"maximum":20},"volume":{"type":"number","minimum":0,"maximum":1}}}}}}}},"responses":{"200":{"description":"TTS generated successfully","content":{"audio/mpeg":{"schema":{"type":"string","format":"binary"}},"audio/wav":{"schema":{"type":"string","format":"binary"}},"audio/ogg":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/voice/tts/{widgetId}":{"post":{"tags":["Voice"],"summary":"Generate TTS for widget","description":"Generate text-to-speech audio for a widget","operationId":"generateTTS","parameters":[{"name":"widgetId","in":"path","description":"Widget ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","description":"Text to convert to speech","maxLength":5000},"voiceId":{"type":"string","description":"Voice ID to use"},"language":{"type":"string","description":"Language code","default":"en-US"},"format":{"type":"string","enum":["mp3","wav","ogg"],"default":"mp3"}}}}}},"responses":{"200":{"description":"TTS generated successfully","content":{"audio/mpeg":{"schema":{"type":"string","format":"binary"}},"audio/wav":{"schema":{"type":"string","format":"binary"}},"audio/ogg":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/voice/tts-chunks/{widgetId}":{"post":{"tags":["Voice"],"summary":"Generate streaming TTS for widget","description":"Generate text-to-speech audio in chunks for streaming","operationId":"generateTTSChunks","parameters":[{"name":"widgetId","in":"path","description":"Widget ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","description":"Text to convert to speech","maxLength":5000},"voiceId":{"type":"string","description":"Voice ID to use"},"language":{"type":"string","description":"Language code","default":"en-US"},"chunkSize":{"type":"number","description":"Size of each chunk in characters","default":500}}}}}},"responses":{"200":{"description":"TTS chunks generated successfully","content":{"application/x-ndjson":{"schema":{"type":"object","properties":{"chunk":{"type":"number"},"total":{"type":"number"},"audio":{"type":"string","format":"base64"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/voice/stats/{widgetId}":{"get":{"tags":["Voice"],"summary":"Get voice usage statistics","description":"Get voice usage statistics for a specific widget","operationId":"getVoiceStats","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"widgetId","in":"path","description":"Widget ID","required":true,"schema":{"type":"string"}},{"name":"period","in":"query","description":"Time period for statistics","required":false,"schema":{"type":"string","enum":["day","week","month","all"],"default":"month"}}],"responses":{"200":{"description":"Statistics retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"widgetId":{"type":"string"},"period":{"type":"string"},"usage":{"type":"object","properties":{"totalCharacters":{"type":"number"},"totalRequests":{"type":"number"},"uniqueUsers":{"type":"number"},"averageLength":{"type":"number"}}},"byVoice":{"type":"object","additionalProperties":{"type":"object","properties":{"requests":{"type":"number"},"characters":{"type":"number"}}}},"byLanguage":{"type":"object","additionalProperties":{"type":"object","properties":{"requests":{"type":"number"},"characters":{"type":"number"}}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/users":{"get":{"tags":["Users"],"summary":"Get all users","description":"Retrieve a list of all users (admin only)","operationId":"getUsers","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"limit","in":"query","description":"Maximum number of users to return","required":false,"schema":{"type":"integer","default":100,"minimum":1,"maximum":1000}},{"name":"offset","in":"query","description":"Number of users to skip","required":false,"schema":{"type":"integer","default":0,"minimum":0}},{"name":"role","in":"query","description":"Filter by user role","required":false,"schema":{"type":"string","enum":["admin","user","guest"]}}],"responses":{"200":{"description":"Users retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"users":{"type":"array","items":{"$ref":"#/components/schemas/User"}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/users/register":{"post":{"tags":["Users"],"summary":"Register a new user","description":"Create a new user account","operationId":"registerUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password","name"],"properties":{"email":{"type":"string","format":"email","description":"User email address"},"password":{"type":"string","format":"password","minLength":8,"description":"User password"},"name":{"type":"string","description":"User full name"},"username":{"type":"string","description":"Optional username"}}}}}},"responses":{"201":{"description":"User registered successfully","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/User"},"token":{"type":"string","description":"JWT authentication token"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"409":{"description":"User already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/users/login":{"post":{"tags":["Users"],"summary":"Login user","description":"Authenticate user and receive access token","operationId":"loginUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email","description":"User email address"},"password":{"type":"string","format":"password","description":"User password"}}}}}},"responses":{"200":{"description":"Login successful","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"$ref":"#/components/schemas/User"},"token":{"type":"string","description":"JWT authentication token"},"expiresIn":{"type":"string","description":"Token expiration time"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/users/generate-token":{"post":{"tags":["Users"],"summary":"Generate Stream Chat token","description":"Generate a Stream Chat access token for a user","operationId":"generateToken","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["userId"],"properties":{"userId":{"type":"string","description":"User ID to generate token for"},"expiresIn":{"type":"string","description":"Token expiration time","default":"24h"}}}}}},"responses":{"200":{"description":"Token generated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string","description":"Stream Chat access token"},"userId":{"type":"string","description":"User ID the token was generated for"},"expiresAt":{"type":"string","format":"date-time","description":"Token expiration timestamp"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/users/me":{"get":{"tags":["Users"],"summary":"Get current user","description":"Get the currently authenticated user's profile","operationId":"getCurrentUser","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"User profile retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/documents":{"get":{"tags":["Vector Store"],"summary":"Get all documents in vector store","description":"Retrieve all documents stored in the vector database","operationId":"getVectorDocuments","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"limit","in":"query","description":"Maximum number of documents to return","required":false,"schema":{"type":"integer","default":100,"minimum":1,"maximum":1000}},{"name":"offset","in":"query","description":"Number of documents to skip","required":false,"schema":{"type":"integer","default":0,"minimum":0}},{"name":"namespace","in":"query","description":"Filter by namespace","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Documents retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"documents":{"type":"array","items":{"$ref":"#/components/schemas/Document"}},"total":{"type":"number"},"limit":{"type":"number"},"offset":{"type":"number"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"post":{"tags":["Vector Store"],"summary":"Add document to vector store","description":"Add a new document to the vector database with automatic embedding generation","operationId":"addVectorDocument","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["content"],"properties":{"content":{"type":"string","description":"Document content to embed and store"},"metadata":{"type":"object","description":"Additional metadata for the document","properties":{"title":{"type":"string"},"source":{"type":"string"},"author":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}}}},"namespace":{"type":"string","description":"Namespace for document organization"},"chunkSize":{"type":"integer","description":"Size of text chunks for embedding","default":1000},"chunkOverlap":{"type":"integer","description":"Overlap between chunks","default":200}}}}}},"responses":{"201":{"description":"Document added successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/search":{"post":{"tags":["Vector Store"],"summary":"Search vector store","description":"Perform semantic search in the vector database","operationId":"searchVectorStore","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["query"],"properties":{"query":{"type":"string","description":"Search query text"},"topK":{"type":"integer","description":"Number of results to return","default":10,"minimum":1,"maximum":100},"threshold":{"type":"number","description":"Minimum similarity score threshold","default":0.7,"minimum":0,"maximum":1},"namespace":{"type":"string","description":"Limit search to specific namespace"},"filter":{"type":"object","description":"Metadata filters for search","additionalProperties":true},"includeEmbeddings":{"type":"boolean","description":"Include embedding vectors in response","default":false}}}}}},"responses":{"200":{"description":"Search completed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"score":{"type":"number"},"content":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"embedding":{"type":"array","items":{"type":"number"}}}}},"query":{"type":"string"},"totalResults":{"type":"number"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/documents/{id}":{"get":{"tags":["Vector Store"],"summary":"Get document by ID","description":"Retrieve a specific document from the vector store","operationId":"getVectorDocument","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"Document ID","required":true,"schema":{"type":"string"}},{"name":"includeEmbedding","in":"query","description":"Include embedding vector in response","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"Document retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"patch":{"tags":["Vector Store"],"summary":"Update document metadata","description":"Update metadata for a document in the vector store","operationId":"updateVectorDocument","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"Document ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"metadata":{"type":"object","description":"Updated metadata","additionalProperties":true},"reindex":{"type":"boolean","description":"Regenerate embeddings","default":false}}}}}},"responses":{"200":{"description":"Document updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"delete":{"tags":["Vector Store"],"summary":"Delete document from vector store","description":"Remove a document from the vector database","operationId":"deleteVectorDocument","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"id","in":"path","description":"Document ID","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Document deleted successfully"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/knowledge/stats":{"get":{"tags":["Vector Store"],"summary":"Get vector store statistics","description":"Get statistics about the vector database","operationId":"getVectorStats","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Statistics retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"totalDocuments":{"type":"number"},"totalVectors":{"type":"number"},"namespaces":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"documentCount":{"type":"number"},"vectorCount":{"type":"number"}}}},"indexSize":{"type":"number"},"dimension":{"type":"number"},"provider":{"type":"string","enum":["openai","pinecone"]}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/performance/stats":{"get":{"tags":["Observability"],"summary":"Get performance statistics","description":"Retrieve comprehensive performance optimization statistics","operationId":"getPerformanceStats","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Performance statistics retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"healthScore":{"type":"number","description":"Overall health score (0-100)","minimum":0,"maximum":100},"stats":{"type":"object","properties":{"uptime":{"type":"number"},"requests":{"type":"object","properties":{"total":{"type":"number"},"successful":{"type":"number"},"failed":{"type":"number"},"averageResponseTime":{"type":"number"}}},"memory":{"type":"object","properties":{"used":{"type":"number"},"total":{"type":"number"},"percentage":{"type":"number"}}},"cpu":{"type":"object","properties":{"usage":{"type":"number"},"loadAverage":{"type":"array","items":{"type":"number"}}}}}},"optimizations":{"type":"object","properties":{"cacheHitRate":{"type":"number"},"poolUtilization":{"type":"number"},"activeConnections":{"type":"number"}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/performance/pools":{"get":{"tags":["Observability"],"summary":"Get resource pool statistics","description":"Get detailed statistics about resource pools and connections","operationId":"getPoolStats","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Pool statistics retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"pools":{"type":"object","properties":{"database":{"type":"object","properties":{"active":{"type":"number"},"idle":{"type":"number"},"waiting":{"type":"number"},"total":{"type":"number"}}},"cache":{"type":"object","properties":{"size":{"type":"number"},"hits":{"type":"number"},"misses":{"type":"number"},"hitRate":{"type":"number"}}},"agents":{"type":"object","properties":{"active":{"type":"number"},"idle":{"type":"number"},"total":{"type":"number"}}}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/performance/refresh":{"post":{"tags":["Observability"],"summary":"Refresh performance optimizations","description":"Force refresh of performance optimizations and clear caches","operationId":"refreshOptimizations","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"clearCache":{"type":"boolean","description":"Clear all caches","default":true},"resetPools":{"type":"boolean","description":"Reset connection pools","default":false},"gcForce":{"type":"boolean","description":"Force garbage collection","default":false}}}}}},"responses":{"200":{"description":"Optimizations refreshed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"cleared":{"type":"object","properties":{"cache":{"type":"boolean"},"pools":{"type":"boolean"},"gc":{"type":"boolean"}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/logs":{"get":{"tags":["Observability"],"summary":"Get application logs","description":"Retrieve application logs with filtering options","operationId":"getApplicationLogs","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"level","in":"query","description":"Log level filter","required":false,"schema":{"type":"string","enum":["error","warn","info","debug"]}},{"name":"source","in":"query","description":"Log source filter","required":false,"schema":{"type":"string"}},{"name":"from","in":"query","description":"Start timestamp","required":false,"schema":{"type":"string","format":"date-time"}},{"name":"to","in":"query","description":"End timestamp","required":false,"schema":{"type":"string","format":"date-time"}},{"name":"limit","in":"query","description":"Maximum number of logs","required":false,"schema":{"type":"integer","default":100,"minimum":1,"maximum":1000}}],"responses":{"200":{"description":"Logs retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"logs":{"type":"array","items":{"type":"object","properties":{"timestamp":{"type":"string","format":"date-time"},"level":{"type":"string"},"source":{"type":"string"},"message":{"type":"string"},"metadata":{"type":"object","additionalProperties":true}}}},"total":{"type":"number"},"filtered":{"type":"number"}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/metrics":{"get":{"tags":["Observability"],"summary":"Get system metrics","description":"Get system metrics in Prometheus format","operationId":"getSystemMetrics","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Metrics retrieved successfully","content":{"text/plain":{"schema":{"type":"string","example":"# HELP http_requests_total Total HTTP requests\\n# TYPE http_requests_total counter\\nhttp_requests_total{method=\"GET\",status=\"200\"} 1234"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/health/detailed":{"get":{"tags":["Observability"],"summary":"Get detailed health check","description":"Get detailed health status of all system components","operationId":"getDetailedHealth","responses":{"200":{"description":"Health check successful","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["healthy","degraded","unhealthy"]},"uptime":{"type":"number"},"timestamp":{"type":"string","format":"date-time"},"components":{"type":"object","properties":{"database":{"type":"object","properties":{"status":{"type":"string"},"responseTime":{"type":"number"}}},"streamChat":{"type":"object","properties":{"status":{"type":"string"},"responseTime":{"type":"number"}}},"vectorStore":{"type":"object","properties":{"status":{"type":"string"},"responseTime":{"type":"number"}}},"openai":{"type":"object","properties":{"status":{"type":"string"},"responseTime":{"type":"number"}}}}}}}}}},"503":{"description":"Service unhealthy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v2/settings":{"get":{"tags":["Settings"],"summary":"Get application settings","description":"Retrieve current application configuration and settings","operationId":"getSettings","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Settings retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"general":{"type":"object","properties":{"appName":{"type":"string"},"version":{"type":"string"},"environment":{"type":"string","enum":["development","staging","production"]},"timezone":{"type":"string"},"locale":{"type":"string"}}},"ai":{"type":"object","properties":{"defaultProvider":{"type":"string","enum":["openai","langchain"]},"defaultModel":{"type":"string"},"temperature":{"type":"number"},"maxTokens":{"type":"number"},"enableStreaming":{"type":"boolean"},"enableTools":{"type":"boolean"}}},"chat":{"type":"object","properties":{"streamEnabled":{"type":"boolean"},"maxMessageLength":{"type":"number"},"typingIndicator":{"type":"boolean"},"readReceipts":{"type":"boolean"},"messageRetention":{"type":"number"}}},"knowledge":{"type":"object","properties":{"vectorStore":{"type":"string","enum":["openai","pinecone"]},"embeddingModel":{"type":"string"},"chunkSize":{"type":"number"},"chunkOverlap":{"type":"number"},"maxDocumentSize":{"type":"number"}}},"security":{"type":"object","properties":{"apiKeyRequired":{"type":"boolean"},"jwtEnabled":{"type":"boolean"},"rateLimitEnabled":{"type":"boolean"},"rateLimitRequests":{"type":"number"},"rateLimitWindow":{"type":"number"},"corsEnabled":{"type":"boolean"},"allowedOrigins":{"type":"array","items":{"type":"string"}}}},"features":{"type":"object","properties":{"pdfProcessing":{"type":"boolean"},"webScraping":{"type":"boolean"},"voiceEnabled":{"type":"boolean"},"widgetEnabled":{"type":"boolean"},"analyticsEnabled":{"type":"boolean"},"debugMode":{"type":"boolean"}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"500":{"$ref":"#/components/responses/InternalServerError"}}},"put":{"tags":["Settings"],"summary":"Update application settings","description":"Update application configuration and settings","operationId":"updateSettings","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"general":{"type":"object","properties":{"appName":{"type":"string"},"timezone":{"type":"string"},"locale":{"type":"string"}}},"ai":{"type":"object","properties":{"defaultProvider":{"type":"string","enum":["openai","langchain"]},"defaultModel":{"type":"string"},"temperature":{"type":"number","minimum":0,"maximum":2},"maxTokens":{"type":"number","minimum":1},"enableStreaming":{"type":"boolean"},"enableTools":{"type":"boolean"}}},"chat":{"type":"object","properties":{"streamEnabled":{"type":"boolean"},"maxMessageLength":{"type":"number"},"typingIndicator":{"type":"boolean"},"readReceipts":{"type":"boolean"},"messageRetention":{"type":"number"}}},"knowledge":{"type":"object","properties":{"vectorStore":{"type":"string","enum":["openai","pinecone"]},"embeddingModel":{"type":"string"},"chunkSize":{"type":"number"},"chunkOverlap":{"type":"number"},"maxDocumentSize":{"type":"number"}}},"security":{"type":"object","properties":{"rateLimitEnabled":{"type":"boolean"},"rateLimitRequests":{"type":"number"},"rateLimitWindow":{"type":"number"},"corsEnabled":{"type":"boolean"},"allowedOrigins":{"type":"array","items":{"type":"string"}}}},"features":{"type":"object","properties":{"pdfProcessing":{"type":"boolean"},"webScraping":{"type":"boolean"},"voiceEnabled":{"type":"boolean"},"widgetEnabled":{"type":"boolean"},"analyticsEnabled":{"type":"boolean"},"debugMode":{"type":"boolean"}}}}}}}},"responses":{"200":{"description":"Settings updated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"settings":{"type":"object","description":"Updated settings object"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/settings/export":{"get":{"tags":["Settings"],"summary":"Export settings","description":"Export all settings for backup or migration","operationId":"exportSettings","security":[{"ApiKeyAuth":[]}],"parameters":[{"name":"format","in":"query","description":"Export format","required":false,"schema":{"type":"string","enum":["json","yaml"],"default":"json"}},{"name":"includeSecrets","in":"query","description":"Include sensitive configuration","required":false,"schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"Settings exported successfully","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"string"},"exportedAt":{"type":"string","format":"date-time"},"settings":{"type":"object"}}}},"application/x-yaml":{"schema":{"type":"string","description":"YAML formatted settings"}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/settings/import":{"post":{"tags":["Settings"],"summary":"Import settings","description":"Import settings from backup","operationId":"importSettings","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["settings"],"properties":{"settings":{"type":"object","description":"Settings to import"},"merge":{"type":"boolean","description":"Merge with existing settings","default":false},"validate":{"type":"boolean","description":"Validate settings before import","default":true}}}}}},"responses":{"200":{"description":"Settings imported successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"imported":{"type":"number"},"skipped":{"type":"number"},"errors":{"type":"array","items":{"type":"string"}}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/settings/reset":{"post":{"tags":["Settings"],"summary":"Reset settings to defaults","description":"Reset all or specific settings to default values","operationId":"resetSettings","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"sections":{"type":"array","description":"Specific sections to reset","items":{"type":"string","enum":["general","ai","chat","knowledge","security","features"]}},"confirm":{"type":"boolean","description":"Confirmation to reset","default":false}}}}}},"responses":{"200":{"description":"Settings reset successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"resetSections":{"type":"array","items":{"type":"string"}}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/stream/status":{"get":{"tags":["Debug"],"summary":"Get Stream Chat status","description":"Get status of Stream Chat channels and users (development only)","operationId":"getStreamStatus","security":[{"ApiKeyAuth":[]}],"responses":{"200":{"description":"Stream Chat status retrieved successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"channels":{"type":"object","properties":{"total":{"type":"number"},"byType":{"type":"object","additionalProperties":{"type":"number"}},"recent":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"memberCount":{"type":"number"},"messageCount":{"type":"number"},"lastMessageAt":{"type":"string","format":"date-time"}}}}}},"users":{"type":"object","properties":{"total":{"type":"number"},"online":{"type":"number"},"aiUsers":{"type":"number"},"humanUsers":{"type":"number"},"recent":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"role":{"type":"string"},"lastActive":{"type":"string","format":"date-time"}}}}}},"messages":{"type":"object","properties":{"total":{"type":"number"},"today":{"type":"number"},"thisWeek":{"type":"number"},"thisMonth":{"type":"number"}}}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/channels/all":{"delete":{"tags":["Debug"],"summary":"Delete all channels","description":"Delete all channels from Stream Chat (development only)","operationId":"deleteAllChannels","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"confirm":{"type":"boolean","description":"Confirmation flag","default":false},"dryRun":{"type":"boolean","description":"Perform dry run without deleting","default":true}}}}}},"responses":{"200":{"description":"Channels deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"deleted":{"type":"number"},"dryRun":{"type":"boolean"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/users/all":{"delete":{"tags":["Debug"],"summary":"Delete all users","description":"Delete all users from Stream Chat (development only)","operationId":"deleteAllUsers","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"confirm":{"type":"boolean","description":"Confirmation flag","default":false},"dryRun":{"type":"boolean","description":"Perform dry run without deleting","default":true}}}}}},"responses":{"200":{"description":"Users deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"deleted":{"type":"number"},"dryRun":{"type":"boolean"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/users/ai":{"delete":{"tags":["Debug"],"summary":"Delete AI users","description":"Delete only AI users from Stream Chat (development only)","operationId":"deleteAIUsers","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"confirm":{"type":"boolean","description":"Confirmation flag","default":false},"pattern":{"type":"string","description":"Pattern to match AI user IDs","default":"ai-"}}}}}},"responses":{"200":{"description":"AI users deleted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"deleted":{"type":"number"},"pattern":{"type":"string"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/stream/nuclear":{"delete":{"tags":["Debug"],"summary":"Nuclear cleanup","description":"Delete everything from Stream Chat - USE WITH EXTREME CAUTION (development only)","operationId":"nuclearCleanup","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["confirm"],"properties":{"confirm":{"type":"string","description":"Must be \"DELETE_EVERYTHING\" to proceed","enum":["DELETE_EVERYTHING"]}}}}}},"responses":{"200":{"description":"Nuclear cleanup completed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"deleted":{"type":"object","properties":{"channels":{"type":"number"},"users":{"type":"number"},"messages":{"type":"number"}}},"warning":{"type":"string"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/database/reset":{"post":{"tags":["Debug"],"summary":"Reset database","description":"Reset database to initial state (development only)","operationId":"resetDatabase","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"collections":{"type":"array","description":"Specific collections to reset","items":{"type":"string"}},"seed":{"type":"boolean","description":"Seed with sample data","default":false},"confirm":{"type":"boolean","description":"Confirmation flag","default":false}}}}}},"responses":{"200":{"description":"Database reset successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"reset":{"type":"array","items":{"type":"string"}},"seeded":{"type":"boolean"}}}}}},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/cache/clear":{"post":{"tags":["Debug"],"summary":"Clear all caches","description":"Clear all application caches (development only)","operationId":"clearCaches","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"caches":{"type":"array","description":"Specific caches to clear","items":{"type":"string","enum":["redis","memory","vector","agent","all"]}}}}}}},"responses":{"200":{"description":"Caches cleared successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"cleared":{"type":"array","items":{"type":"string"}},"freed":{"type":"object","properties":{"memory":{"type":"number"},"entries":{"type":"number"}}}}}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"403":{"$ref":"#/components/responses/ForbiddenError"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/api/v2/debug/errors/simulate":{"post":{"tags":["Debug"],"summary":"Simulate errors","description":"Simulate various error conditions for testing (development only)","operationId":"simulateErrors","security":[{"ApiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["type"],"properties":{"type":{"type":"string","description":"Error type to simulate","enum":["timeout","rateLimit","database","network","memory","crash"]},"delay":{"type":"number","description":"Delay before error (ms)","default":0},"duration":{"type":"number","description":"Error duration (ms)","default":1000}}}}}},"responses":{"200":{"description":"Error simulated (when recoverable)","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"simulatedError":{"type":"string"}}}}}},"429":{"description":"Rate limit error simulated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Server error simulated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service unavailable simulated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}