{"openapi":"3.0.0","paths":{"/api/sse":{"get":{"operationId":"SseController_sse","parameters":[],"responses":{"200":{"description":""}},"tags":["Sse"]}},"/api/messages":{"post":{"operationId":"SseController_messages","parameters":[],"responses":{"201":{"description":""}},"tags":["Sse"]}},"/api/accounts":{"get":{"operationId":"AccountController_findAll","parameters":[],"responses":{"200":{"description":"A list of accounts associated with the user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListAccountsResponseDto"}}}}},"security":[{"bearer":[]}],"summary":"List all accounts for the current user","tags":["Accounts"]},"post":{"operationId":"AccountController_create","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccountDto"}}}},"responses":{"201":{"description":"Account created successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponseDto"}}}}},"security":[{"bearer":[]}],"summary":"Create a new account","tags":["Accounts"]}},"/api/accounts/{id}":{"patch":{"operationId":"AccountController_update","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAccountDto"}}}},"responses":{"200":{"description":"Account updated successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponseDto"}}}}},"security":[{"bearer":[]}],"summary":"Update an account","tags":["Accounts"]},"delete":{"operationId":"AccountController_delete","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Account deleted successfully."}},"security":[{"bearer":[]}],"summary":"Delete an account","tags":["Accounts"]}},"/api/users":{"get":{"description":"Retrieve a list of all users in the system","operationId":"UserController_findAll","parameters":[],"responses":{"200":{"description":""}},"summary":"Get all users","tags":["User Management"]}},"/api/users/{id}":{"get":{"description":"Retrieve a specific user by their unique identifier","operationId":"UserController_findOne","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}},{"name":"page","required":false,"in":"query","description":"Page number (1-based)","schema":{"minimum":1,"default":1,"example":1,"type":"number"}},{"name":"limit","required":false,"in":"query","description":"Number of items per page","schema":{"minimum":1,"maximum":2000,"default":10,"example":10,"type":"number"}},{"name":"relations","required":false,"in":"query","description":"Relations to include in the response. Use dot notation for nested relations.","schema":{"example":["company","company.accounts"],"type":"array","items":{"type":"string"}}},{"name":"select","required":false,"in":"query","description":"Fields to select in the response","schema":{"example":["id","email","firstName","lastName"],"type":"array","items":{"type":"string"}}},{"name":"sort","required":false,"in":"query","description":"Sort configuration. Can be a single field or multiple fields.","schema":{"type":"array","items":{"$ref":"#/components/schemas/SortField"}}},{"name":"filters","required":false,"in":"query","description":"Filter conditions as JSON object","schema":{"$ref":"#/components/schemas/Object"}}],"responses":{"200":{"description":""}},"summary":"Get user by ID","tags":["User Management"]}},"/api/users/account/users":{"get":{"operationId":"UserController_getAccountUsers","parameters":[],"responses":{"200":{"description":""}},"summary":"Get all users in the active account","tags":["User Management"]}},"/api/users/invite":{"post":{"operationId":"UserController_inviteUser","parameters":[],"responses":{"201":{"description":""}},"summary":"Invite user to the active account (Admin only)","tags":["User Management"]}},"/api/users/account/user/{userId}":{"delete":{"operationId":"UserController_removeUserFromAccount","parameters":[{"name":"userId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Remove user from active account (Admin only)","tags":["User Management"]}},"/api/users/preferred-language":{"put":{"operationId":"UserController_updatePreferredLanguage","parameters":[],"responses":{"200":{"description":""}},"summary":"Update user preferred language","tags":["User Management"]}},"/api/inbox/{id}":{"get":{"description":"Gets an inbox by id","operationId":"InboxController_getInbox","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get inbox","tags":["Inbox Management"]},"delete":{"description":"Deletes an inbox","operationId":"InboxController_deleteInbox","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Delete inbox","tags":["Inbox Management"]}},"/api/inbox":{"get":{"description":"Gets all inboxes","operationId":"InboxController_getInboxes","parameters":[],"responses":{"200":{"description":""}},"summary":"Get inboxes","tags":["Inbox Management"]}},"/api/inbox/whatsapp/oauth/config":{"get":{"description":"Returns the Meta App ID and config ID needed to initialize the Embedded Signup SDK on the frontend","operationId":"InboxController_getWhatsAppOAuthConfig","parameters":[],"responses":{"200":{"description":""}},"summary":"Get WhatsApp OAuth configuration","tags":["Inbox Management"]}},"/api/inbox/whatsapp/oauth/callback":{"post":{"description":"Processes the OAuth callback from Facebook Embedded Signup. Exchanges code for token, assigns System User to WABA, and creates inbox.","operationId":"InboxController_handleWhatsAppOAuthCallback","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsAppOAuthCallbackDto"}}}},"responses":{"201":{"description":""}},"summary":"Process WhatsApp OAuth callback","tags":["Inbox Management"]}},"/api/inbox/{id}/connection-status":{"get":{"description":"Returns the current connection state and QR code (if connecting) for an Evolution inbox","operationId":"InboxController_getConnectionStatus","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get Evolution connection status","tags":["Inbox Management"]}},"/api/inbox/{id}/qr-code":{"get":{"description":"Returns the QR code for linking a WhatsApp account to an Evolution inbox","operationId":"InboxController_getQrCode","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get Evolution QR code","tags":["Inbox Management"]}},"/api/inbox/{id}/reconnect":{"post":{"description":"Restarts the Evolution instance and generates a new QR code for reconnection","operationId":"InboxController_reconnect","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":""}},"summary":"Reconnect Evolution instance","tags":["Inbox Management"]}},"/api/conversations/search":{"post":{"description":"Use this endpoint for complex custom field queries instead of GET with query parameters. Supports nested JSON paths and includes unread message counts.","operationId":"ConversationController_search","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldQueryRequest"}}}},"responses":{"200":{"description":""}},"summary":"Search conversations with custom field filters (POST for complex queries)","tags":["Conversations"]}},"/api/conversations/statistics":{"get":{"description":"Returns average response time, new conversations count, and total conversations for a given period","operationId":"ConversationController_getStatistics","parameters":[{"name":"period","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get conversation statistics for dashboard","tags":["Conversations"]}},"/api/conversations/{id}":{"get":{"operationId":"ConversationController_findOne","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get a conversation by ID","tags":["Conversations"]},"patch":{"operationId":"ConversationController_update","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateConversationDto"}}}},"responses":{"200":{"description":""}},"summary":"Update a conversation","tags":["Conversations"]},"delete":{"description":"Permanently delete a conversation and all related messages (hard delete)","operationId":"ConversationController_delete","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Delete a conversation","tags":["Conversations"]}},"/api/conversations/counts":{"post":{"description":"Returns counts for all, mine, and unassigned conversations with applied filters (tags, unread, etc.)","operationId":"ConversationController_getCounts","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldQueryRequest"}}}},"responses":{"200":{"description":""}},"summary":"Get conversation counts by assignment filter with additional filters","tags":["Conversations"]}},"/api/conversations/{id}/transcript":{"get":{"description":"Returns a text/plain transcript of the conversation suitable for AI training, with role and timestamp annotations.","operationId":"ConversationController_transcript","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Export conversation as plain-text transcript","tags":["Conversations"]}},"/api/conversation-messages/search":{"post":{"description":"Use this endpoint for complex queries instead of GET with query parameters.","operationId":"ConversationMessageController_search","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BaseQueryRequest"}}}},"responses":{"200":{"description":""}},"summary":"Search conversation messages (POST for complex queries)","tags":["Conversation Messages"]}},"/api/conversation-messages":{"post":{"description":"Sends a message to a conversation using the channel processor","operationId":"ConversationMessageController_create","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateConversationMessageDto"}}}},"responses":{"201":{"description":""}},"summary":"Send a message to a conversation","tags":["Conversation Messages"]}},"/api/bots":{"get":{"operationId":"BotController_findAll","parameters":[{"name":"page","required":false,"in":"query","description":"Page number (1-based)","schema":{"minimum":1,"default":1,"example":1,"type":"number"}},{"name":"limit","required":false,"in":"query","description":"Number of items per page","schema":{"minimum":1,"maximum":2000,"default":10,"example":10,"type":"number"}},{"name":"relations","required":false,"in":"query","description":"Relations to include in the response. Use dot notation for nested relations.","schema":{"example":["company","company.accounts"],"type":"array","items":{"type":"string"}}},{"name":"select","required":false,"in":"query","description":"Fields to select in the response","schema":{"example":["id","email","firstName","lastName"],"type":"array","items":{"type":"string"}}},{"name":"sort","required":false,"in":"query","description":"Sort configuration. Can be a single field or multiple fields.","schema":{"type":"array","items":{"$ref":"#/components/schemas/SortField"}}},{"name":"filters","required":false,"in":"query","description":"Filter conditions as JSON object","schema":{"$ref":"#/components/schemas/Object"}}],"responses":{"200":{"description":""}},"summary":"Get all bots for the active account","tags":["Bot"]},"post":{"operationId":"BotController_create","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrUpdateBotDto"}}}},"responses":{"201":{"description":""}},"summary":"Create a new bot","tags":["Bot"]}},"/api/bots/{id}":{"get":{"operationId":"BotController_findOne","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get a bot by ID","tags":["Bot"]},"put":{"operationId":"BotController_update","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrUpdateBotDto"}}}},"responses":{"200":{"description":""}},"summary":"Update a bot","tags":["Bot"]},"delete":{"operationId":"BotController_delete","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Delete a bot","tags":["Bot"]}},"/api/contacts/search":{"get":{"description":"Alias for GET /contacts with query parameters. Use POST /contacts/search for complex JSON body queries.","operationId":"ContactController_searchGet","parameters":[{"name":"page","required":false,"in":"query","description":"Page number (1-based)","schema":{"minimum":1,"default":1,"example":1,"type":"number"}},{"name":"limit","required":false,"in":"query","description":"Number of items per page","schema":{"minimum":1,"maximum":2000,"default":10,"example":10,"type":"number"}},{"name":"relations","required":false,"in":"query","description":"Relations to include in the response. Use dot notation for nested relations.","schema":{"example":["company","company.accounts"],"type":"array","items":{"type":"string"}}},{"name":"select","required":false,"in":"query","description":"Fields to select in the response","schema":{"example":["id","email","firstName","lastName"],"type":"array","items":{"type":"string"}}},{"name":"sort","required":false,"in":"query","description":"Sort configuration. Can be a single field or multiple fields.","schema":{"type":"array","items":{"$ref":"#/components/schemas/SortField"}}},{"name":"filters","required":false,"in":"query","description":"Filter conditions as JSON object","schema":{"$ref":"#/components/schemas/Object"}},{"name":"customFieldFilters","required":false,"in":"query","description":"Filter by custom field values using JSON path queries","schema":{"$ref":"#/components/schemas/Object"}},{"name":"customFieldSearch","required":false,"in":"query","description":"Search text within custom field values","schema":{"example":"urgent task","type":"string"}},{"name":"search","required":false,"in":"query","description":"Search text across name, email, and phone fields","schema":{"example":"john doe","type":"string"}},{"name":"tags","required":false,"in":"query","description":"Filter by tags - returns entities that contain any of the specified tags","schema":{"example":["urgent","customer-support","follow-up"],"type":"array","items":{"type":"string"}}},{"name":"customFieldSort","required":false,"in":"query","description":"Sort by custom field (use customFields.fieldName format)","schema":{"example":"customFields.priority","type":"string"}},{"name":"customFieldGroupBy","required":false,"in":"query","description":"Group by custom field (use customFields.fieldName format)","schema":{"example":"customFields.status","type":"string"}},{"name":"showUnreadOnly","required":false,"in":"query","description":"Filter to show only unread conversations","schema":{"example":true,"type":"boolean"}},{"name":"currentUserId","required":false,"in":"query","description":"Current user ID for filtering \"mine\" conversations in count queries","schema":{"example":"user-123","type":"string"}}],"responses":{"200":{"description":""}},"summary":"Search contacts with custom field filters (GET for simple queries)","tags":["Contacts"]},"post":{"description":"Use this endpoint for complex custom field queries instead of GET with query parameters. Supports nested JSON paths like \"customFields.contactData.lastContactDateTime\".","operationId":"ContactController_search","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldQueryRequest"}}}},"responses":{"200":{"description":""}},"summary":"Search contacts with custom field filters (POST for complex queries)","tags":["Contacts"]}},"/api/contacts/{id}":{"get":{"operationId":"ContactController_findOne","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get a contact by ID","tags":["Contacts"]},"patch":{"operationId":"ContactController_update","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOrCreateContactDto"}}}},"responses":{"200":{"description":""}},"summary":"Update a contact","tags":["Contacts"]},"delete":{"operationId":"ContactController_delete","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Delete a contact and its conversations","tags":["Contacts"]}},"/api/contacts":{"post":{"operationId":"ContactController_create","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateOrCreateContactDto"}}}},"responses":{"201":{"description":""}},"summary":"Create a new contact","tags":["Contacts"]}},"/api/custom-field-definitions":{"get":{"operationId":"CustomFieldDefinitionController_findAll","parameters":[{"name":"includeHidden","required":true,"in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":""}},"summary":"Get all custom field definitions for account","tags":["Custom Field Definitions"]},"post":{"operationId":"CustomFieldDefinitionController_create","parameters":[],"responses":{"201":{"description":""}},"summary":"Create a new custom field definition","tags":["Custom Field Definitions"]}},"/api/custom-field-definitions/{id}":{"get":{"operationId":"CustomFieldDefinitionController_findById","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get a custom field definition by ID","tags":["Custom Field Definitions"]},"put":{"operationId":"CustomFieldDefinitionController_update","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Update a custom field definition","tags":["Custom Field Definitions"]},"delete":{"operationId":"CustomFieldDefinitionController_delete","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Delete a custom field definition","tags":["Custom Field Definitions"]}},"/api/custom-field-definitions/scope/{scope}":{"get":{"operationId":"CustomFieldDefinitionController_findByScope","parameters":[],"responses":{"200":{"description":""}},"summary":"Get custom field definitions by scope","tags":["Custom Field Definitions"]}},"/api/knowledge-documents":{"post":{"description":"Upload and process a document to create a new knowledge document with vector embeddings","operationId":"KnowledgeDocumentController_create","parameters":[],"requestBody":{"required":true,"description":"Knowledge document data with file upload","content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary","description":"The document file to upload (PDF only, max 10MB)"},"name":{"type":"string","description":"Name of the knowledge document","example":"Product Manual v2.1"},"description":{"type":"string","description":"Description of the knowledge document","example":"Comprehensive product manual covering all features"},"type":{"type":"string","enum":["pdf"],"description":"Type of the document","example":"pdf"},"metadata":{"type":"object","description":"Additional metadata for the document","example":{"version":"2.1","category":"product"}}},"required":["file","name","type"]}}}},"responses":{"201":{"description":"Knowledge document created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeDocumentResponseDto"}}}},"400":{"description":"Invalid file type or missing required fields"}},"summary":"Create a new knowledge document","tags":["Knowledge Documents"]},"get":{"description":"Retrieve all knowledge documents belonging to the current account","operationId":"KnowledgeDocumentController_findAll","parameters":[],"responses":{"200":{"description":"Knowledge documents retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeDocumentResponseDto"}}}}}},"summary":"Get all knowledge documents for the account","tags":["Knowledge Documents"]}},"/api/knowledge-documents/query":{"post":{"description":"Search for relevant document chunks using vector similarity search","operationId":"KnowledgeDocumentController_query","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueryDocumentsDto"}}}},"responses":{"200":{"description":"Query results returned successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueryDocumentsResponseDto"}}}},"400":{"description":"Invalid query parameters"}},"summary":"Query knowledge documents","tags":["Knowledge Documents"]}},"/api/knowledge-documents/bot/{botId}":{"get":{"description":"Retrieve all knowledge documents associated with a specific bot","operationId":"KnowledgeDocumentController_findByBotId","parameters":[{"name":"botId","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Knowledge documents retrieved successfully","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeDocumentResponseDto"}}}}}},"summary":"Get knowledge documents for a specific bot","tags":["Knowledge Documents"]}},"/api/knowledge-documents/{id}":{"get":{"description":"Retrieve a specific knowledge document by its unique identifier","operationId":"KnowledgeDocumentController_findOne","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Knowledge document retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeDocumentResponseDto"}}}},"404":{"description":"Knowledge document not found"}},"summary":"Get a knowledge document by ID","tags":["Knowledge Documents"]},"delete":{"description":"Delete a knowledge document and all its associated chunks","operationId":"KnowledgeDocumentController_remove","parameters":[{"name":"id","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Knowledge document deleted successfully"},"404":{"description":"Knowledge document not found"}},"summary":"Delete a knowledge document","tags":["Knowledge Documents"]}},"/api/media/upload":{"post":{"description":"Upload a media file to cloud storage. Files are deduplicated by content hash within the account.","operationId":"MediaController_uploadMedia","parameters":[],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/UploadMediaDto"}}}},"responses":{"201":{"description":"Media uploaded successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MediaFile"}}}},"400":{"description":"Invalid file or file too large"}},"summary":"Upload media file","tags":["Media"]}},"/api/media":{"get":{"description":"Get paginated list of media files with filtering options","operationId":"MediaController_getMediaFiles","parameters":[{"name":"scope","required":false,"in":"query","description":"Filter by media scope","schema":{"type":"string","enum":["account","conversation"]}},{"name":"search","required":false,"in":"query","description":"Search in filename","schema":{"type":"string"}},{"name":"mimeType","required":false,"in":"query","description":"Filter by MIME type (e.g., \"image/\", \"video/\", \"application/pdf\")","schema":{"type":"string"}},{"name":"page","required":false,"in":"query","description":"Page number (1-based)","schema":{"minimum":1,"default":1,"type":"number"}},{"name":"limit","required":false,"in":"query","description":"Items per page","schema":{"minimum":1,"maximum":100,"default":20,"type":"number"}},{"name":"uploadedBy","required":false,"in":"query","description":"Filter by uploader user ID","schema":{"type":"string"}}],"responses":{"200":{"description":"Media files retrieved successfully"}},"summary":"Get media files","tags":["Media"]}},"/api/media/stats":{"get":{"description":"Get storage usage statistics for the account","operationId":"MediaController_getStorageStats","parameters":[],"responses":{"200":{"description":"Storage statistics retrieved successfully"}},"summary":"Get storage statistics","tags":["Media"]}},"/api/media/{id}":{"get":{"description":"Get detailed information about a specific media file","operationId":"MediaController_getMediaById","parameters":[{"name":"id","required":true,"in":"path","description":"Media file ID","schema":{"type":"string"}}],"responses":{"200":{"description":"Media file retrieved successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MediaFile"}}}},"404":{"description":"Media file not found"}},"summary":"Get media file by ID","tags":["Media"]},"delete":{"description":"Delete a media file from cloud storage and database","operationId":"MediaController_deleteMedia","parameters":[{"name":"id","required":true,"in":"path","description":"Media file ID","schema":{"type":"string"}}],"responses":{"204":{"description":"Media file deleted successfully"},"404":{"description":"Media file not found"}},"summary":"Delete media file","tags":["Media"]}},"/api/media/{id}/presigned-url":{"post":{"description":"Generate a temporary pre-signed URL for direct media access","operationId":"MediaController_generatePreSignedUrl","parameters":[{"name":"id","required":true,"in":"path","description":"Media file ID","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PreSignedUrlDto"}}}},"responses":{"200":{"description":"Pre-signed URL generated successfully","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","description":"Pre-signed URL for main media file"},"expiresAt":{"type":"string","format":"date-time","description":"URL expiration time"},"thumbnailUrl":{"type":"string","description":"Pre-signed URL for thumbnail (if available)","nullable":true}}}}}},"404":{"description":"Media file not found"}},"summary":"Generate pre-signed URL","tags":["Media"]}},"/api/media/bulk":{"delete":{"description":"Delete multiple media files from cloud storage and database","operationId":"MediaController_bulkDeleteMedia","parameters":[],"responses":{"204":{"description":"Media files deleted successfully"},"404":{"description":"One or more media files not found"}},"summary":"Bulk delete media files","tags":["Media"]}},"/api/used-tags":{"get":{"description":"Returns used tags for a specific source type with optional search and limit","operationId":"UsedTagsController_getUsedTags","parameters":[{"name":"sourceType","required":true,"in":"query","description":"Type of entity to get tags for","schema":{"enum":["contact","conversation"],"type":"string"}},{"name":"searchTerm","required":false,"in":"query","description":"Search term to filter tags","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"Maximum number of tags to return (default: 10)","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get used tags with filtering","tags":["Used Tags"]}},"/api/used-tags/suggestions":{"get":{"description":"Returns tag suggestions based on previously used tags for a specific source type (contact or conversation)","operationId":"UsedTagsController_getTagSuggestions","parameters":[{"name":"sourceType","required":true,"in":"query","description":"Type of entity to get suggestions for","schema":{"enum":["contact","conversation"],"type":"string"}},{"name":"search","required":false,"in":"query","description":"Search term to filter suggestions","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"Maximum number of suggestions to return (default: 10)","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get tag suggestions for autocomplete","tags":["Used Tags"]}},"/api/used-tags/summary":{"get":{"description":"Returns summary of all tags with usage counts across both contacts and conversations","operationId":"UsedTagsController_getTagsSummary","parameters":[{"name":"search","required":false,"in":"query","description":"Search term to filter tags","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"Maximum number of tags to return","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get aggregated tag usage summary","tags":["Used Tags"]}},"/api/used-tags/all":{"get":{"description":"Returns all unique tags used in the account for filtering purposes","operationId":"UsedTagsController_getAllTagsForAccount","parameters":[],"responses":{"200":{"description":""}},"summary":"Get all unique tags for the account","tags":["Used Tags"]}},"/api/used-tags/by-source/{sourceType}":{"get":{"description":"Returns tags used for a specific source type (contact or conversation)","operationId":"UsedTagsController_getTagsBySourceType","parameters":[{"name":"sourceType","required":true,"in":"path","schema":{"type":"string"}},{"name":"search","required":false,"in":"query","description":"Search term to filter tags","schema":{"type":"string"}},{"name":"limit","required":false,"in":"query","description":"Maximum number of tags to return","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get tags filtered by source type","tags":["Used Tags"]}},"/api/used-tags/stats/{tag}":{"get":{"description":"Returns detailed usage statistics for a specific tag","operationId":"UsedTagsController_getTagUsageStats","parameters":[{"name":"tag","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":""}},"summary":"Get usage statistics for a specific tag","tags":["Used Tags"]}},"/api/webhooks/whatsapp":{"get":{"description":"Handles webhook verification from Meta. Returns hub.challenge if verify_token matches.","operationId":"WhatsAppWebhookController_verifyWebhook","parameters":[{"name":"hub.mode","required":true,"in":"query","schema":{"type":"string"}},{"name":"hub.verify_token","required":true,"in":"query","schema":{"type":"string"}},{"name":"hub.challenge","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Verification successful"},"403":{"description":"Verification failed - token mismatch"}},"summary":"Verify WhatsApp webhook","tags":["Webhooks"]}}},"info":{"title":"Kuantia CRM API","description":"Kuantia CRM API Documentation","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"ListAccountResponseAccountElement":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the account","example":"uuid-123e4567-e89b-12d3-a456-426614174000"},"name":{"type":"string","description":"Display name of the account","example":"Acme Corp Customer Support"},"description":{"type":"string","description":"Account description","example":"This account handles customer support for the EMEA region"},"role":{"type":"string","description":"User role within this account","enum":["admin","user"],"example":"admin"},"createdAt":{"format":"date-time","type":"string","description":"Account creation timestamp","example":"2024-01-15T10:30:00Z"},"updatedAt":{"format":"date-time","type":"string","description":"Last update timestamp","example":"2024-01-20T14:45:00Z"}},"required":["id","name","role","createdAt","updatedAt"]},"ListAccountsResponseDto":{"type":"object","properties":{"accounts":{"description":"List of accounts accessible to the user","type":"array","items":{"$ref":"#/components/schemas/ListAccountResponseAccountElement"}}},"required":["accounts"]},"CreateAccountDto":{"type":"object","properties":{"name":{"type":"string","description":"Display name of the account","example":"My New Account","minLength":1}},"required":["name"]},"AccountResponseDto":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the account","example":"uuid-123e4567-e89b-12d3-a456-426614174000"},"name":{"type":"string","description":"Display name of the account","example":"Acme Corp Customer Support"},"description":{"type":"string","description":"Account description","example":"This account handles customer support for the EMEA region"},"role":{"type":"string","description":"User role within this account","enum":["admin","user"],"example":"admin"},"createdAt":{"format":"date-time","type":"string","description":"Account creation timestamp","example":"2024-01-15T10:30:00Z"},"updatedAt":{"format":"date-time","type":"string","description":"Last update timestamp","example":"2024-01-20T14:45:00Z"}},"required":["id","name","role","createdAt","updatedAt"]},"UpdateAccountDto":{"type":"object","properties":{"name":{"type":"string","description":"Display name of the account","example":"Updated Account Name","minLength":1},"description":{"type":"string","description":"Account description","example":"This account handles customer support for the EMEA region"}}},"SortField":{"type":"object","properties":{"field":{"type":"string","description":"Field name to sort by","example":"createdAt"},"order":{"type":"string","description":"Sort order","enum":["ASC","DESC"],"example":"DESC"}}},"Object":{"type":"object","properties":{}},"WhatsAppOAuthCallbackDto":{"type":"object","properties":{"code":{"type":"string","description":"Authorization code from Facebook Embedded Signup","example":"AQDHzK..."},"phoneNumberId":{"type":"string","description":"Phone Number ID from Embedded Signup response (optional - extracted from token if not provided)","example":"123456789012345"},"wabaId":{"type":"string","description":"WABA ID from Embedded Signup response (optional - extracted from token if not provided)","example":"123456789012345"},"inboxName":{"type":"string","description":"Name for the inbox to be created","example":"My WhatsApp Business","minLength":1}},"required":["code","inboxName"]},"CustomFieldQueryRequest":{"type":"object","properties":{"page":{"type":"number","description":"Page number (1-based)","minimum":1,"default":1,"example":1},"limit":{"type":"number","description":"Number of items per page","minimum":1,"maximum":2000,"default":10,"example":10},"relations":{"description":"Relations to include in the response. Use dot notation for nested relations.","example":["company","company.accounts"],"type":"array","items":{"type":"string"}},"select":{"description":"Fields to select in the response","example":["id","email","firstName","lastName"],"type":"array","items":{"type":"string"}},"sort":{"description":"Sort configuration. Can be a single field or multiple fields.","example":[{"field":"createdAt","order":"DESC"}],"type":"array","items":{"$ref":"#/components/schemas/SortField"}},"filters":{"type":"object","description":"Filter conditions as JSON object","example":{"company.id":"123e4567-e89b-12d3-a456-426614174000"}},"customFieldFilters":{"type":"object","description":"Filter by custom field values using JSON path queries","example":{"customFields.status":"active","customFields.priority":{"$in":["high","medium"]},"customFields.tags":{"$contains":"urgent"},"customFields.createdDate":{"$gte":"2024-01-01"},"customFields.score":{"$gt":50},"customFields.isActive":{"$exists":true}}},"customFieldSearch":{"type":"string","description":"Search text within custom field values","example":"urgent task"},"search":{"type":"string","description":"Search text across name, email, and phone fields","example":"john doe"},"tags":{"description":"Filter by tags - returns entities that contain any of the specified tags","example":["urgent","customer-support","follow-up"],"type":"array","items":{"type":"string"}},"customFieldSort":{"type":"string","description":"Sort by custom field (use customFields.fieldName format)","example":"customFields.priority"},"customFieldGroupBy":{"type":"string","description":"Group by custom field (use customFields.fieldName format)","example":"customFields.status"},"showUnreadOnly":{"type":"boolean","description":"Filter to show only unread conversations","example":true},"currentUserId":{"type":"string","description":"Current user ID for filtering \"mine\" conversations in count queries","example":"user-123"}}},"UpdateConversationDto":{"type":"object","properties":{"disableBotCall":{"type":"boolean","description":"Whether to disable bot calls for this conversation","example":true},"assigneeId":{"type":"string","description":"The ID of the user assigned to this conversation. Set to \"UNASSIGN\" to unassign.","example":"user-id-123"},"tags":{"description":"Tags for the conversation","example":["urgent","customer-support"],"type":"array","items":{"type":"string"}},"customFields":{"type":"object","description":"Custom fields for the conversation","example":{}}}},"BaseQueryRequest":{"type":"object","properties":{"page":{"type":"number","description":"Page number (1-based)","minimum":1,"default":1,"example":1},"limit":{"type":"number","description":"Number of items per page","minimum":1,"maximum":2000,"default":10,"example":10},"relations":{"description":"Relations to include in the response. Use dot notation for nested relations.","example":["company","company.accounts"],"type":"array","items":{"type":"string"}},"select":{"description":"Fields to select in the response","example":["id","email","firstName","lastName"],"type":"array","items":{"type":"string"}},"sort":{"description":"Sort configuration. Can be a single field or multiple fields.","example":[{"field":"createdAt","order":"DESC"}],"type":"array","items":{"$ref":"#/components/schemas/SortField"}},"filters":{"type":"object","description":"Filter conditions as JSON object","example":{"company.id":"123e4567-e89b-12d3-a456-426614174000"}}}},"CreateConversationMessageDto":{"type":"object","properties":{"conversationId":{"type":"string","description":"The ID of the conversation to send the message to. If not provided, a new conversation will be created."},"message":{"type":"string","description":"The message to send"},"type":{"type":"string","description":"The type of the message","enum":["USER","BOT","NOTE"]},"messageType":{"type":"string","description":"The type of the message","example":"TEXT","enum":["TEXT","IMAGE","AUDIO","VIDEO","FILE","CONTACT_CARD"]},"content":{"type":"object","description":"Additional metadata for the message. Shape depends on messageType:\n- TEXT: {} (empty, put text in \"message\" field)\n- CONTACT_CARD: { contact: { name, phone } }\n- IMAGE/VIDEO/AUDIO/FILE: { media: { mediaFileId, caption?, filename? } }\n- Template (TEXT): { template: { templateName, language, parameters? } }","additionalProperties":true,"examples":{"text":{"summary":"Plain text (TEXT)","value":{}},"contact":{"summary":"Contact card (CONTACT_CARD)","value":{"contact":{"name":"John Doe","phone":"+34612345678"}}},"media":{"summary":"Media — image, video, audio or file (IMAGE/VIDEO/AUDIO/FILE)","value":{"media":{"mediaFileId":"uuid-of-uploaded-file","caption":"Optional caption","filename":"document.pdf"}}},"template":{"summary":"WhatsApp template (TEXT)","value":{"template":{"templateName":"my_template","language":"en_US","parameters":[{"type":"body","values":[{"type":"text","text":"replacement value"}]}]}}}}},"inboxId":{"type":"string","description":"Required when conversationId is not provided. The ID of the inbox to send the message through."},"contactId":{"type":"string","description":"Required when conversationId is not provided. The ID of the existing contact to send the message to."}},"required":["message","type","messageType","content"]},"CreateOrUpdateBotDto":{"type":"object","properties":{"name":{"type":"string","description":"The name of the bot","example":"My Bot"},"profilePicturePath":{"type":"string","description":"The profile picture path of the bot","example":"https://example.com/profile-picture.png"},"description":{"type":"string","description":"The description of the bot","example":"This is my bot"},"webhookUrl":{"type":"string","description":"The webhook URL of the bot","example":"https://example.com/webhook"},"inboxesIds":{"description":"The inboxes IDs of the bot","example":["123e4567-e89b-12d3-a456-426614174000"],"type":"array","items":{"type":"string"}}},"required":["name","profilePicturePath","description","webhookUrl","inboxesIds"]},"UpdateOrCreateContactDto":{"type":"object","properties":{"id":{"type":"string","description":"Contact ID","example":"123e4567-e89b-12d3-a456-426614174000"},"name":{"type":"string","description":"Contact name","example":"John Doe"},"email":{"type":"string","description":"Contact email address","example":"john.doe@example.com"},"phone":{"type":"string","description":"Contact phone number","example":"+1234567890"},"profilePictureUrl":{"type":"string","description":"Profile picture URL","example":"https://example.com/profile.jpg"},"tags":{"description":"Tags for the contact","example":["vip","customer-support","follow-up"],"type":"array","items":{"type":"string"}},"customFields":{"type":"object","description":"Custom fields for the contact","example":{"customer_type":"enterprise","lead_source":"website","deal_value":75000,"last_contact_date":"2024-01-15T10:30:00Z"}}},"required":["id"]},"KnowledgeDocumentResponseDto":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the knowledge document","example":"123e4567-e89b-12d3-a456-426614174000"},"name":{"type":"string","description":"Name of the knowledge document","example":"Product Manual v2.1"},"description":{"type":"string","description":"Description of the knowledge document","example":"Comprehensive product manual covering all features and troubleshooting","nullable":true},"type":{"type":"string","description":"Type of the document","enum":["pdf"],"example":"pdf"},"filePath":{"type":"string","description":"File path where the document is stored","example":"/uploads/documents/product-manual-v2.1.pdf"},"originalFilename":{"type":"string","description":"Original filename when uploaded","example":"product-manual-v2.1.pdf"},"fileSize":{"type":"number","description":"File size in bytes","example":2048576},"mimeType":{"type":"string","description":"MIME type of the file","example":"application/pdf"},"chunkCount":{"type":"number","description":"Number of chunks this document was split into","example":15},"tokenCount":{"type":"number","description":"Total number of tokens in the document","example":2500},"metadata":{"type":"object","description":"Additional metadata for the document","example":{"version":"2.1","category":"product","tags":["manual","troubleshooting"]},"nullable":true},"accountId":{"type":"string","description":"Account ID that owns this document","example":"123e4567-e89b-12d3-a456-426614174000"},"createdAt":{"format":"date-time","type":"string","description":"Creation timestamp","example":"2024-01-15T10:30:00Z"},"updatedAt":{"format":"date-time","type":"string","description":"Last update timestamp","example":"2024-01-15T10:30:00Z"}},"required":["id","name","description","type","filePath","originalFilename","fileSize","mimeType","chunkCount","tokenCount","metadata","accountId","createdAt","updatedAt"]},"QueryDocumentsDto":{"type":"object","properties":{"query":{"type":"string","description":"Query string to search for in the knowledge documents","example":"How to configure the payment settings?","minLength":1,"maxLength":1000},"botId":{"type":"string","description":"Bot ID to filter documents by","example":"123e4567-e89b-12d3-a456-426614174000"},"accountId":{"type":"string","description":"Account ID to filter documents by (optional)","example":"123e4567-e89b-12d3-a456-426614174000"},"limit":{"type":"number","description":"Maximum number of results to return","example":5,"minimum":1,"maximum":20,"default":5}},"required":["query","botId"]},"KnowledgeDocumentChunkResponseDto":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the chunk","example":"123e4567-e89b-12d3-a456-426614174000"},"documentId":{"type":"string","description":"Document ID this chunk belongs to","example":"123e4567-e89b-12d3-a456-426614174000"},"chunkIndex":{"type":"number","description":"Sequential index of this chunk within the document","example":3},"content":{"type":"string","description":"The text content of this chunk","example":"This section covers the payment configuration settings..."},"tokenCount":{"type":"number","description":"Number of tokens in this chunk","example":150},"startPosition":{"type":"number","description":"Start position of this chunk in the original document","example":1250},"endPosition":{"type":"number","description":"End position of this chunk in the original document","example":1850},"metadata":{"type":"object","description":"Additional metadata for this chunk","example":{"page":3,"section":"Payment Configuration"},"nullable":true},"createdAt":{"format":"date-time","type":"string","description":"Creation timestamp","example":"2024-01-15T10:30:00Z"},"updatedAt":{"format":"date-time","type":"string","description":"Last update timestamp","example":"2024-01-15T10:30:00Z"}},"required":["id","documentId","chunkIndex","content","tokenCount","startPosition","endPosition","metadata","createdAt","updatedAt"]},"QueryDocumentsResponseDto":{"type":"object","properties":{"chunks":{"description":"Array of matching document chunks","type":"array","items":{"$ref":"#/components/schemas/KnowledgeDocumentChunkResponseDto"}},"totalCount":{"type":"number","description":"Total number of chunks found","example":5},"query":{"type":"string","description":"The original query string","example":"How to configure the payment settings?"}},"required":["chunks","totalCount","query"]},"UploadMediaDto":{"type":"object","properties":{"scope":{"type":"string","description":"Media scope - account level or conversation level","enum":["account","conversation"],"default":"account"},"conversationId":{"type":"string","description":"Conversation ID - required when scope is CONVERSATION","format":"uuid"},"metadata":{"type":"object","description":"Additional metadata for the media file (dimensions, duration, etc.)","additionalProperties":true}},"required":["metadata"]},"MediaFile":{"type":"object","properties":{}},"PreSignedUrlDto":{"type":"object","properties":{"expiresIn":{"type":"number","description":"URL expiration time in seconds","default":3600,"minimum":60,"maximum":86400}}}}}}