{"openapi":"3.1.0","info":{"title":"WAQueen API","version":"1.0.0","description":"Public and operator API for WhatsApp sessions, queued outbound messages, rate limits, and durable webhook delivery.","contact":{"name":"WAQueen Support","email":"support@waqueen.com"}},"servers":[{"url":"https://0.0.0.0:3010","description":"Current deployment"},{"url":"https://waqueen.com","description":"Production"},{"url":"http://localhost:3010","description":"Local development"}],"tags":[{"name":"Business","description":"Create the tenant workspace and manage the structured AI Business Brain profile."},{"name":"Knowledge","description":"Create, index, search, and govern AI Business Brain knowledge sources."},{"name":"WhatsApp","description":"Public WhatsApp utility endpoints for external tools."},{"name":"Messages","description":"Queue text, media, poll, and quick-reply messages for WhatsApp delivery."},{"name":"Inbox","description":"Read conversations, inspect message threads, mark chats read, and reply from the inbox."},{"name":"Contacts","description":"Manage CRM contact records, policy flags, and WhatsApp availability checks."},{"name":"Tags","description":"Manage the business tag catalog used by contacts, conversations, and segmentation."},{"name":"Segments","description":"Create saved dynamic or static contact segments with opt-out and block safety defaults."},{"name":"Queue","description":"Inspect, clear, cancel, and retry outbound message queue rows."},{"name":"Webhooks","description":"Inspect and replay durable webhook deliveries."},{"name":"Sessions","description":"Create, pair, monitor, and operate WhatsApp sessions."},{"name":"API Keys","description":"Create, rotate, and revoke API keys for public API access."},{"name":"Developer","description":"Machine-readable API documentation and test artifacts."}],"paths":{"/api/v1/whatsapp/check-number":{"post":{"tags":["WhatsApp"],"summary":"Check whether a phone number has WhatsApp","operationId":"checkWhatsAppNumber","security":[{"ApiKeyAuth":["whatsapp:check"]}],"description":"Checks a direct phone number through a linked WhatsApp session. If sessionId is omitted, WAQueen selects the best connected or recoverable session for the API key's business.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsAppCheckNumberRequest"},"example":{"phoneNumber":"+923001234567"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WhatsAppCheckNumberResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid phone number","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"API key does not include whatsapp:check scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Requested session was not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"412":{"description":"No connected or send-ready WhatsApp session is available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"API key rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"WhatsApp/Baileys availability check failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/messages":{"post":{"tags":["Messages"],"summary":"Queue a text, media, poll, or quick-reply message","operationId":"queueMessage","security":[{"ApiKeyAuth":["messages:send"]}],"description":"Accepts a text, single media, poll, or quick-reply message into the durable per-session FIFO queue. Quick replies are sent as a single-answer WhatsApp poll for reliability. If sessionId is omitted, WAQueen selects the best send-ready session. If sessionId is provided with allowFallback=true, WAQueen may use another send-ready session only when the requested session is temporarily restoring. The response confirms queue acceptance; final delivery arrives through webhook status events.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageRequest"},"example":{"to":"+15551234567","interactive":{"type":"poll","question":"Which delivery slot works best?","options":["Morning","Afternoon","Evening"]},"idempotencyKey":"order-4821-shipped","allowFallback":true}}}},"responses":{"200":{"description":"Message queued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"},"example":{"success":true,"data":{"messageId":"msg_123","toJid":"15551234567@s.whatsapp.net","status":"queued","queuedAt":1760000000000,"expiresAt":1760086400000,"sessionId":"s_abc123","fallbackUsed":false}}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid message request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"API key does not include messages:send scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"412":{"description":"No queueable or send-ready session is available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Request, recipient, business, or queue rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Message could not be queued because an upstream send dependency failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/media/upload":{"post":{"tags":["Messages"],"summary":"Upload media for a later message send","operationId":"uploadMessageMedia","security":[{"ApiKeyAuth":["messages:send"]}],"description":"Stores one media file in WAQueen-controlled storage and returns a mediaId. Use that mediaId in POST /api/v1/messages to avoid depending on an external public media URL.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"},"mediaType":{"type":"string","enum":["image","video","audio","document"]},"fileName":{"type":"string","minLength":1,"maxLength":255}}}}}},"responses":{"200":{"description":"Media uploaded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MediaUploadResponse"},"example":{"success":true,"data":{"id":"med_123","fileName":"invoice.pdf","mediaType":"document","mimeType":"application/pdf","sizeBytes":524288}}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid media upload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"API key does not include messages:send scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Request rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses":{"post":{"tags":["Business"],"summary":"Create business workspace and AI brain profile","operationId":"createBusinessOnboarding","security":[{"DashboardSession":[]}],"description":"Completes first-run onboarding. The `brain` object is optional for backward compatibility, but the dashboard wizard sends it to create structured AI context.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessOnboardingRequest"},"example":{"name":"ABC Restaurant","slug":"abc-restaurant","category":"Restaurant","country":"Pakistan","city":"Lahore","timezone":"Asia/Karachi","phoneE164":"+923001234567","websiteUrl":"https://example.com","description":"We sell pizza, burgers and biryani.","brain":{"goals":["support","sales"],"languages":["English","Roman Urdu"],"tone":"friendly","replyLength":"balanced","products":[{"name":"Pizza deal","description":"Large pizza with drink","price":"Rs 1800"}],"serviceArea":"5km around Gulberg Lahore","openingHours":{"summary":"Mon-Sun 12pm to 1am","timezone":"Asia/Karachi"},"faqs":[{"question":"Do you deliver?","answer":"Yes, within 5km."}],"policies":{"refundPolicy":"Refunds are reviewed by support.","deliveryPolicy":"35 to 45 minutes."},"handoffRules":["Refund disputes","Payment issues"],"blockedTopics":["Legal advice"],"allowedActions":["answer questions","collect lead details","handoff to human"],"whatsappDefaults":{"numberUse":"dedicated","dmPolicy":"pairing","groupPolicy":"disabled","groupRequireMention":true,"delaySendMessagesMilliseconds":1000}}}}}},"responses":{"200":{"description":"Existing incomplete workspace completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessOnboardingResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessOnboardingResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid business or brain profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Business already exists for this account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/current":{"get":{"tags":["Business"],"summary":"Read current business workspace","operationId":"getCurrentBusiness","security":[{"DashboardSession":[]}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CurrentBusinessResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Business"],"summary":"Update current business profile","operationId":"updateCurrentBusiness","security":[{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessProfileRequest"},"example":{"name":"ABC Restaurant","timezone":"Asia/Karachi","category":"Restaurant"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid business profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Only owners and admins can update business settings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/brain":{"get":{"tags":["Business"],"summary":"Read AI Business Brain profile","operationId":"getBusinessBrainProfile","security":[{"DashboardSession":[]}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessBrainProfileResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"409":{"description":"Business onboarding required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"tags":["Business"],"summary":"Update AI Business Brain profile","operationId":"updateBusinessBrainProfile","security":[{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessBrainProfileRequest"},"example":{"goals":["support","bookings"],"languages":["English","Roman Urdu"],"tone":"supportive","replyLength":"balanced","handoffRules":["Payment issue","Angry customer"],"whatsappDefaults":{"numberUse":"dedicated","dmPolicy":"pairing","groupPolicy":"disabled","groupRequireMention":true}}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessBrainProfileResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid business brain profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Only owners and admins can update the business brain profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/brain/generate-summary":{"post":{"tags":["Business"],"summary":"Preview generated AI business prompt summary","operationId":"generateBusinessBrainSummary","security":[{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessBrainProfileRequest"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessBrainSummaryResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid business brain profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Business onboarding required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/knowledge-sources":{"get":{"tags":["Knowledge"],"summary":"List knowledge sources","operationId":"listKnowledgeSources","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"q","in":"query","required":false,"description":"Search title, description, or URL.","schema":{"type":"string"}},{"name":"type","in":"query","required":false,"description":"Filter by source type.","schema":{"type":"string","enum":["profile","manual","website","document","catalog","service","faq","policy","conversation"]}},{"name":"status","in":"query","required":false,"description":"Filter by source status.","schema":{"type":"string","enum":["pending","indexing","ready","failed","archived"]}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived sources.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum rows to return.","schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourceListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Knowledge"],"summary":"Create and optionally index a knowledge source","operationId":"createKnowledgeSource","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourceRequest"},"example":{"type":"faq","title":"Refund policy","content":"Refunds are reviewed by support. Wrong item refunds are eligible within 24 hours.","ingestNow":true}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid source or empty content","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/knowledge-sources/{id}":{"get":{"tags":["Knowledge"],"summary":"Read a knowledge source","operationId":"getKnowledgeSource","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Knowledge source id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Knowledge source not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Knowledge"],"summary":"Update a knowledge source","operationId":"updateKnowledgeSource","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Knowledge source id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourcePatchRequest"},"example":{"title":"Updated refund policy","description":"Operator-reviewed policy text"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid source update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Knowledge source not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Knowledge"],"summary":"Archive a knowledge source","operationId":"archiveKnowledgeSource","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Knowledge source id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Knowledge source not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/knowledge-sources/{id}/reindex":{"post":{"tags":["Knowledge"],"summary":"Reindex a knowledge source","operationId":"reindexKnowledgeSource","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Knowledge source id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeReindexRequest"},"example":{"content":"Replacement verified policy text."}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSourceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Source has no extractable content","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Knowledge source not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/knowledge/search":{"post":{"tags":["Knowledge"],"summary":"Search indexed knowledge chunks","operationId":"searchKnowledge","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSearchRequest"},"example":{"query":"refund policy","limit":5,"source":"crm_bot"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSearchResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid knowledge search query","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/ai-context/preview":{"post":{"tags":["Knowledge"],"summary":"Preview AI reply context","operationId":"previewAIContext","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"description":"Builds the same compact context pack the AI reply pipeline will use: business profile, contact/conversation state, approved KB chunks, source IDs, and safety/handoff decision flags.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIContextPreviewRequest"},"example":{"messageText":"Large pizza kitny ki hai aur delivery Gulberg mein hoti hai?","sessionId":"{{sessionId}}","chatJid":"{{chatJid}}","knowledgeLimit":6,"messageLimit":12,"tokenBudget":6000}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AIContextPreviewResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid AI context preview request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/services":{"get":{"tags":["Knowledge"],"summary":"List governed services and pricing","operationId":"listBusinessServices","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"q","in":"query","required":false,"description":"Search name, description, or category.","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"Filter by governance status.","schema":{"type":"string","enum":["draft","approved","archived"]}},{"name":"availability","in":"query","required":false,"description":"Filter by availability.","schema":{"type":"string","enum":["available","limited","unavailable","quote_only"]}},{"name":"category","in":"query","required":false,"description":"Filter by category.","schema":{"type":"string"}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived services.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum rows to return.","schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Knowledge"],"summary":"Create a governed service or priced catalog item","operationId":"createBusinessService","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceRequest"},"example":{"name":"Large Pizza","description":"Large chicken fajita pizza","category":"Pizza","availability":"available","tags":["menu","popular"],"price":{"priceType":"fixed","amountMinor":180000,"currency":"PKR","unit":"item","displayPrice":"Rs. 1800"}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid service or price","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/services/{id}":{"get":{"tags":["Knowledge"],"summary":"Read a governed service","operationId":"getBusinessService","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Service id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Service not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Knowledge"],"summary":"Update a governed service","operationId":"updateBusinessService","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Service id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServicePatchRequest"},"example":{"price":{"priceType":"from","amountMinor":150000,"currency":"PKR","displayPrice":"From Rs. 1500"},"changeReason":"Menu price changed"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid service update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Service not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Knowledge"],"summary":"Archive a governed service","operationId":"archiveBusinessService","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Service id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Service not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/services/{id}/publish":{"post":{"tags":["Knowledge"],"summary":"Publish a governed service and index it","operationId":"publishBusinessService","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Service id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessKnowledgePublishRequest"},"example":{"changeReason":"Approved by catalog owner"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Service could not be published","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Service not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/services/{id}/archive":{"post":{"tags":["Knowledge"],"summary":"Archive a governed service","operationId":"archiveBusinessServicePost","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Service id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessKnowledgeArchiveRequest"},"example":{"changeReason":"Removed from menu"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessServiceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Service not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/services/{id}/revisions":{"get":{"tags":["Knowledge"],"summary":"List service revisions","operationId":"listBusinessServiceRevisions","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Service id.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Maximum rows to return.","schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessKnowledgeRevisionListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/faqs":{"get":{"tags":["Knowledge"],"summary":"List governed FAQs","operationId":"listBusinessFaqs","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"q","in":"query","required":false,"description":"Search question, answer, or category.","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"Filter by governance status.","schema":{"type":"string","enum":["draft","approved","archived"]}},{"name":"category","in":"query","required":false,"description":"Filter by category.","schema":{"type":"string"}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived FAQs.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum rows to return.","schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Knowledge"],"summary":"Create a governed FAQ","operationId":"createBusinessFaq","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqRequest"},"example":{"question":"Delivery area kya hai?","answer":"Hum Gulberg Lahore ke 5km radius mein delivery karte hain.","category":"delivery","tags":["delivery","support"],"handoffRequired":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid FAQ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/faqs/{id}":{"get":{"tags":["Knowledge"],"summary":"Read a governed FAQ","operationId":"getBusinessFaq","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"FAQ id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"FAQ not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Knowledge"],"summary":"Update a governed FAQ","operationId":"updateBusinessFaq","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"FAQ id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqPatchRequest"},"example":{"answer":"Updated verified delivery answer.","changeReason":"Policy changed"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid FAQ update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"FAQ not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Knowledge"],"summary":"Archive a governed FAQ","operationId":"archiveBusinessFaq","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"FAQ id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"FAQ not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/faqs/{id}/publish":{"post":{"tags":["Knowledge"],"summary":"Publish a governed FAQ","operationId":"publishBusinessFaq","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"FAQ id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessKnowledgePublishRequest"},"example":{"changeReason":"Approved by support lead"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessFaqResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"FAQ could not be published","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"FAQ not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/faqs/{id}/revisions":{"get":{"tags":["Knowledge"],"summary":"List FAQ revisions","operationId":"listBusinessFaqRevisions","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"FAQ id.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Maximum rows to return.","schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessKnowledgeRevisionListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/policies":{"get":{"tags":["Knowledge"],"summary":"List governed policies","operationId":"listBusinessPolicies","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"q","in":"query","required":false,"description":"Search title, body, or category.","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"Filter by governance status.","schema":{"type":"string","enum":["draft","approved","archived"]}},{"name":"type","in":"query","required":false,"description":"Filter by policy type.","schema":{"type":"string","enum":["refund","delivery","cancellation","booking","privacy","terms","custom"]}},{"name":"severity","in":"query","required":false,"description":"Filter by severity.","schema":{"type":"string","enum":["info","sensitive","critical"]}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived policies.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum rows to return.","schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Knowledge"],"summary":"Create a governed policy","operationId":"createBusinessPolicy","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyRequest"},"example":{"type":"refund","title":"Refund policy","body":"Wrong item refund is eligible within 24 hours after support review.","severity":"sensitive","handoffRequired":true,"blockedIfUnclear":true}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid policy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/policies/{id}":{"get":{"tags":["Knowledge"],"summary":"Read a governed policy","operationId":"getBusinessPolicy","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Policy id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Policy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Knowledge"],"summary":"Update a governed policy","operationId":"updateBusinessPolicy","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Policy id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyPatchRequest"},"example":{"body":"Updated verified policy text.","changeReason":"Operations update"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid policy update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Policy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Knowledge"],"summary":"Archive a governed policy","operationId":"archiveBusinessPolicy","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Policy id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Policy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/policies/{id}/publish":{"post":{"tags":["Knowledge"],"summary":"Publish a governed policy","operationId":"publishBusinessPolicy","security":[{"ApiKeyAuth":["knowledge:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Policy id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessKnowledgePublishRequest"},"example":{"changeReason":"Approved by policy owner"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessPolicyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Policy could not be published","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing knowledge:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Policy not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/businesses/policies/{id}/revisions":{"get":{"tags":["Knowledge"],"summary":"List policy revisions","operationId":"listBusinessPolicyRevisions","security":[{"ApiKeyAuth":["knowledge:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Policy id.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Maximum rows to return.","schema":{"type":"integer","default":100,"minimum":1,"maximum":500}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BusinessKnowledgeRevisionListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing knowledge:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions":{"get":{"tags":["Sessions"],"summary":"List WhatsApp sessions","operationId":"listSessions","security":[{"DashboardSession":[]}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Sessions"],"summary":"Create a WhatsApp session","operationId":"createSession","security":[{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSessionRequest"},"example":{"name":"support-line","webhookUrl":"https://example.com/wa","dmPolicy":"pairing","settings":{"delaySendMessagesMilliseconds":1000,"outgoingAPIMessageWebhook":true,"stateWebhook":true}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionCreateResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid session request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Business session limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}":{"get":{"tags":["Sessions"],"summary":"Get one WhatsApp session","operationId":"getSession","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Sessions"],"summary":"Update session settings","operationId":"updateSession","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateSessionRequest"},"example":{"webhookUrl":"https://example.com/wa","settings":{"delaySendMessagesMilliseconds":1500}}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid patch request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Sessions"],"summary":"Delete a WhatsApp session","operationId":"deleteSession","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Session operation already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/qr":{"get":{"tags":["Sessions"],"summary":"Read QR pairing state","operationId":"getQrState","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QrPairingResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Sessions"],"summary":"Start or refresh QR pairing","operationId":"startQrPairing","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}},{"name":"refresh","in":"query","required":false,"description":"Use 1 to force a fresh pairing socket when possible.","schema":{"type":"string","enum":["1"]}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QrPairingResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/status":{"get":{"tags":["Sessions"],"summary":"Read connection status","operationId":"getSessionStatus","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionStatusResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/persistence":{"get":{"tags":["Sessions"],"summary":"Read persisted auth health","operationId":"getSessionPersistence","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionPersistenceResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/diagnostics":{"get":{"tags":["Sessions"],"summary":"Read deep session diagnostics","operationId":"getSessionDiagnostics","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}},{"name":"warmup","in":"query","required":false,"description":"Use 1 to attempt persisted-session warmup before returning diagnostics.","schema":{"type":"string","enum":["1"]}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"description":"Session diagnostics including live socket, auth persistence, QR state, heartbeat windows, warmup result, and recent events."}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/events":{"get":{"tags":["Sessions"],"summary":"List recent session events","operationId":"listSessionEvents","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionEventsResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/restart":{"post":{"tags":["Sessions"],"summary":"Restart a WhatsApp session socket","operationId":"restartSession","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Session operation already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/logout":{"post":{"tags":["Sessions"],"summary":"Logout a WhatsApp session","operationId":"logoutSession","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Session operation already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/queue":{"get":{"tags":["Queue"],"summary":"Inspect a session outbound queue","operationId":"listSessionQueue","security":[{"ApiKeyAuth":["messages:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"queued, all, terminal, or a comma-separated list of statuses.","schema":{"type":"string","default":"queued"}},{"name":"limit","in":"query","required":false,"description":"Maximum number of rows to return.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageQueueListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid status or limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing auth","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/inbox/events":{"get":{"tags":["Inbox"],"summary":"Stream inbox snapshots","description":"Server-sent event stream for dashboard-style realtime inbox refresh. Emits `snapshot` events with the current conversation list and, when `sessionId` plus `chatJid` are provided, the selected thread messages. Clients should keep ordinary REST polling as a fallback.","operationId":"streamInboxSnapshots","security":[{"ApiKeyAuth":["messages:read"]},{"DashboardSession":[]}],"parameters":[{"name":"sessionId","in":"query","required":false,"description":"Filter to one WhatsApp session.","schema":{"type":"string"}},{"name":"chatJid","in":"query","required":false,"description":"Selected chat JID. Requires sessionId and includes thread messages in snapshot events.","schema":{"type":"string"}},{"name":"q","in":"query","required":false,"description":"Search chat JID, display name, or last message preview.","schema":{"type":"string"}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived conversations.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum conversation rows per snapshot.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"messageLimit","in":"query","required":false,"description":"Maximum selected-thread messages per snapshot.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Server-sent events. `snapshot` events contain InboxConversation and InboxMessage payloads.","content":{"text/event-stream":{"schema":{"type":"string"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid stream request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/inbox/conversations":{"get":{"tags":["Inbox"],"summary":"List inbox conversations","operationId":"listInboxConversations","security":[{"ApiKeyAuth":["messages:read"]},{"DashboardSession":[]}],"parameters":[{"name":"sessionId","in":"query","required":false,"description":"Filter to one WhatsApp session.","schema":{"type":"string"}},{"name":"q","in":"query","required":false,"description":"Search chat JID, display name, or last message preview.","schema":{"type":"string"}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived conversations.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum number of rows to return.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing messages:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Inbox"],"summary":"Create or find an inbox conversation","description":"Bootstraps an empty conversation from a contact, phone number, or chat JID so operators can open the thread and send the first message.","operationId":"createOrFindInboxConversation","security":[{"ApiKeyAuth":["messages:manage"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationCreateRequest"},"example":{"sessionId":"s_abc123","chatJid":"15551234567@s.whatsapp.net","displayName":"Ali Khan"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid conversation create request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:manage scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/inbox/conversations/{chatJid}":{"get":{"tags":["Inbox"],"summary":"Get one inbox conversation","operationId":"getInboxConversation","security":[{"ApiKeyAuth":["messages:read"]},{"DashboardSession":[]}],"parameters":[{"name":"chatJid","in":"path","required":true,"description":"URL-encoded chat JID.","schema":{"type":"string"}},{"name":"sessionId","in":"query","required":false,"description":"Owning WhatsApp session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Missing sessionId","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Conversation or session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Inbox"],"summary":"Update inbox conversation metadata","operationId":"updateInboxConversation","security":[{"ApiKeyAuth":["messages:manage"]},{"DashboardSession":[]}],"parameters":[{"name":"chatJid","in":"path","required":true,"description":"URL-encoded chat JID.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationUpdateRequest"},"example":{"sessionId":"s_abc123","archived":true,"tags":["vip"]}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid conversation patch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:manage scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Conversation or session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/inbox/conversations/{chatJid}/messages":{"get":{"tags":["Inbox"],"summary":"List messages in one conversation","operationId":"listInboxConversationMessages","security":[{"ApiKeyAuth":["messages:read"]},{"DashboardSession":[]}],"parameters":[{"name":"chatJid","in":"path","required":true,"description":"URL-encoded chat JID.","schema":{"type":"string"}},{"name":"sessionId","in":"query","required":false,"description":"Owning WhatsApp session id.","schema":{"type":"string"}},{"name":"before","in":"query","required":false,"description":"Return messages before this Unix timestamp in milliseconds.","schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"description":"Maximum number of rows to return.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxMessageListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid sessionId or before timestamp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Conversation or session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/inbox/conversations/{chatJid}/resync":{"post":{"tags":["Inbox"],"summary":"Request WhatsApp history resync","description":"Requests more WhatsApp history for a conversation. If an oldest stored WhatsApp message exists, WAQueen asks Baileys for older messages for that chat. If no anchor exists and fallbackFullSync is true, WAQueen requests a full session history sync restart.","operationId":"requestInboxConversationHistoryResync","security":[{"ApiKeyAuth":["messages:manage"]},{"DashboardSession":[]}],"parameters":[{"name":"chatJid","in":"path","required":true,"description":"URL-encoded chat JID.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxHistoryResyncRequest"},"example":{"sessionId":"s_abc123","count":50,"fallbackFullSync":true}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxHistoryResyncResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid resync request or missing history anchor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:manage scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Conversation or session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Session is not connected or history resync could not be requested","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/inbox/conversations/{chatJid}/read":{"post":{"tags":["Inbox"],"summary":"Mark one conversation read","operationId":"markInboxConversationRead","security":[{"ApiKeyAuth":["messages:manage"]},{"DashboardSession":[]}],"parameters":[{"name":"chatJid","in":"path","required":true,"description":"URL-encoded chat JID.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationReadRequest"},"example":{"sessionId":"s_abc123"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxConversationResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid read request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:manage scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Conversation or session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/inbox/conversations/{chatJid}/reply":{"post":{"tags":["Inbox"],"summary":"Reply to a conversation","operationId":"replyToInboxConversation","security":[{"ApiKeyAuth":["messages:send"]},{"DashboardSession":[]}],"parameters":[{"name":"chatJid","in":"path","required":true,"description":"URL-encoded chat JID.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxReplyRequest"},"example":{"sessionId":"s_abc123","text":"Your order is out for delivery.","replyToMessageId":"msg_inbound_123"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboxReplyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid reply request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing messages:send scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Conversation or session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Recipient, business, or queue rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/contacts":{"get":{"tags":["Contacts"],"summary":"List contacts","operationId":"listContacts","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"q","in":"query","required":false,"description":"Search phone, JID, name, display name, or notes.","schema":{"type":"string"}},{"name":"tag","in":"query","required":false,"description":"Filter by one normalized tag.","schema":{"type":"string"}},{"name":"type","in":"query","required":false,"description":"Filter by contact type.","schema":{"type":"string","enum":["all","user","group"],"default":"all"}},{"name":"status","in":"query","required":false,"description":"Filter by policy status.","schema":{"type":"string","enum":["all","active","blocked","opted_out"],"default":"all"}},{"name":"limit","in":"query","required":false,"description":"Maximum number of rows to return.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"401":{"description":"Missing auth","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Contacts"],"summary":"Create or upsert a contact","operationId":"upsertContact","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactUpsertRequest"},"example":{"phoneE164":"+15551234567","displayName":"Ali Khan","tags":["vip","refund"],"notes":"Invoice dispute customer"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid contact request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing auth","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/contacts/{id}":{"get":{"tags":["Contacts"],"summary":"Get one contact","operationId":"getContact","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Contact not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Contacts"],"summary":"Update a contact","operationId":"updateContact","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactUpdateRequest"},"example":{"displayName":"Ali Khan","tags":["vip"],"notes":"Prefers WhatsApp updates"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid contact patch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Contact not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Contacts"],"summary":"Delete a contact","operationId":"deleteContact","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactDeleteResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Contact not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/contacts/{id}/lead":{"patch":{"tags":["Contacts"],"summary":"Update persisted lead state for one contact","operationId":"updateContactLead","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactLeadActionRequest"},"example":{"action":"update_details","capturedDetails":{"name":"Ali Khan","phone":"+15551234567","serviceInterest":"website design","budget":"PKR 50000"}}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid lead action","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Contact not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/contacts/{id}/block":{"post":{"tags":["Contacts"],"summary":"Block or unblock a contact","operationId":"setContactBlocked","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactActionRequest"},"example":{"blocked":true,"reason":"Support blocklist"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Contact not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/contacts/{id}/opt-out":{"post":{"tags":["Contacts"],"summary":"Opt a contact out or back in","operationId":"setContactOptOut","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactActionRequest"},"example":{"optedOut":true,"reason":"STOP"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Contact not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/contacts/check-whatsapp":{"post":{"tags":["Contacts"],"summary":"Check WhatsApp account availability","operationId":"checkWhatsAppContact","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactCheckWhatsappRequest"},"example":{"sessionId":"s_abc123","phoneNumber":"+15551234567"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactCheckWhatsappResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid target or session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"WhatsApp socket is not available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/contacts/bulk-tags":{"post":{"tags":["Contacts"],"summary":"Bulk add or remove contact tags","operationId":"bulkUpdateContactTags","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkContactTagsRequest"},"example":{"contactIds":["ct_123","ct_456"],"addTags":["vip"],"removeTags":["cold-lead"]}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkContactTagsResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid bulk tag request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/tags":{"get":{"tags":["Tags"],"summary":"List tags","operationId":"listTags","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"q","in":"query","required":false,"description":"Search by slug, name, or description.","schema":{"type":"string"}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived tags.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum number of rows to return.","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Tags"],"summary":"Create or restore a tag","operationId":"upsertTag","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagUpsertRequest"},"example":{"name":"VIP","color":"violet","description":"Priority support customers"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid tag request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/tags/{id}":{"get":{"tags":["Tags"],"summary":"Get one tag","operationId":"getTag","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Tag id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Tag not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Tags"],"summary":"Update a tag","operationId":"updateTag","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Tag id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagUpdateRequest"},"example":{"name":"VIP","color":"amber","description":"High-priority customers"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid tag patch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Tag not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Tags"],"summary":"Archive a tag","operationId":"archiveTag","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Tag id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TagResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Tag not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/segments":{"get":{"tags":["Segments"],"summary":"List segments","operationId":"listSegments","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"q","in":"query","required":false,"description":"Search by slug, name, or description.","schema":{"type":"string"}},{"name":"includeArchived","in":"query","required":false,"description":"Include archived segments.","schema":{"type":"boolean","default":false}},{"name":"limit","in":"query","required":false,"description":"Maximum number of rows to return.","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["Segments"],"summary":"Create a segment","operationId":"createSegment","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentUpsertRequest"},"example":{"name":"VIP active customers","type":"dynamic","defaultExcludesBlocked":true,"defaultExcludesOptedOut":true,"rules":{"all":[{"field":"tags","op":"has","value":"vip"},{"field":"lastInboundAt","op":"afterDaysAgo","value":30}]}}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid segment request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/segments/preview":{"post":{"tags":["Segments"],"summary":"Preview unsaved segment rules","operationId":"previewSegmentRules","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentPreviewRequest"},"example":{"defaultExcludesBlocked":true,"defaultExcludesOptedOut":true,"limit":50,"rules":{"all":[{"field":"tags","op":"has","value":"vip"},{"field":"lastInboundAt","op":"afterDaysAgo","value":30}]}}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentPreviewResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid segment rules","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/segments/{id}":{"get":{"tags":["Segments"],"summary":"Get one segment","operationId":"getSegment","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Segment id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Segment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Segments"],"summary":"Update a segment","operationId":"updateSegment","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Segment id.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentUpdateRequest"},"example":{"description":"Priority support segment","defaultExcludesOptedOut":true}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid segment patch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Segment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Segments"],"summary":"Archive a segment","operationId":"archiveSegment","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Segment id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Segment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/segments/{id}/contacts":{"get":{"tags":["Segments"],"summary":"List contacts in a segment","operationId":"listSegmentContacts","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Segment id.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Maximum number of contacts to return.","schema":{"type":"integer","minimum":1,"maximum":500,"default":100}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentContactsResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Segment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/segments/{id}/preview":{"post":{"tags":["Segments"],"summary":"Preview one saved segment","operationId":"previewSavedSegment","security":[{"ApiKeyAuth":["contacts:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Segment id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentPreviewResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Segment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/segments/{id}/recalculate":{"post":{"tags":["Segments"],"summary":"Recalculate segment membership cache","operationId":"recalculateSegment","security":[{"ApiKeyAuth":["contacts:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Segment id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentRecalculateResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing contacts:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Segment not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/queue/clear":{"post":{"tags":["Queue"],"summary":"Cancel all unlocked queued messages for one session","operationId":"clearSessionQueue","security":[{"ApiKeyAuth":["messages:manage"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueueActionRequest"},"example":{"reason":"Number changed"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueueClearResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing messages:manage scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/messages/{id}":{"get":{"tags":["Queue"],"summary":"Read one outbound message lifecycle record","operationId":"getMessage","security":[{"ApiKeyAuth":["messages:read"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Message id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageRecordResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing messages:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Message not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/messages/{id}/cancel":{"post":{"tags":["Queue"],"summary":"Cancel one queued outbound message","operationId":"cancelMessage","security":[{"ApiKeyAuth":["messages:manage"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Message id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueueActionRequest"},"example":{"reason":"Customer opted out"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageRecordResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing messages:manage scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Message not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Message is not queued or is locked by a worker","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/messages/{id}/retry":{"post":{"tags":["Queue"],"summary":"Move a failed or cancelled message back to the queue","operationId":"retryMessage","security":[{"ApiKeyAuth":["messages:manage"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Message id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetryRequest"},"example":{"delayMs":0}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageRecordResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing messages:manage scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Message not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Message is not failed or cancelled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webhook-deliveries":{"get":{"tags":["Webhooks"],"summary":"List webhook delivery attempts","operationId":"listWebhookDeliveries","security":[{"ApiKeyAuth":["webhooks:read"]},{"DashboardSession":[]}],"parameters":[{"name":"status","in":"query","required":false,"description":"pending, delivering, delivered, failed, or all.","schema":{"type":"string","default":"all"}},{"name":"sessionId","in":"query","required":false,"description":"Filter to one WhatsApp session.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Maximum number of rows to return.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid status or limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Missing webhooks:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/webhook-deliveries/{id}/replay":{"post":{"tags":["Webhooks"],"summary":"Replay a delivered or failed webhook delivery","operationId":"replayWebhookDelivery","security":[{"ApiKeyAuth":["webhooks:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook delivery id.","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetryRequest"},"example":{"delayMs":0}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing webhooks:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Webhook delivery not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Webhook delivery is currently in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/sessions/{id}/webhook/test":{"post":{"tags":["Webhooks"],"summary":"Queue a signed test webhook","operationId":"sendTestWebhook","security":[{"ApiKeyAuth":["webhooks:write"]},{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Session id.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookDeliveryResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing webhooks:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/notifications/receive":{"get":{"tags":["Webhooks"],"summary":"Receive the next webhook notification","operationId":"receiveWebhookNotification","security":[{"ApiKeyAuth":["webhooks:read"]}],"description":"GreenAPI-style polling fallback for customers without a public webhook endpoint. Returns the oldest available event notification, then the client confirms processing with DELETE /api/v1/notifications/{id}.","parameters":[{"name":"sessionId","in":"query","required":false,"description":"Filter to one WhatsApp session.","schema":{"type":"string"}},{"name":"leaseMs","in":"query","required":false,"description":"How long to hide this receipt before it can be received again if not deleted.","schema":{"type":"integer","minimum":10000,"maximum":3600000,"default":300000}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookNotificationReceiveResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing webhooks:read scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/notifications/{id}":{"delete":{"tags":["Webhooks"],"summary":"Delete a processed webhook notification","operationId":"deleteWebhookNotification","security":[{"ApiKeyAuth":["webhooks:write"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Notification receipt id returned by receiveWebhookNotification.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookNotificationDeleteResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Missing webhooks:write scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Notification receipt not found or already deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/api-keys":{"get":{"tags":["API Keys"],"summary":"List API keys","operationId":"listApiKeys","security":[{"DashboardSession":[]}],"parameters":[{"name":"status","in":"query","required":false,"description":"Filter by key lifecycle state.","schema":{"type":"string","enum":["active","revoked","all"],"default":"active"}},{"name":"q","in":"query","required":false,"description":"Search API key labels.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Maximum keys to return, from 1 to 50.","schema":{"type":"integer","minimum":1,"maximum":50,"default":25}},{"name":"cursor","in":"query","required":false,"description":"Cursor returned by the previous list response.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyListResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"401":{"description":"Dashboard sign-in required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Only owners and admins can list API keys","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"tags":["API Keys"],"summary":"Create an API key","operationId":"createApiKey","security":[{"DashboardSession":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateApiKeyRequest"},"example":{"label":"production","environment":"live","scopes":["messages:send","messages:read"],"rateLimitPerMinute":60}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateApiKeyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Invalid API key request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Only owners and admins can create API keys","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["API Keys"],"summary":"Revoke an API key","operationId":"revokeApiKey","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"query","required":false,"description":"API key id to revoke.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"400":{"description":"Missing id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Only owners and admins can revoke API keys","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"API key not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/api-keys/{id}/rotate":{"post":{"tags":["API Keys"],"summary":"Rotate an API key","operationId":"rotateApiKey","security":[{"DashboardSession":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"API key id to rotate.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateApiKeyResponse"}}},"headers":{"X-RateLimit-Limit":{"description":"Allowed requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Remaining":{"description":"Remaining requests in the current API key window.","schema":{"type":"integer"}},"X-RateLimit-Reset":{"description":"Unix timestamp in milliseconds when the current API key window resets.","schema":{"type":"integer"}}}},"403":{"description":"Only owners and admins can rotate API keys","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"API key not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/openapi":{"get":{"tags":["Developer"],"summary":"Download OpenAPI specification","operationId":"getOpenApiSpec","responses":{"200":{"description":"OpenAPI 3.1 JSON document.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/openapi.json":{"get":{"tags":["Developer"],"summary":"Download OpenAPI specification as JSON","operationId":"getOpenApiJsonSpec","responses":{"200":{"description":"OpenAPI 3.1 JSON document.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/postman":{"get":{"tags":["Developer"],"summary":"Download Postman collection","operationId":"getPostmanCollection","responses":{"200":{"description":"Postman collection JSON document.","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"WAQueen API key","description":"Use `Authorization: Bearer wsk_test_...` in staging or `Authorization: Bearer wsk_live_...` in production."},"DashboardSession":{"type":"apiKey","in":"cookie","name":"__session","description":"Clerk/dashboard browser session."}},"schemas":{"SuccessResponse":{"type":"object","required":["success"],"properties":{"success":{"type":"boolean","const":true}}},"ErrorResponse":{"type":"object","required":["success","error"],"properties":{"success":{"type":"boolean","const":false},"code":{"type":"string","examples":["RATE_LIMIT_EXCEEDED","SESSION_NOT_SEND_READY","QUEUE_FULL"]},"error":{"type":"string"},"retryAfterMs":{"type":"integer","minimum":0}}},"Business":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"category":{"type":"string"},"country":{"type":"string"},"city":{"type":"string"},"timezone":{"type":"string","examples":["Asia/Karachi"]},"phoneE164":{"type":"string","examples":["+923001234567"]},"websiteUrl":{"type":"string","format":"uri"},"description":{"type":"string"},"status":{"type":"string","enum":["ACTIVE","SUSPENDED"]},"onboardingCompletedAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"BusinessProfileRequest":{"type":"object","required":["name","timezone"],"properties":{"name":{"type":"string","minLength":2,"maxLength":80},"slug":{"type":"string","maxLength":64},"category":{"type":"string","maxLength":80},"country":{"type":"string","maxLength":80},"city":{"type":"string","maxLength":80},"timezone":{"type":"string","maxLength":80},"phoneE164":{"type":"string","pattern":"^\\+[1-9]\\d{6,14}$"},"websiteUrl":{"type":"string","format":"uri"},"description":{"type":"string","maxLength":4000}}},"BrainProduct":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":1,"maxLength":120},"description":{"type":"string","maxLength":1000},"price":{"type":"string","maxLength":120},"url":{"type":"string","format":"uri"}}},"BrainFaq":{"type":"object","required":["question"],"properties":{"question":{"type":"string","minLength":1,"maxLength":300},"answer":{"type":"string","maxLength":2000}}},"BrainPolicies":{"type":"object","properties":{"refundPolicy":{"type":"string","maxLength":2000},"deliveryPolicy":{"type":"string","maxLength":2000},"cancellationPolicy":{"type":"string","maxLength":2000},"bookingProcess":{"type":"string","maxLength":2000}}},"BrainOpeningHours":{"type":"object","properties":{"summary":{"type":"string","maxLength":1000},"timezone":{"type":"string","maxLength":80}}},"BrainKnowledgeSource":{"type":"object","properties":{"type":{"type":"string","enum":["website","document","manual","catalog"]},"title":{"type":"string","maxLength":160},"url":{"type":"string","format":"uri"},"notes":{"type":"string","maxLength":1000}}},"WhatsappBrainDefaults":{"type":"object","properties":{"numberUse":{"type":"string","enum":["dedicated","personal","unknown"]},"dedicatedNumberRecommended":{"type":"boolean"},"dmPolicy":{"type":"string","enum":["pairing","allowlist","open","disabled"]},"allowFrom":{"type":"array","items":{"type":"string"},"maxItems":50},"groupPolicy":{"type":"string","enum":["allowlist","open","disabled"]},"groupAllowFrom":{"type":"array","items":{"type":"string"},"maxItems":50},"groupRequireMention":{"type":"boolean"},"delaySendMessagesMilliseconds":{"type":"integer","minimum":500,"maximum":600000},"webhookDefaults":{"type":"object","properties":{"incomingWebhook":{"type":"boolean"},"outgoingWebhook":{"type":"boolean"},"outgoingAPIMessageWebhook":{"type":"boolean"},"stateWebhook":{"type":"boolean"}}}}},"BusinessBrainProfileRequest":{"type":"object","properties":{"goals":{"type":"array","maxItems":12,"items":{"type":"string","maxLength":80}},"languages":{"type":"array","maxItems":8,"items":{"type":"string","maxLength":40}},"tone":{"type":"string","enum":["friendly","professional","concise","sales-focused","supportive"]},"replyLength":{"type":"string","enum":["short","balanced","detailed"]},"products":{"type":"array","maxItems":50,"items":{"$ref":"#/components/schemas/BrainProduct"}},"serviceArea":{"type":"string","maxLength":1000},"openingHours":{"$ref":"#/components/schemas/BrainOpeningHours"},"faqs":{"type":"array","maxItems":50,"items":{"$ref":"#/components/schemas/BrainFaq"}},"policies":{"$ref":"#/components/schemas/BrainPolicies"},"handoffRules":{"type":"array","maxItems":25,"items":{"type":"string","maxLength":160}},"blockedTopics":{"type":"array","maxItems":25,"items":{"type":"string","maxLength":160}},"allowedActions":{"type":"array","maxItems":25,"items":{"type":"string","maxLength":120}},"knowledgeSources":{"type":"array","maxItems":25,"items":{"$ref":"#/components/schemas/BrainKnowledgeSource"}},"whatsappDefaults":{"$ref":"#/components/schemas/WhatsappBrainDefaults"}}},"BusinessBrainProfile":{"allOf":[{"$ref":"#/components/schemas/BusinessBrainProfileRequest"}],"properties":{"id":{"type":"string"},"businessId":{"type":"string"},"promptSummary":{"type":"string"},"completedAt":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"BusinessOnboardingRequest":{"allOf":[{"$ref":"#/components/schemas/BusinessProfileRequest"}],"properties":{"brain":{"$ref":"#/components/schemas/BusinessBrainProfileRequest"}}},"BusinessResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Business"}}},"CurrentBusinessResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Business"},"needsOnboarding":{"type":"boolean"}}},"BusinessOnboardingResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Business"},"brainProfile":{"$ref":"#/components/schemas/BusinessBrainProfile"},"created":{"type":"boolean"}}},"BusinessBrainProfileResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/BusinessBrainProfile"}}},"BusinessBrainSummaryResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"profile":{"$ref":"#/components/schemas/BusinessBrainProfileRequest"},"promptSummary":{"type":"string"}}}}},"KnowledgeSource":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"sourceKey":{"type":"string"},"type":{"type":"string","enum":["profile","manual","website","document","catalog","service","faq","policy","conversation"]},"title":{"type":"string"},"description":{"type":"string"},"url":{"type":"string","format":"uri"},"storageKey":{"type":"string"},"contentHash":{"type":"string"},"status":{"type":"string","enum":["pending","indexing","ready","failed","archived"]},"chunkCount":{"type":"integer"},"lastIndexedAt":{"type":"integer"},"lastIndexedByUserId":{"type":"string"},"error":{"type":"string"},"metadata":{"type":"object","additionalProperties":true},"archivedAt":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"KnowledgeSourceRequest":{"type":"object","properties":{"type":{"type":"string","enum":["manual","website","document","catalog","service","faq","policy","conversation"],"default":"manual"},"title":{"type":"string","maxLength":160},"description":{"type":"string","maxLength":1000},"url":{"type":"string","format":"uri"},"content":{"type":"string","maxLength":250000},"metadata":{"type":"object","additionalProperties":true},"ingestNow":{"type":"boolean","default":true}}},"KnowledgeSourcePatchRequest":{"type":"object","properties":{"title":{"type":"string","maxLength":160},"description":{"type":"string","maxLength":1000,"nullable":true},"url":{"type":"string","format":"uri","nullable":true},"metadata":{"type":"object","additionalProperties":true}}},"KnowledgeReindexRequest":{"type":"object","properties":{"content":{"type":"string","maxLength":250000}}},"KnowledgeSearchRequest":{"type":"object","required":["query"],"properties":{"query":{"type":"string","minLength":2,"maxLength":500},"limit":{"type":"integer","minimum":1,"maximum":20,"default":8},"source":{"type":"string","maxLength":80}}},"KnowledgeSearchResult":{"type":"object","properties":{"id":{"type":"string"},"sourceId":{"type":"string"},"sourceTitle":{"type":"string"},"sourceType":{"type":"string","enum":["profile","manual","website","document","catalog","service","faq","policy","conversation"]},"sourceUrl":{"type":"string","format":"uri"},"title":{"type":"string"},"content":{"type":"string"},"excerpt":{"type":"string"},"chunkIndex":{"type":"integer"},"tokenCount":{"type":"integer"},"score":{"type":"number"},"metadata":{"type":"object","additionalProperties":true},"createdAt":{"type":"integer"}}},"KnowledgeSourceResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeSource"}}},"KnowledgeSourceListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeSource"}},"meta":{"type":"object","properties":{"count":{"type":"integer"}}}}},"KnowledgeSearchResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeSearchResult"}},"meta":{"type":"object","properties":{"count":{"type":"integer"}}}}},"AIContextPreviewRequest":{"type":"object","required":["messageText"],"properties":{"sessionId":{"type":"string","maxLength":160},"chatJid":{"type":"string","maxLength":220},"messageText":{"type":"string","minLength":2,"maxLength":4000},"messageType":{"type":"string","default":"text","maxLength":80},"participantJid":{"type":"string","maxLength":220},"quotedText":{"type":"string","maxLength":2000},"knowledgeLimit":{"type":"integer","minimum":1,"maximum":10,"default":6},"messageLimit":{"type":"integer","minimum":0,"maximum":30,"default":12},"tokenBudget":{"type":"integer","minimum":2000,"maximum":16000,"default":6000},"source":{"type":"string","maxLength":80,"default":"ai_context"}}},"AIContextSource":{"type":"object","properties":{"chunkId":{"type":"string"},"sourceId":{"type":"string"},"sourceTitle":{"type":"string"},"sourceType":{"type":"string","enum":["profile","manual","website","document","catalog","service","faq","policy","conversation"]},"sourceUrl":{"type":"string","format":"uri"},"title":{"type":"string"},"excerpt":{"type":"string"},"score":{"type":"number"},"chunkIndex":{"type":"integer"},"tokenCount":{"type":"integer"},"metadata":{"type":"object","additionalProperties":true}}},"AIContextConversationLine":{"type":"object","properties":{"id":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"sender":{"type":"string"},"text":{"type":"string"},"messageType":{"type":"string"},"status":{"type":"string"},"timestamp":{"type":"integer"}}},"AIContextDecisionFlag":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"severity":{"type":"string","enum":["info","warning","block"]}}},"AIGuardrailResult":{"type":"object","properties":{"phase":{"type":"string","enum":["pre_generation","post_generation"]},"allowGenerate":{"type":"boolean"},"allowSend":{"type":"boolean"},"shouldHandoff":{"type":"boolean"},"reason":{"type":"string"},"flags":{"type":"array","items":{"$ref":"#/components/schemas/AIContextDecisionFlag"}}}},"AILeadQualification":{"type":"object","properties":{"stage":{"type":"string","enum":["not_lead","new","qualifying","qualified","hot"]},"intent":{"type":"string","enum":["unknown","support","sales","pricing","booking","order_tracking"]},"score":{"type":"integer","minimum":0,"maximum":100},"capturedDetails":{"type":"object","properties":{"name":{"type":"string"},"phone":{"type":"string"},"email":{"type":"string"},"city":{"type":"string"},"budget":{"type":"string"},"timeline":{"type":"string"},"serviceInterest":{"type":"string"}}},"missingDetails":{"type":"array","items":{"type":"string","enum":["name","phone","service","budget","timeline","city"]}},"shouldCollectDetails":{"type":"boolean"},"nextQuestion":{"type":"string"},"suggestedTags":{"type":"array","items":{"type":"string"}},"reasons":{"type":"array","items":{"type":"string"}}}},"AIContextResult":{"type":"object","properties":{"shouldAnswer":{"type":"boolean"},"shouldHandoff":{"type":"boolean"},"blockedReason":{"type":"string"},"guardrail":{"$ref":"#/components/schemas/AIGuardrailResult"},"systemInstructions":{"type":"string"},"contextText":{"type":"string"},"sources":{"type":"array","items":{"$ref":"#/components/schemas/AIContextSource"}},"conversation":{"type":"array","items":{"$ref":"#/components/schemas/AIContextConversationLine"}},"leadQualification":{"$ref":"#/components/schemas/AILeadQualification"},"decisionFlags":{"type":"array","items":{"$ref":"#/components/schemas/AIContextDecisionFlag"}},"tokenEstimate":{"type":"integer"},"trimmedMessageCount":{"type":"integer"}}},"AIContextPreviewResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/AIContextResult"}}},"BusinessKnowledgeStatus":{"type":"string","enum":["draft","approved","archived"]},"ServicePrice":{"type":"object","properties":{"id":{"type":"string"},"serviceId":{"type":"string"},"priceType":{"type":"string","enum":["fixed","from","range","hourly","free","quote"]},"amountMinor":{"type":"integer","minimum":0},"minAmountMinor":{"type":"integer","minimum":0},"maxAmountMinor":{"type":"integer","minimum":0},"currency":{"type":"string","minLength":3,"maxLength":3},"unit":{"type":"string","maxLength":40},"displayPrice":{"type":"string","maxLength":120},"effectiveFrom":{"type":"integer"},"effectiveUntil":{"type":"integer"},"approvedAt":{"type":"integer"},"archivedAt":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"ServicePriceRequest":{"type":"object","properties":{"priceType":{"type":"string","enum":["fixed","from","range","hourly","free","quote"],"default":"quote"},"amountMinor":{"type":"integer","minimum":0,"maximum":1000000000},"minAmountMinor":{"type":"integer","minimum":0,"maximum":1000000000},"maxAmountMinor":{"type":"integer","minimum":0,"maximum":1000000000},"currency":{"type":"string","minLength":3,"maxLength":3,"default":"PKR"},"unit":{"type":"string","maxLength":40},"displayPrice":{"type":"string","maxLength":120},"effectiveFrom":{"type":"string","format":"date-time"},"effectiveUntil":{"type":"string","format":"date-time"}}},"BusinessService":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"sourceKey":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":"string"},"category":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"status":{"$ref":"#/components/schemas/BusinessKnowledgeStatus"},"availability":{"type":"string","enum":["available","limited","unavailable","quote_only"]},"source":{"type":"string","enum":["onboarding","manual","import","website","whatsapp"]},"priority":{"type":"integer"},"url":{"type":"string","format":"uri"},"imageUrl":{"type":"string","format":"uri"},"metadata":{"type":"object","additionalProperties":true},"handoffRequired":{"type":"boolean"},"blockedIfUnclear":{"type":"boolean"},"version":{"type":"integer"},"knowledgeSourceId":{"type":"string"},"approvedAt":{"type":"integer"},"archivedAt":{"type":"integer"},"price":{"$ref":"#/components/schemas/ServicePrice"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"BusinessServiceRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":2,"maxLength":160},"slug":{"type":"string","maxLength":180},"description":{"type":"string","maxLength":4000},"category":{"type":"string","maxLength":100},"tags":{"type":"array","maxItems":30,"items":{"type":"string","maxLength":40}},"status":{"$ref":"#/components/schemas/BusinessKnowledgeStatus"},"availability":{"type":"string","enum":["available","limited","unavailable","quote_only"],"default":"available"},"source":{"type":"string","enum":["onboarding","manual","import","website","whatsapp"],"default":"manual"},"priority":{"type":"integer","minimum":0,"maximum":1000},"url":{"type":"string","format":"uri"},"imageUrl":{"type":"string","format":"uri"},"metadata":{"type":"object","additionalProperties":true},"handoffRequired":{"type":"boolean"},"blockedIfUnclear":{"type":"boolean"},"price":{"$ref":"#/components/schemas/ServicePriceRequest"},"changeReason":{"type":"string","maxLength":500}}},"BusinessServicePatchRequest":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":160},"slug":{"type":"string","maxLength":180,"nullable":true},"description":{"type":"string","maxLength":4000,"nullable":true},"category":{"type":"string","maxLength":100,"nullable":true},"tags":{"type":"array","maxItems":30,"items":{"type":"string","maxLength":40}},"availability":{"type":"string","enum":["available","limited","unavailable","quote_only"]},"source":{"type":"string","enum":["onboarding","manual","import","website","whatsapp"]},"priority":{"type":"integer","minimum":0,"maximum":1000},"url":{"type":"string","format":"uri","nullable":true},"imageUrl":{"type":"string","format":"uri","nullable":true},"metadata":{"type":"object","additionalProperties":true,"nullable":true},"handoffRequired":{"type":"boolean"},"blockedIfUnclear":{"type":"boolean"},"price":{"$ref":"#/components/schemas/ServicePriceRequest"},"changeReason":{"type":"string","maxLength":500}}},"BusinessFaq":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"sourceKey":{"type":"string"},"question":{"type":"string"},"answer":{"type":"string"},"category":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"status":{"$ref":"#/components/schemas/BusinessKnowledgeStatus"},"priority":{"type":"integer"},"effectiveFrom":{"type":"integer"},"effectiveUntil":{"type":"integer"},"sourceUrl":{"type":"string","format":"uri"},"sourceLabel":{"type":"string"},"handoffRequired":{"type":"boolean"},"version":{"type":"integer"},"knowledgeSourceId":{"type":"string"},"approvedAt":{"type":"integer"},"archivedAt":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"BusinessFaqRequest":{"type":"object","required":["question","answer"],"properties":{"question":{"type":"string","minLength":2,"maxLength":500},"answer":{"type":"string","minLength":2,"maxLength":5000},"category":{"type":"string","maxLength":80},"tags":{"type":"array","maxItems":30,"items":{"type":"string","maxLength":40}},"status":{"$ref":"#/components/schemas/BusinessKnowledgeStatus"},"priority":{"type":"integer","minimum":0,"maximum":1000},"effectiveFrom":{"type":"string","format":"date-time"},"effectiveUntil":{"type":"string","format":"date-time"},"sourceUrl":{"type":"string","format":"uri"},"sourceLabel":{"type":"string","maxLength":160},"handoffRequired":{"type":"boolean"},"changeReason":{"type":"string","maxLength":500}}},"BusinessFaqPatchRequest":{"type":"object","properties":{"question":{"type":"string","minLength":2,"maxLength":500},"answer":{"type":"string","minLength":2,"maxLength":5000},"category":{"type":"string","maxLength":80,"nullable":true},"tags":{"type":"array","maxItems":30,"items":{"type":"string","maxLength":40}},"priority":{"type":"integer","minimum":0,"maximum":1000},"effectiveFrom":{"type":"string","format":"date-time","nullable":true},"effectiveUntil":{"type":"string","format":"date-time","nullable":true},"sourceUrl":{"type":"string","format":"uri","nullable":true},"sourceLabel":{"type":"string","maxLength":160,"nullable":true},"handoffRequired":{"type":"boolean"},"changeReason":{"type":"string","maxLength":500}}},"BusinessPolicy":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"sourceKey":{"type":"string"},"type":{"type":"string","enum":["refund","delivery","cancellation","booking","privacy","terms","custom"]},"title":{"type":"string"},"body":{"type":"string"},"category":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"status":{"$ref":"#/components/schemas/BusinessKnowledgeStatus"},"severity":{"type":"string","enum":["info","sensitive","critical"]},"priority":{"type":"integer"},"effectiveFrom":{"type":"integer"},"effectiveUntil":{"type":"integer"},"sourceUrl":{"type":"string","format":"uri"},"sourceLabel":{"type":"string"},"handoffRequired":{"type":"boolean"},"blockedIfUnclear":{"type":"boolean"},"version":{"type":"integer"},"knowledgeSourceId":{"type":"string"},"approvedAt":{"type":"integer"},"archivedAt":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"BusinessPolicyRequest":{"type":"object","required":["title","body"],"properties":{"type":{"type":"string","enum":["refund","delivery","cancellation","booking","privacy","terms","custom"],"default":"custom"},"title":{"type":"string","minLength":2,"maxLength":160},"body":{"type":"string","minLength":2,"maxLength":12000},"category":{"type":"string","maxLength":80},"tags":{"type":"array","maxItems":30,"items":{"type":"string","maxLength":40}},"status":{"$ref":"#/components/schemas/BusinessKnowledgeStatus"},"severity":{"type":"string","enum":["info","sensitive","critical"],"default":"info"},"priority":{"type":"integer","minimum":0,"maximum":1000},"effectiveFrom":{"type":"string","format":"date-time"},"effectiveUntil":{"type":"string","format":"date-time"},"sourceUrl":{"type":"string","format":"uri"},"sourceLabel":{"type":"string","maxLength":160},"handoffRequired":{"type":"boolean"},"blockedIfUnclear":{"type":"boolean"},"changeReason":{"type":"string","maxLength":500}}},"BusinessPolicyPatchRequest":{"type":"object","properties":{"type":{"type":"string","enum":["refund","delivery","cancellation","booking","privacy","terms","custom"]},"title":{"type":"string","minLength":2,"maxLength":160},"body":{"type":"string","minLength":2,"maxLength":12000},"category":{"type":"string","maxLength":80,"nullable":true},"tags":{"type":"array","maxItems":30,"items":{"type":"string","maxLength":40}},"severity":{"type":"string","enum":["info","sensitive","critical"]},"priority":{"type":"integer","minimum":0,"maximum":1000},"effectiveFrom":{"type":"string","format":"date-time","nullable":true},"effectiveUntil":{"type":"string","format":"date-time","nullable":true},"sourceUrl":{"type":"string","format":"uri","nullable":true},"sourceLabel":{"type":"string","maxLength":160,"nullable":true},"handoffRequired":{"type":"boolean"},"blockedIfUnclear":{"type":"boolean"},"changeReason":{"type":"string","maxLength":500}}},"BusinessKnowledgePublishRequest":{"type":"object","properties":{"changeReason":{"type":"string","maxLength":500},"effectiveFrom":{"type":"string","format":"date-time","nullable":true},"effectiveUntil":{"type":"string","format":"date-time","nullable":true}}},"BusinessKnowledgeArchiveRequest":{"type":"object","properties":{"changeReason":{"type":"string","maxLength":500}}},"BusinessKnowledgeRevision":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"targetId":{"type":"string"},"version":{"type":"integer"},"action":{"type":"string"},"snapshot":{"type":"object","additionalProperties":true},"changeReason":{"type":"string"},"createdByUserId":{"type":"string"},"createdAt":{"type":"integer"}}},"BusinessServiceResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/BusinessService"}}},"BusinessServiceListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/BusinessService"}},"meta":{"type":"object","properties":{"count":{"type":"integer"}}}}},"BusinessFaqResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/BusinessFaq"}}},"BusinessFaqListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/BusinessFaq"}},"meta":{"type":"object","properties":{"count":{"type":"integer"}}}}},"BusinessPolicyResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/BusinessPolicy"}}},"BusinessPolicyListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/BusinessPolicy"}},"meta":{"type":"object","properties":{"count":{"type":"integer"}}}}},"BusinessKnowledgeRevisionListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/BusinessKnowledgeRevision"}},"meta":{"type":"object","properties":{"count":{"type":"integer"}}}}},"InteractiveMessageRequest":{"oneOf":[{"type":"object","required":["type","question","options"],"properties":{"type":{"type":"string","const":"poll"},"question":{"type":"string","minLength":1,"maxLength":255},"options":{"type":"array","minItems":2,"maxItems":12,"items":{"type":"string","minLength":1,"maxLength":100}},"multipleAnswers":{"type":"boolean","default":false}}},{"type":"object","required":["type","body","buttons"],"properties":{"type":{"type":"string","enum":["quick_replies","buttons"]},"body":{"type":"string","minLength":1,"maxLength":255},"buttons":{"type":"array","minItems":2,"maxItems":3,"items":{"oneOf":[{"type":"string","minLength":1,"maxLength":25},{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":120},"buttonId":{"type":"string","minLength":1,"maxLength":120},"title":{"type":"string","minLength":1,"maxLength":25},"text":{"type":"string","minLength":1,"maxLength":25},"label":{"type":"string","minLength":1,"maxLength":25}}}]}},"footer":{"type":"string","maxLength":120}}}],"description":"Polls use WhatsApp native poll transport. Quick replies are delivered as a single-answer poll because WhatsApp Web button transports are unstable across clients."},"SendMessageRequest":{"type":"object","description":"`to`/`text`/`mediaUrl` are canonical. `chatId`/`message`/`urlFile` are GreenAPI-compatible aliases. Use `interactive` for polls and reliable quick replies. Contact cards and location messages are supported as single-purpose WhatsApp payloads.","properties":{"to":{"type":"string","examples":["+15551234567","15551234567@s.whatsapp.net"]},"chatId":{"type":"string","examples":["15551234567@c.us","120363025000000000@g.us"]},"text":{"type":"string","maxLength":20000},"message":{"type":"string","maxLength":20000},"interactive":{"$ref":"#/components/schemas/InteractiveMessageRequest"},"contact":{"type":"object","required":["displayName","phoneE164"],"properties":{"displayName":{"type":"string","minLength":1,"maxLength":120},"phoneE164":{"type":"string","examples":["+15551234567"]}}},"contacts":{"type":"array","minItems":1,"maxItems":25,"items":{"type":"object","required":["displayName","phoneE164"],"properties":{"displayName":{"type":"string","minLength":1,"maxLength":120},"phoneE164":{"type":"string","examples":["+15551234567"]}}}},"location":{"type":"object","required":["latitude","longitude"],"properties":{"latitude":{"type":"number","minimum":-90,"maximum":90},"longitude":{"type":"number","minimum":-180,"maximum":180},"name":{"type":"string","maxLength":120},"address":{"type":"string","maxLength":300}}},"mediaId":{"type":"string","description":"ID returned by POST /api/v1/media/upload."},"mediaUrl":{"type":"string","format":"uri"},"urlFile":{"type":"string","format":"uri"},"mediaType":{"type":"string","enum":["image","video","audio","document"]},"fileName":{"type":"string","minLength":1,"maxLength":255},"mimeType":{"type":"string","minLength":3,"maxLength":200},"caption":{"type":"string"},"replyToId":{"type":"string"},"audioAsVoice":{"type":"boolean"},"gifPlayback":{"type":"boolean"},"typingTime":{"type":"integer","minimum":1000,"maximum":20000},"typingType":{"type":"string","enum":["composing","recording"]},"sessionId":{"type":"string","description":"Optional linked WhatsApp session id. Omit this unless you must force a specific sender."},"allowFallback":{"type":"boolean","description":"When sessionId is provided, allow WAQueen to use another send-ready session if the requested session is temporarily restoring. Real logged-out or QR-required sessions are not silently replaced."},"idempotencyKey":{"type":"string","minLength":8,"maxLength":200}},"anyOf":[{"required":["to"]},{"required":["chatId"]}],"oneOf":[{"required":["text"]},{"required":["message"]},{"required":["interactive"]},{"required":["contact"]},{"required":["contacts"]},{"required":["location"]},{"required":["mediaId"]},{"required":["mediaUrl"]},{"required":["urlFile"]}]},"MediaUploadResponse":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","required":["id","fileName","mimeType","mediaType","sizeBytes"],"properties":{"id":{"type":"string"},"businessId":{"type":"string"},"fileName":{"type":"string"},"originalFileName":{"type":"string"},"mimeType":{"type":"string"},"mediaType":{"type":"string","enum":["image","video","audio","document"]},"sizeBytes":{"type":"integer"},"sha256":{"type":"string"},"status":{"type":"string","enum":["active","deleted"]},"expiresAt":{"type":"integer"},"createdAt":{"type":"integer"}}}}},"SendMessageResponse":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","required":["messageId","toJid","status","sessionId"],"properties":{"messageId":{"type":"string"},"whatsappMessageId":{"type":"string"},"toJid":{"type":"string"},"status":{"type":"string","enum":["queued","sent","failed","cancelled"]},"queuedAt":{"type":"integer"},"sentAt":{"type":"integer"},"expiresAt":{"type":"integer"},"idempotentReplay":{"type":"boolean"},"sessionId":{"type":"string"},"fallbackUsed":{"type":"boolean"},"requestedSessionId":{"type":"string"}}}}},"WhatsAppCheckNumberRequest":{"type":"object","required":["phoneNumber"],"properties":{"phoneNumber":{"type":"string","examples":["+923001234567"],"minLength":5,"maxLength":32},"sessionId":{"type":"string","description":"Optional linked WhatsApp session id. If omitted, WAQueen selects a send-ready session."}}},"WhatsAppCheckNumberResponse":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","required":["sessionId","phoneNumber","existsWhatsapp","chatId"],"properties":{"sessionId":{"type":"string"},"phoneNumber":{"type":"string","examples":["+923001234567"]},"existsWhatsapp":{"type":"boolean"},"chatId":{"type":"string","examples":["923001234567@s.whatsapp.net"]}}}}},"SessionSettings":{"type":"object","properties":{"delaySendMessagesMilliseconds":{"type":"integer","minimum":500,"maximum":600000},"markIncomingMessagesRead":{"type":"boolean"},"markIncomingMessagesReadOnReply":{"type":"boolean"},"incomingWebhook":{"type":"boolean"},"outgoingWebhook":{"type":"boolean"},"outgoingMessageWebhook":{"type":"boolean"},"outgoingAPIMessageWebhook":{"type":"boolean"},"stateWebhook":{"type":"boolean"},"pollMessageWebhook":{"type":"boolean"},"incomingCallWebhook":{"type":"boolean"},"editedMessageWebhook":{"type":"boolean"},"deletedMessageWebhook":{"type":"boolean"},"keepOnlineStatus":{"type":"boolean"}}},"SessionConnectionSummary":{"type":"object","properties":{"authState":{"type":"string","enum":["unknown","authorized","qr_required","logged_out","blocked"]},"connectionState":{"type":"string","enum":["online","connecting","restoring","reconnecting","offline","stale","qr_required","logged_out","error","stopped"]},"operationalState":{"type":"string","enum":["healthy","degraded","unavailable"]},"online":{"type":"boolean"},"canSendMessages":{"type":"boolean"},"canAttemptReconnect":{"type":"boolean"},"canAcceptSendRequest":{"type":"boolean"},"liveSocket":{"type":"boolean"},"heartbeatFresh":{"type":"boolean"},"reason":{"type":"string"}}},"Session":{"type":"object","required":["id","businessId","name","status","createdAt","updatedAt","settings"],"properties":{"id":{"type":"string"},"businessId":{"type":"string"},"name":{"type":"string"},"provider":{"type":"string","enum":["baileys","greenapi"]},"status":{"type":"string","enum":["pending","qr","connecting","connected","disconnected","logged_out","error"]},"selfE164":{"type":"string"},"selfName":{"type":"string"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"},"webhookUrl":{"type":"string","format":"uri"},"dmPolicy":{"type":"string","enum":["open","allowlist","pairing","disabled"]},"allowFrom":{"type":"array","items":{"type":"string"}},"settings":{"$ref":"#/components/schemas/SessionSettings"},"metrics":{"type":"object","properties":{"sent":{"type":"integer"},"received":{"type":"integer"},"failed":{"type":"integer"}}},"healthState":{"type":"string","enum":["unknown","healthy","reconnecting","stale","logged_out","error","stopped"]},"connection":{"$ref":"#/components/schemas/SessionConnectionSummary"}}},"CreateSessionRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":2,"maxLength":48},"webhookUrl":{"type":"string","format":"uri"},"dmPolicy":{"type":"string","enum":["open","allowlist","pairing","disabled"]},"allowFrom":{"type":"array","maxItems":100,"items":{"type":"string"}},"settings":{"$ref":"#/components/schemas/SessionSettings"}}},"UpdateSessionRequest":{"allOf":[{"$ref":"#/components/schemas/CreateSessionRequest"}],"description":"All fields are optional on PATCH. Set webhookUrl to an empty string or null to clear it."},"SessionListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/Session"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"}}}}},"SessionResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Session"}}},"SessionCreateResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"allOf":[{"$ref":"#/components/schemas/Session"}],"properties":{"webhookSecret":{"type":"string","description":"Shown once when the session is created."}}}}},"QrPairingResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"status":{"type":"string"},"connected":{"type":"boolean"},"qrDataUrl":{"type":"string"},"qrVersion":{"type":"integer"},"qrIssuedAt":{"type":"integer"},"qrExpiresAt":{"type":"integer"},"pairingExpiresAt":{"type":"integer"},"code":{"type":"string"},"message":{"type":"string"}}}}},"SessionStatusResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/SessionConnectionSummary"}}},"SessionPersistenceResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object"}}},"SessionEventsResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"type":"object"}}}},"MessageRecord":{"type":"object","properties":{"id":{"type":"string"},"sessionId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"status":{"type":"string","enum":["queued","sent","delivered","read","failed","cancelled"]},"toJid":{"type":"string"},"whatsappMessageId":{"type":"string"},"messageType":{"type":"string"},"text":{"type":"string"},"mediaUrl":{"type":"string"},"fileName":{"type":"string"},"mimeType":{"type":"string"},"queuedAt":{"type":"integer"},"sendAfter":{"type":"integer"},"expiresAt":{"type":"integer"},"sentAt":{"type":"integer"},"deliveredAt":{"type":"integer"},"readAt":{"type":"integer"},"failedAt":{"type":"integer"},"attemptCount":{"type":"integer"},"lastError":{"type":"string"},"source":{"type":"string"},"createdByUserId":{"type":"string"},"agentNameSnapshot":{"type":"string"},"replyToMessageId":{"type":"string"},"manualReply":{"type":"boolean"}}},"MessageQueueListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/MessageRecord"}},"meta":{"type":"object","properties":{"sessionId":{"type":"string"},"status":{"type":"string"},"count":{"type":"integer"},"limit":{"type":"integer"},"summary":{"type":"object"}}}}},"MessageRecordResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/MessageRecord"}}},"Contact":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"phoneE164":{"type":"string","examples":["+15551234567"]},"jid":{"type":"string","examples":["15551234567@s.whatsapp.net","120363025000000000@g.us"]},"name":{"type":"string"},"displayName":{"type":"string"},"avatarUrl":{"type":"string","format":"uri"},"lastSeenAt":{"type":"integer"},"isBusiness":{"type":"boolean"},"isGroup":{"type":"boolean"},"blockedAt":{"type":"integer"},"optedOutAt":{"type":"integer"},"notes":{"type":"string"},"source":{"type":"string","examples":["manual","inbound","api"]},"lastInboundAt":{"type":"integer"},"lastOutboundAt":{"type":"integer"},"tags":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"ContactUpsertRequest":{"type":"object","properties":{"phoneE164":{"type":"string","minLength":5,"maxLength":32},"jid":{"type":"string","minLength":5,"maxLength":120},"chatId":{"type":"string","minLength":5,"maxLength":120},"name":{"type":"string","nullable":true,"maxLength":120},"displayName":{"type":"string","nullable":true,"maxLength":120},"avatarUrl":{"type":"string","nullable":true,"format":"uri"},"lastSeenAt":{"type":"integer","nullable":true,"minimum":0},"isBusiness":{"type":"boolean"},"isGroup":{"type":"boolean"},"blockedAt":{"type":"integer","nullable":true,"minimum":0},"optedOutAt":{"type":"integer","nullable":true,"minimum":0},"notes":{"type":"string","nullable":true,"maxLength":5000},"source":{"type":"string","minLength":1,"maxLength":40},"tags":{"type":"array","maxItems":20,"items":{"type":"string","minLength":1,"maxLength":40}},"metadata":{"type":"object"}},"anyOf":[{"required":["phoneE164"]},{"required":["jid"]},{"required":["chatId"]}]},"ContactUpdateRequest":{"allOf":[{"$ref":"#/components/schemas/ContactUpsertRequest"}],"description":"All fields are optional on PATCH. Phone/JID changes are normalized and deduplicated."},"ContactActionRequest":{"type":"object","properties":{"blocked":{"type":"boolean"},"optedOut":{"type":"boolean"},"reason":{"type":"string","maxLength":500}}},"ContactLeadDetails":{"type":"object","properties":{"name":{"type":"string","maxLength":120},"phone":{"type":"string","maxLength":40},"email":{"type":"string","format":"email","maxLength":160},"city":{"type":"string","maxLength":100},"budget":{"type":"string","maxLength":120},"timeline":{"type":"string","maxLength":120},"serviceInterest":{"type":"string","maxLength":180}}},"ContactLeadActionRequest":{"type":"object","required":["action"],"properties":{"action":{"type":"string","enum":["mark_qualified","mark_not_lead","update_details","assign_owner","set_follow_up","clear_follow_up","mark_won","mark_lost","reopen"]},"capturedDetails":{"$ref":"#/components/schemas/ContactLeadDetails"},"note":{"type":"string","maxLength":500},"assignedToUserId":{"type":"string","nullable":true,"maxLength":120},"assignedToName":{"type":"string","nullable":true,"maxLength":120},"followUpAt":{"type":"integer","nullable":true,"minimum":0},"followUpNote":{"type":"string","nullable":true,"maxLength":500},"outcomeReason":{"type":"string","nullable":true,"maxLength":500}}},"ContactListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"},"q":{"type":"string"},"tag":{"type":"string"},"type":{"type":"string","enum":["all","user","group"]},"status":{"type":"string","enum":["all","active","blocked","opted_out"]}}}}},"ContactResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Contact"}}},"ContactDeleteResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"id":{"type":"string"},"deleted":{"type":"boolean","const":true}}}}},"ContactCheckWhatsappRequest":{"type":"object","required":["sessionId"],"properties":{"sessionId":{"type":"string"},"phoneNumber":{"type":"string","examples":["+15551234567"]},"chatId":{"type":"string","examples":["15551234567@c.us"]}},"oneOf":[{"required":["phoneNumber"]},{"required":["chatId"]}]},"ContactCheckWhatsappResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"sessionId":{"type":"string"},"existsWhatsapp":{"type":"boolean"},"chatId":{"type":"string"}}}}},"Tag":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"slug":{"type":"string","examples":["vip"]},"name":{"type":"string","examples":["vip"]},"color":{"type":"string","enum":["violet","blue","mint","amber","peach","slate"]},"description":{"type":"string"},"archivedAt":{"type":"integer"},"contactCount":{"type":"integer"},"conversationCount":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"TagUpsertRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":1,"maxLength":80},"color":{"type":"string","enum":["violet","blue","mint","amber","peach","slate"]},"description":{"type":"string","nullable":true,"maxLength":500}}},"TagUpdateRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"color":{"type":"string","enum":["violet","blue","mint","amber","peach","slate"]},"description":{"type":"string","nullable":true,"maxLength":500},"archived":{"type":"boolean"}}},"TagListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/Tag"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"q":{"type":"string"},"includeArchived":{"type":"boolean"}}}}},"TagResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Tag"}}},"BulkContactTagsRequest":{"type":"object","required":["contactIds"],"properties":{"contactIds":{"type":"array","minItems":1,"maxItems":500,"items":{"type":"string"}},"addTags":{"type":"array","maxItems":25,"items":{"type":"string","minLength":1,"maxLength":40}},"removeTags":{"type":"array","maxItems":25,"items":{"type":"string","minLength":1,"maxLength":40}}}},"BulkContactTagsResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"updated":{"type":"integer"},"tags":{"type":"array","items":{"type":"string"}}}}}},"SegmentRuleCondition":{"type":"object","required":["field","op"],"properties":{"field":{"type":"string","enum":["tags","isGroup","isBusiness","blockedAt","optedOutAt","lastInboundAt","lastOutboundAt","source"]},"op":{"type":"string","enum":["has","notHas","equals","notEquals","isNull","isNotNull","afterDaysAgo","beforeDaysAgo"]},"value":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"SegmentRules":{"type":"object","description":"Safe rule tree. Use `all`, `any`, or `not` nodes, or condition nodes with supported fields/operators.","properties":{"all":{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/SegmentRuleCondition"},{"type":"object"}]}},"any":{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/SegmentRuleCondition"},{"type":"object"}]}},"not":{"type":"object"},"field":{"type":"string"},"op":{"type":"string"},"value":{"oneOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}},"additionalProperties":false},"Segment":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"slug":{"type":"string","examples":["vip-active-customers"]},"name":{"type":"string"},"description":{"type":"string"},"type":{"type":"string","enum":["dynamic","static"]},"rules":{"$ref":"#/components/schemas/SegmentRules"},"defaultExcludesOptedOut":{"type":"boolean"},"defaultExcludesBlocked":{"type":"boolean"},"cachedCount":{"type":"integer"},"lastEvaluatedAt":{"type":"integer"},"archivedAt":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"SegmentUpsertRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":1,"maxLength":120},"description":{"type":"string","nullable":true,"maxLength":1000},"type":{"type":"string","enum":["dynamic","static"]},"rules":{"$ref":"#/components/schemas/SegmentRules"},"defaultExcludesOptedOut":{"type":"boolean"},"defaultExcludesBlocked":{"type":"boolean"},"contactIds":{"type":"array","maxItems":2000,"items":{"type":"string"}}}},"SegmentUpdateRequest":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"description":{"type":"string","nullable":true,"maxLength":1000},"type":{"type":"string","enum":["dynamic","static"]},"rules":{"$ref":"#/components/schemas/SegmentRules"},"defaultExcludesOptedOut":{"type":"boolean"},"defaultExcludesBlocked":{"type":"boolean"},"contactIds":{"type":"array","maxItems":2000,"items":{"type":"string"}},"archived":{"type":"boolean"}}},"SegmentPreviewRequest":{"type":"object","properties":{"rules":{"$ref":"#/components/schemas/SegmentRules"},"defaultExcludesOptedOut":{"type":"boolean"},"defaultExcludesBlocked":{"type":"boolean"},"limit":{"type":"integer","minimum":1,"maximum":200}}},"SegmentListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/Segment"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"q":{"type":"string"},"includeArchived":{"type":"boolean"}}}}},"SegmentResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Segment"}}},"SegmentPreviewResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"count":{"type":"integer"},"contacts":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}}}}}},"SegmentContactsResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"meta":{"type":"object","properties":{"segment":{"$ref":"#/components/schemas/Segment"},"count":{"type":"integer"},"limit":{"type":"integer"}}}}},"SegmentRecalculateResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"count":{"type":"integer"},"segment":{"$ref":"#/components/schemas/Segment"}}}}},"InboxConversation":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"sessionId":{"type":"string"},"chatJid":{"type":"string"},"chatType":{"type":"string","enum":["direct","group"]},"displayName":{"type":"string"},"lastMessageId":{"type":"string"},"lastMessageAt":{"type":"integer"},"lastMessagePreview":{"type":"string"},"unreadCount":{"type":"integer"},"readAt":{"type":"integer"},"archivedAt":{"type":"integer"},"mutedUntil":{"type":"integer"},"assignedUserId":{"type":"string"},"handoffState":{"type":"string","enum":["bot","human","paused"]},"botPausedUntil":{"type":"integer"},"botPausedByUserId":{"type":"string"},"botPauseReason":{"type":"string"},"lastManualReplyAt":{"type":"integer"},"tags":{"type":"array","items":{"type":"string"}},"syncStatus":{"type":"string","enum":["pending","syncing","partial","synced","failed"]},"syncMetadata":{"type":"object","additionalProperties":true},"lastSyncedAt":{"type":"integer"},"contact":{"type":"object","properties":{"id":{"type":"string"},"phoneE164":{"type":"string"},"jid":{"type":"string"},"name":{"type":"string"},"displayName":{"type":"string"},"avatarUrl":{"type":"string","format":"uri"},"blockedAt":{"type":"integer"},"optedOutAt":{"type":"integer"},"tags":{"type":"array","items":{"type":"string"}},"metadata":{"type":"object"}}},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"InboxMessage":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"sessionId":{"type":"string"},"whatsappMessageId":{"type":"string"},"direction":{"type":"string","enum":["inbound","outbound"]},"chatJid":{"type":"string"},"fromJid":{"type":"string"},"toJid":{"type":"string"},"senderJid":{"type":"string"},"participantJid":{"type":"string"},"text":{"type":"string"},"caption":{"type":"string"},"mediaType":{"type":"string"},"messageType":{"type":"string"},"media":{"type":"object"},"interactive":{"type":"object","additionalProperties":true},"quoted":{"type":"object"},"mentions":{"type":"array","items":{"type":"string"}},"senderName":{"type":"string"},"status":{"type":"string"},"isGroup":{"type":"boolean"},"timestamp":{"type":"integer"},"queuedAt":{"type":"integer"},"sentAt":{"type":"integer"},"deliveredAt":{"type":"integer"},"readAt":{"type":"integer"},"failedAt":{"type":"integer"},"cancelledAt":{"type":"integer"},"lastError":{"type":"string"},"source":{"type":"string"},"createdByUserId":{"type":"string"},"agentNameSnapshot":{"type":"string"},"replyToMessageId":{"type":"string"},"manualReply":{"type":"boolean"},"mediaStatus":{"type":"string","enum":["none","pending","stored","expired","failed"]},"mediaAssetId":{"type":"string"},"mediaStorageKey":{"type":"string"},"mediaMimeType":{"type":"string"},"mediaFileName":{"type":"string"},"mediaSizeBytes":{"type":"integer"},"mediaError":{"type":"string"},"reconciliationStatus":{"type":"string","enum":["none","exact_match","ambiguous","unmatched","duplicate_replay"]},"reconciliationKey":{"type":"string"},"reconciliationError":{"type":"string"},"createdAt":{"type":"integer"}}},"InboxConversationListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/InboxConversation"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"},"sessionId":{"type":"string"},"q":{"type":"string"},"includeArchived":{"type":"boolean"}}}}},"InboxConversationResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/InboxConversation"}}},"InboxConversationCreateRequest":{"type":"object","required":["sessionId"],"properties":{"sessionId":{"type":"string"},"chatJid":{"type":"string","minLength":1,"maxLength":120},"chatId":{"type":"string","minLength":1,"maxLength":120},"phoneNumber":{"oneOf":[{"type":"string","minLength":5,"maxLength":32},{"type":"integer","minimum":1}]},"displayName":{"type":"string","nullable":true,"minLength":1,"maxLength":120}},"oneOf":[{"required":["chatJid"]},{"required":["chatId"]},{"required":["phoneNumber"]}]},"InboxMessageListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/InboxMessage"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"},"sessionId":{"type":"string"},"chatJid":{"type":"string"},"before":{"type":"integer"},"hasMore":{"type":"boolean"},"nextBefore":{"type":"integer"}}}}},"InboxConversationUpdateRequest":{"type":"object","required":["sessionId"],"properties":{"sessionId":{"type":"string"},"displayName":{"type":"string","nullable":true,"minLength":1,"maxLength":120},"archived":{"type":"boolean"},"handoffState":{"type":"string","enum":["bot","human","paused"]},"botPausedUntil":{"type":"integer","nullable":true},"botPauseReason":{"type":"string","nullable":true,"maxLength":500},"tags":{"type":"array","maxItems":20,"items":{"type":"string","minLength":1,"maxLength":40}}}},"InboxConversationReadRequest":{"type":"object","required":["sessionId"],"properties":{"sessionId":{"type":"string"},"readAt":{"type":"integer"}}},"InboxHistoryResyncRequest":{"type":"object","required":["sessionId"],"properties":{"sessionId":{"type":"string"},"count":{"type":"integer","minimum":1,"maximum":50,"default":50},"fallbackFullSync":{"type":"boolean","default":true}}},"InboxHistoryResyncResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"status":{"type":"string","enum":["history_requested","full_history_requested"]},"sessionId":{"type":"string"},"businessId":{"type":"string"},"chatJid":{"type":"string"},"count":{"type":"integer"},"requestId":{"type":"string"},"oldestMessageId":{"type":"string"},"oldestMessageTimestamp":{"type":"integer"},"contactSyncJobId":{"type":"string"},"reason":{"type":"string"}}}}},"InboxReplyRequest":{"type":"object","required":["sessionId"],"properties":{"sessionId":{"type":"string"},"text":{"type":"string","minLength":1,"maxLength":20000},"interactive":{"$ref":"#/components/schemas/InteractiveMessageRequest"},"replyToMessageId":{"type":"string","minLength":1,"maxLength":200},"typingTime":{"type":"integer","minimum":1000,"maximum":20000},"idempotencyKey":{"type":"string","minLength":8,"maxLength":200}},"oneOf":[{"required":["text"]},{"required":["interactive"]}]},"InboxReplyResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"messageId":{"type":"string"},"whatsappMessageId":{"type":"string"},"toJid":{"type":"string"},"status":{"type":"string","enum":["queued","sent","failed","cancelled"]},"queuedAt":{"type":"integer"},"sentAt":{"type":"integer"},"expiresAt":{"type":"integer"},"idempotentReplay":{"type":"boolean"},"sessionId":{"type":"string"},"chatJid":{"type":"string"},"replyToMessageId":{"type":"string"},"manualReply":{"type":"boolean"},"conversation":{"$ref":"#/components/schemas/InboxConversation"}}}}},"QueueActionRequest":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500}}},"QueueClearResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"cancelled":{"type":"integer"},"skippedLocked":{"type":"integer"}}}}},"RetryRequest":{"type":"object","properties":{"retryAt":{"type":"integer","minimum":0},"delayMs":{"type":"integer","minimum":0,"maximum":86400000}}},"WebhookEvent":{"type":"object","required":["type","sessionId"],"properties":{"eventId":{"type":"string"},"deliveryId":{"type":"string"},"schemaVersion":{"type":"string"},"eventCreatedAt":{"type":"integer"},"type":{"type":"string","enum":["qr_updated","session.connected","session.disconnected","session.logged_out","session.health_changed","session.reconnecting","session.stale","message_received","message_queued","message_sent","message_delivered","message_read","message_failed","message_cancelled","message_retried","queue_cleared","webhook_test"]},"sessionId":{"type":"string"},"messageId":{"type":"string"},"whatsappMessageId":{"type":"string"},"chatJid":{"type":"string"},"senderJid":{"type":"string"},"participantJid":{"type":"string"},"chatType":{"type":"string","enum":["direct","group"]},"messageType":{"type":"string","enum":["text","image","video","audio","document","location","contact","contacts","sticker","reaction","poll","button","list","unknown"]},"toJid":{"type":"string"},"from":{"type":"string"},"fromJid":{"type":"string"},"status":{"type":"string"},"text":{"type":"string"},"caption":{"type":"string"},"mediaType":{"type":"string"},"media":{"type":"object"},"interactive":{"type":"object","additionalProperties":true},"quoted":{"type":"object"},"mentions":{"type":"array","items":{"type":"string"}},"senderName":{"type":"string"},"isGroup":{"type":"boolean"},"timestamp":{"type":"integer"}}},"WebhookDelivery":{"type":"object","properties":{"id":{"type":"string"},"eventId":{"type":"string"},"businessId":{"type":"string"},"sessionId":{"type":"string"},"messageId":{"type":"string"},"eventType":{"type":"string"},"status":{"type":"string","enum":["pending","delivering","delivered","failed"]},"webhookUrl":{"type":"string","format":"uri"},"payload":{"$ref":"#/components/schemas/WebhookEvent"},"attemptCount":{"type":"integer"},"nextAttemptAt":{"type":"integer"},"expiresAt":{"type":"integer"},"lastAttemptAt":{"type":"integer"},"deliveredAt":{"type":"integer"},"failedAt":{"type":"integer"},"lastError":{"type":"string"},"responseStatus":{"type":"integer"},"createdAt":{"type":"integer"},"updatedAt":{"type":"integer"}}},"WebhookDeliveryListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookDelivery"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"},"status":{"type":"string"},"sessionId":{"type":"string"},"summary":{"type":"object"}}}}},"WebhookDeliveryResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/WebhookDelivery"}}},"WebhookNotification":{"type":"object","nullable":true,"properties":{"receiptId":{"type":"string"},"eventId":{"type":"string"},"body":{"$ref":"#/components/schemas/WebhookEvent"},"receivedAt":{"type":"integer"},"expiresAt":{"type":"integer"}}},"WebhookNotificationReceiveResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/WebhookNotification"}}},"WebhookNotificationDeleteResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"object","properties":{"receiptId":{"type":"string"},"eventId":{"type":"string"},"deletedAt":{"type":"integer"}}}}},"ApiKey":{"type":"object","properties":{"id":{"type":"string"},"businessId":{"type":"string"},"prefix":{"type":"string"},"environment":{"type":"string","enum":["test","live"]},"label":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"rateLimitPerMinute":{"type":"integer"},"createdAt":{"type":"integer"},"createdByUserId":{"type":"string"},"rotatedAt":{"type":"integer"},"rotatedByUserId":{"type":"string"},"lastUsedAt":{"type":"integer"},"lastUsedIp":{"type":"string"},"expiresAt":{"type":"integer"},"revokedAt":{"type":"integer"},"revokedByUserId":{"type":"string"}}},"ApiKeyListResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"nextCursor":{"type":"string","nullable":true}}}}},"CreateApiKeyRequest":{"type":"object","required":["label"],"properties":{"label":{"type":"string","minLength":2,"maxLength":48},"environment":{"type":"string","enum":["test","live"],"default":"test"},"scopes":{"type":"array","items":{"type":"string"}},"rateLimitPerMinute":{"type":"integer","minimum":1,"maximum":600},"expiresAt":{"type":"string","nullable":true}}},"CreateApiKeyResponse":{"type":"object","properties":{"success":{"type":"boolean","const":true},"data":{"allOf":[{"$ref":"#/components/schemas/ApiKey"}],"properties":{"key":{"type":"string","description":"Plaintext API key. Shown only once."}}}}}}}}