{"openapi":"3.1.0","info":{"title":"Chatra AI — Open API","version":"1.0.0","description":"REST-API для интеграций с CRM, ERP, 1С и другими системами. Аутентификация через Bearer-ключ (Settings → API-ключи в дашборде). Полный гайд: https://chatra-ai.ru/docs/api/quickstart"},"servers":[{"url":"https://api.chatra-ai.ru"}],"paths":{"/api/v1/public/customers/upsert":{"post":{"tags":["open-api / customers"],"summary":"Создать или обновить контекст клиента","description":"Идемпотентный апдейт. Если клиент с таким `external_id` уже существует — перезаписываем атрибуты, email и phone (это разрешает CRM делать прямой PUT на каждое изменение записи). Если нет — создаём нового.","operationId":"upsert_customer_api_v1_public_customers_upsert_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerUpsertIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/public/customers/{external_id}":{"get":{"tags":["open-api / customers"],"summary":"Получить контекст клиента","operationId":"get_customer_api_v1_public_customers__external_id__get","parameters":[{"name":"external_id","in":"path","required":true,"schema":{"type":"string","title":"External Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/public/customers/{external_id}/events":{"post":{"tags":["open-api / customers"],"summary":"Записать событие клиента","description":"Append-only лог событий. Поле `summary_for_ai` — однострочное человеческое описание, которое AI получит как факт; `payload` сохраняется отдельно для вашей аналитики.","operationId":"append_event_api_v1_public_customers__external_id__events_post","parameters":[{"name":"external_id","in":"path","required":true,"schema":{"type":"string","title":"External Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerEventIn"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerEventOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["open-api / customers"],"summary":"Список событий клиента","operationId":"list_events_api_v1_public_customers__external_id__events_get","parameters":[{"name":"external_id","in":"path","required":true,"schema":{"type":"string","title":"External Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"since","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Since"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomerEventOut"},"title":"Response List Events Api V1 Public Customers  External Id  Events Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AccessToken":{"properties":{"access_token":{"type":"string","title":"Access Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"},"expires_in":{"type":"integer","title":"Expires In"}},"type":"object","required":["access_token","expires_in"],"title":"AccessToken"},"AnalyticsOverview":{"properties":{"today_total":{"type":"integer","title":"Today Total"},"today_escalated":{"type":"integer","title":"Today Escalated"},"today_resolved_by_bot":{"type":"integer","title":"Today Resolved By Bot"},"daily_series":{"items":{"$ref":"#/components/schemas/DailyPoint"},"type":"array","title":"Daily Series"},"latency_p50_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Latency P50 Ms"},"latency_p95_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Latency P95 Ms"},"deflection_pct":{"type":"integer","title":"Deflection Pct"},"csat_avg":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Csat Avg"},"csat_count":{"type":"integer","title":"Csat Count"},"kb_chunks_total":{"type":"integer","title":"Kb Chunks Total"}},"type":"object","required":["today_total","today_escalated","today_resolved_by_bot","daily_series","latency_p50_ms","latency_p95_ms","deflection_pct","csat_avg","csat_count","kb_chunks_total"],"title":"AnalyticsOverview"},"ApiKeyCreateIn":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name"},"scopes":{"items":{"type":"string"},"type":"array","title":"Scopes"},"mode":{"type":"string","pattern":"^(live|test)$","title":"Mode","default":"live"}},"type":"object","required":["name"],"title":"ApiKeyCreateIn"},"ApiKeyCreateOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"prefix":{"type":"string","title":"Prefix"},"scopes":{"items":{"type":"string"},"type":"array","title":"Scopes"},"mode":{"type":"string","title":"Mode"},"last_used_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Used At"},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Revoked At"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"plain_text_key":{"type":"string","title":"Plain Text Key"}},"type":"object","required":["id","name","prefix","scopes","mode","created_at","plain_text_key"],"title":"ApiKeyCreateOut","description":"Response for create — includes the full plain-text key.\n\nShown to the merchant ONCE on creation; we never persist or return\nthe plain-text value again."},"ApiKeyOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"prefix":{"type":"string","title":"Prefix"},"scopes":{"items":{"type":"string"},"type":"array","title":"Scopes"},"mode":{"type":"string","title":"Mode"},"last_used_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Used At"},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Revoked At"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","name","prefix","scopes","mode","created_at"],"title":"ApiKeyOut"},"Body_upload_file_api_v1_kb_upload_post":{"properties":{"file":{"type":"string","contentMediaType":"application/octet-stream","title":"File"}},"type":"object","required":["file"],"title":"Body_upload_file_api_v1_kb_upload_post"},"ChangePlanIn":{"properties":{"plan":{"type":"string","title":"Plan"},"return_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Return Url"}},"type":"object","required":["plan"],"title":"ChangePlanIn"},"ChangePlanOut":{"properties":{"confirmation_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Confirmation Url"},"payment_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payment Id"},"pending_change":{"anyOf":[{"$ref":"#/components/schemas/PendingChangeOut"},{"type":"null"}]},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"}},"type":"object","title":"ChangePlanOut","description":"Either a redirect (upgrade — confirmation_url set) or a no-op /\nscheduled response (downgrade or same-plan — confirmation_url=None)."},"CheckoutIn":{"properties":{"plan":{"type":"string","title":"Plan"},"return_url":{"type":"string","title":"Return Url"}},"type":"object","required":["plan","return_url"],"title":"CheckoutIn"},"CheckoutOut":{"properties":{"confirmation_url":{"type":"string","title":"Confirmation Url"},"payment_id":{"type":"string","title":"Payment Id"}},"type":"object","required":["confirmation_url","payment_id"],"title":"CheckoutOut"},"ClaimOut":{"properties":{"conversation_id":{"type":"string","format":"uuid","title":"Conversation Id"},"assigned_operator_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Assigned Operator Id"},"claimed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Claimed At"},"operator_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Operator Name"}},"type":"object","required":["conversation_id","assigned_operator_id","claimed_at"],"title":"ClaimOut"},"ConversationDetail":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"status":{"type":"string","enum":["open","escalated","closed"],"title":"Status"},"visitor_contact":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Visitor Contact"},"assigned_operator_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Assigned Operator Id"},"claimed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Claimed At"},"resolved_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Resolved By"},"csat_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Csat Score"},"started_at":{"type":"string","format":"date-time","title":"Started At"},"closed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Closed At"},"message_count":{"type":"integer","title":"Message Count"},"last_message_preview":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Message Preview"},"messages":{"items":{"$ref":"#/components/schemas/src__app__schemas__conversation__MessageOut"},"type":"array","title":"Messages"}},"type":"object","required":["id","status","started_at","message_count","messages"],"title":"ConversationDetail"},"ConversationOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"status":{"type":"string","enum":["open","escalated","closed"],"title":"Status"},"visitor_contact":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Visitor Contact"},"assigned_operator_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Assigned Operator Id"},"claimed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Claimed At"},"resolved_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Resolved By"},"csat_score":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Csat Score"},"started_at":{"type":"string","format":"date-time","title":"Started At"},"closed_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Closed At"},"message_count":{"type":"integer","title":"Message Count"},"last_message_preview":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Message Preview"}},"type":"object","required":["id","status","started_at","message_count"],"title":"ConversationOut"},"CrawlIn":{"properties":{"site_id":{"type":"string","format":"uuid","title":"Site Id"},"url":{"type":"string","title":"Url"},"max_pages":{"type":"integer","maximum":500.0,"minimum":1.0,"title":"Max Pages","default":50},"max_depth":{"type":"integer","maximum":5.0,"minimum":1.0,"title":"Max Depth","default":2}},"type":"object","required":["site_id","url"],"title":"CrawlIn"},"CsatIn":{"properties":{"score":{"type":"integer","maximum":5.0,"minimum":1.0,"title":"Score"},"comment":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Comment"}},"type":"object","required":["score"],"title":"CsatIn"},"CustomerEventIn":{"properties":{"type":{"type":"string","maxLength":64,"minLength":1,"title":"Type","description":"Тип события — короткий идентификатор. Соглашение: `<resource>.<verb>`, например `order.shipped`, `subscription.cancelled`, `appointment.rescheduled`."},"summary_for_ai":{"type":"string","maxLength":500,"minLength":1,"title":"Summary For Ai","description":"Однострочное человеческое описание события — то что AI получит как факт. Пример: «Заказ ORD-9821 отправлен СДЭК 7 мая, трекинг RU123456789». Без этого AI пришлось бы парсить произвольный JSON, что хрупко."},"occurred_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Occurred At","description":"Когда событие произошло. По умолчанию — момент получения запроса."},"payload":{"additionalProperties":true,"type":"object","title":"Payload","description":"Произвольные сырые данные события для аналитики. AI читает только `summary_for_ai`."}},"type":"object","required":["type","summary_for_ai"],"title":"CustomerEventIn"},"CustomerEventOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"type":{"type":"string","title":"Type"},"summary_for_ai":{"type":"string","title":"Summary For Ai"},"occurred_at":{"type":"string","format":"date-time","title":"Occurred At"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"payload":{"additionalProperties":true,"type":"object","title":"Payload"}},"type":"object","required":["id","type","summary_for_ai","occurred_at","created_at","payload"],"title":"CustomerEventOut"},"CustomerOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"external_id":{"type":"string","title":"External Id"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"attributes":{"additionalProperties":true,"type":"object","title":"Attributes"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"},"updated_at":{"type":"string","format":"date-time","title":"Updated At"}},"type":"object","required":["id","external_id","email","phone","attributes","expires_at","updated_at"],"title":"CustomerOut"},"CustomerUpsertIn":{"properties":{"external_id":{"type":"string","maxLength":255,"minLength":1,"title":"External Id","description":"ID клиента в вашей CRM. Используется как стабильный ключ для связи виджет-сессии с записью клиента."},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email","description":"Email клиента. Опционально, но крайне желательно — мы используем его как fallback-идентификатор когда виджет открывает анонимный посетитель и в браузере есть только email."},"phone":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Phone","description":"Телефон клиента в любом формате. Пробелы и дефисы сохраняются как есть."},"attributes":{"additionalProperties":true,"type":"object","title":"Attributes","description":"Произвольный JSON с атрибутами клиента (план, имя, статус подписки, и т.д.). AI получит важные атрибуты в системном промпте."},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At","description":"После этой даты контекст считается устаревшим и AI его не использует. По умолчанию — 30 дней с момента upsert."}},"type":"object","required":["external_id"],"title":"CustomerUpsertIn"},"DailyPoint":{"properties":{"date":{"type":"string","title":"Date"},"total":{"type":"integer","title":"Total"},"escalated":{"type":"integer","title":"Escalated"}},"type":"object","required":["date","total","escalated"],"title":"DailyPoint"},"DeleteRequestIn":{"properties":{"confirm_slug":{"type":"string","title":"Confirm Slug","description":"Echo back the tenant slug to confirm"}},"type":"object","required":["confirm_slug"],"title":"DeleteRequestIn"},"FaqPair":{"properties":{"question":{"type":"string","maxLength":2000,"minLength":1,"title":"Question"},"answer":{"type":"string","maxLength":10000,"minLength":1,"title":"Answer"}},"type":"object","required":["question","answer"],"title":"FaqPair"},"FaqUpsertIn":{"properties":{"site_id":{"type":"string","format":"uuid","title":"Site Id"},"title":{"type":"string","maxLength":512,"title":"Title","default":"FAQ"},"pairs":{"items":{"$ref":"#/components/schemas/FaqPair"},"type":"array","maxItems":500,"minItems":1,"title":"Pairs"}},"type":"object","required":["site_id","pairs"],"title":"FaqUpsertIn"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"InvoiceOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"amount_kopecks":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Amount Kopecks"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"},"paid_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paid At"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","amount_kopecks","status","paid_at","created_at"],"title":"InvoiceOut"},"KbChunkOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"chunk_index":{"type":"integer","title":"Chunk Index"},"content":{"type":"string","title":"Content"},"token_count":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Token Count"}},"type":"object","required":["id","chunk_index","content","token_count"],"title":"KbChunkOut"},"KbGapOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"site_id":{"type":"string","format":"uuid","title":"Site Id"},"question":{"type":"string","title":"Question"},"hits":{"type":"integer","title":"Hits"},"last_seen_at":{"type":"string","format":"date-time","title":"Last Seen At"},"status":{"type":"string","enum":["open","resolved","dismissed"],"title":"Status"},"examples":{"items":{"type":"string"},"type":"array","title":"Examples"},"resolved_source_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Resolved Source Id"}},"type":"object","required":["id","site_id","question","hits","last_seen_at","status"],"title":"KbGapOut"},"KbGapUpdateIn":{"properties":{"status":{"type":"string","enum":["open","resolved","dismissed"],"title":"Status"},"resolved_source_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Resolved Source Id"}},"type":"object","required":["status"],"title":"KbGapUpdateIn"},"KbSourceOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"site_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Site Id"},"type":{"type":"string","enum":["faq","file","url"],"title":"Type"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title"},"source_uri":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Uri"},"status":{"type":"string","enum":["pending","processing","ready","error","quota_exceeded"],"title":"Status"},"chunk_count":{"type":"integer","title":"Chunk Count","default":0}},"type":"object","required":["id","type","title","source_uri","status"],"title":"KbSourceOut"},"LoginIn":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"password":{"type":"string","title":"Password"}},"type":"object","required":["email","password"],"title":"LoginIn"},"LogoutIn":{"properties":{"refresh_token":{"type":"string","title":"Refresh Token"}},"type":"object","required":["refresh_token"],"title":"LogoutIn"},"OperatorInviteIn":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"password":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Password"}},"type":"object","required":["email"],"title":"OperatorInviteIn"},"OperatorMessageIn":{"properties":{"content":{"type":"string","maxLength":4000,"minLength":1,"title":"Content"}},"type":"object","required":["content"],"title":"OperatorMessageIn"},"OperatorMessageOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"content":{"type":"string","title":"Content"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"operator_user_id":{"type":"string","format":"uuid","title":"Operator User Id"},"operator_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Operator Name"}},"type":"object","required":["id","content","created_at","operator_user_id"],"title":"OperatorMessageOut"},"OperatorOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"email":{"type":"string","title":"Email"},"role":{"type":"string","title":"Role"},"telegram_username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Telegram Username"},"is_linked":{"type":"boolean","title":"Is Linked"}},"type":"object","required":["id","full_name","email","role","telegram_username","is_linked"],"title":"OperatorOut"},"PasswordChangeIn":{"properties":{"current_password":{"type":"string","maxLength":128,"minLength":1,"title":"Current Password"},"new_password":{"type":"string","maxLength":128,"minLength":8,"title":"New Password"}},"type":"object","required":["current_password","new_password"],"title":"PasswordChangeIn"},"PasswordResetConfirmIn":{"properties":{"token":{"type":"string","title":"Token"},"new_password":{"type":"string","maxLength":128,"minLength":8,"title":"New Password"}},"type":"object","required":["token","new_password"],"title":"PasswordResetConfirmIn"},"PasswordResetIn":{"properties":{"email":{"type":"string","format":"email","title":"Email"}},"type":"object","required":["email"],"title":"PasswordResetIn"},"PendingChangeOut":{"properties":{"plan":{"type":"string","title":"Plan"},"effective_at":{"type":"string","format":"date-time","title":"Effective At"}},"type":"object","required":["plan","effective_at"],"title":"PendingChangeOut"},"PlanOut":{"properties":{"code":{"type":"string","title":"Code"},"name":{"type":"string","title":"Name"},"monthly_kopecks":{"type":"integer","title":"Monthly Kopecks"},"conversations_per_month":{"type":"integer","title":"Conversations Per Month"},"sites_max":{"type":"integer","title":"Sites Max"},"operators_max":{"type":"integer","title":"Operators Max"},"kb_chunks_max":{"type":"integer","title":"Kb Chunks Max"},"llm_tier":{"type":"string","title":"Llm Tier"},"is_trial":{"type":"boolean","title":"Is Trial"},"trial_days":{"type":"integer","title":"Trial Days"}},"type":"object","required":["code","name","monthly_kopecks","conversations_per_month","sites_max","operators_max","kb_chunks_max","llm_tier","is_trial","trial_days"],"title":"PlanOut"},"RefreshIn":{"properties":{"refresh_token":{"type":"string","title":"Refresh Token"}},"type":"object","required":["refresh_token"],"title":"RefreshIn"},"ResendVerificationIn":{"properties":{"email":{"type":"string","format":"email","title":"Email"}},"type":"object","required":["email"],"title":"ResendVerificationIn"},"SandboxInitIn":{"properties":{"site_id":{"type":"string","format":"uuid","title":"Site Id"}},"type":"object","required":["site_id"],"title":"SandboxInitIn"},"SandboxInitOut":{"properties":{"ws_token":{"type":"string","title":"Ws Token"},"conversation_id":{"type":"string","title":"Conversation Id"},"config":{"additionalProperties":true,"type":"object","title":"Config"},"quota":{"$ref":"#/components/schemas/SandboxQuotaView"}},"type":"object","required":["ws_token","conversation_id","config","quota"],"title":"SandboxInitOut"},"SandboxQuotaView":{"properties":{"used_today":{"type":"integer","title":"Used Today"},"limit":{"type":"integer","title":"Limit"},"resets_at":{"type":"string","title":"Resets At"}},"type":"object","required":["used_today","limit","resets_at"],"title":"SandboxQuotaView"},"SignupIn":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"password":{"type":"string","maxLength":128,"minLength":8,"title":"Password"},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"tenant_name":{"type":"string","maxLength":255,"minLength":2,"title":"Tenant Name"},"tenant_slug":{"type":"string","maxLength":64,"minLength":2,"pattern":"^[a-z0-9][a-z0-9-]*$","title":"Tenant Slug"}},"type":"object","required":["email","password","tenant_name","tenant_slug"],"title":"SignupIn"},"SignupOut":{"properties":{"user_id":{"type":"string","title":"User Id"},"message":{"type":"string","title":"Message","default":"Проверьте почту и подтвердите email"}},"type":"object","required":["user_id"],"title":"SignupOut"},"SiteCreateIn":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name"},"domain":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Domain"}},"type":"object","required":["name"],"title":"SiteCreateIn"},"SiteOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"type":"string","title":"Name"},"domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Domain"},"public_key":{"type":"string","title":"Public Key"},"is_active":{"type":"boolean","title":"Is Active"},"verified":{"type":"boolean","title":"Verified","default":false},"verified_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Verified At"},"last_probe_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Probe At"},"last_probe_status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Probe Status"},"kb_chunk_count":{"type":"integer","title":"Kb Chunk Count","default":0},"conversation_count":{"type":"integer","title":"Conversation Count","default":0},"theme":{"additionalProperties":true,"type":"object","title":"Theme"},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At"}},"type":"object","required":["id","name","public_key","is_active"],"title":"SiteOut"},"SiteUpdateIn":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":255,"minLength":1},{"type":"null"}],"title":"Name"},"domain":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Domain"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"},"theme":{"anyOf":[{"$ref":"#/components/schemas/WidgetThemeIn"},{"type":"null"}]}},"type":"object","title":"SiteUpdateIn"},"SubscriptionOut":{"properties":{"plan":{"type":"string","title":"Plan"},"status":{"type":"string","title":"Status"},"current_period_end":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Current Period End"},"monthly_amount_kopecks":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Monthly Amount Kopecks"},"auto_renew":{"type":"boolean","title":"Auto Renew"},"canceled_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Canceled At"},"pending_change":{"anyOf":[{"$ref":"#/components/schemas/PendingChangeOut"},{"type":"null"}]}},"type":"object","required":["plan","status","current_period_end","monthly_amount_kopecks","auto_renew"],"title":"SubscriptionOut"},"TelegramLinkOut":{"properties":{"deep_link":{"type":"string","title":"Deep Link"},"token":{"type":"string","title":"Token"},"expires_at":{"type":"string","format":"date-time","title":"Expires At"}},"type":"object","required":["deep_link","token","expires_at"],"title":"TelegramLinkOut"},"TenantOut":{"properties":{"id":{"type":"string","title":"Id"},"slug":{"type":"string","title":"Slug"},"name":{"type":"string","title":"Name"},"plan":{"type":"string","title":"Plan"},"llm_tier":{"type":"string","title":"Llm Tier"},"widget_config":{"additionalProperties":true,"type":"object","title":"Widget Config"},"allowed_origins":{"items":{"type":"string"},"type":"array","title":"Allowed Origins"},"telegram_bot_username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Telegram Bot Username"},"telegram_supergroup_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Telegram Supergroup Id"},"telegram_bot_configured":{"type":"boolean","title":"Telegram Bot Configured","default":false},"site_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Site Id"}},"type":"object","required":["id","slug","name","plan","llm_tier","widget_config","allowed_origins"],"title":"TenantOut"},"TenantPatch":{"properties":{"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"widget_config":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Widget Config"},"allowed_origins":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Allowed Origins"},"llm_tier":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Llm Tier"},"telegram_bot_token":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Telegram Bot Token"},"telegram_bot_username":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Telegram Bot Username"},"telegram_supergroup_id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Telegram Supergroup Id"}},"type":"object","title":"TenantPatch"},"TokenPair":{"properties":{"access_token":{"type":"string","title":"Access Token"},"refresh_token":{"type":"string","title":"Refresh Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"},"expires_in":{"type":"integer","title":"Expires In"}},"type":"object","required":["access_token","refresh_token","expires_in"],"title":"TokenPair"},"UsageBlock":{"properties":{"used":{"type":"integer","title":"Used"},"limit":{"type":"integer","title":"Limit"}},"type":"object","required":["used","limit"],"title":"UsageBlock"},"UsageOut":{"properties":{"plan_code":{"type":"string","title":"Plan Code"},"plan_name":{"type":"string","title":"Plan Name"},"plan_is_trial":{"type":"boolean","title":"Plan Is Trial"},"plan_monthly_kopecks":{"type":"integer","title":"Plan Monthly Kopecks"},"trial_ends_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Trial Ends At"},"status":{"type":"string","title":"Status"},"conversations_month":{"$ref":"#/components/schemas/UsageBlock"},"sites":{"$ref":"#/components/schemas/UsageBlock"},"operators":{"$ref":"#/components/schemas/UsageBlock"},"kb_chunks":{"$ref":"#/components/schemas/UsageBlock"}},"type":"object","required":["plan_code","plan_name","plan_is_trial","plan_monthly_kopecks","trial_ends_at","status","conversations_month","sites","operators","kb_chunks"],"title":"UsageOut"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"VerifyEmailIn":{"properties":{"token":{"type":"string","title":"Token"}},"type":"object","required":["token"],"title":"VerifyEmailIn"},"WidgetCsatIn":{"properties":{"score":{"type":"integer","title":"Score"},"comment":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Comment"}},"type":"object","required":["score"],"title":"WidgetCsatIn"},"WidgetIdentifyIn":{"properties":{"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"subject":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subject"},"anonymous":{"type":"boolean","title":"Anonymous","default":false}},"type":"object","title":"WidgetIdentifyIn"},"WidgetInitIn":{"properties":{"site_id":{"type":"string","title":"Site Id"},"origin":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Origin"},"visitor_token":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Visitor Token"},"customer_external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer External Id"},"customer_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Email"},"customer_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Customer Phone"}},"type":"object","required":["site_id"],"title":"WidgetInitIn"},"WidgetInitOut":{"properties":{"widget_session":{"type":"string","title":"Widget Session"},"conversation_id":{"type":"string","title":"Conversation Id"},"config":{"additionalProperties":true,"type":"object","title":"Config"}},"type":"object","required":["widget_session","conversation_id","config"],"title":"WidgetInitOut"},"WidgetMessageIn":{"properties":{"content":{"type":"string","title":"Content"}},"type":"object","required":["content"],"title":"WidgetMessageIn"},"WidgetMessageOut":{"properties":{"message_id":{"type":"string","title":"Message Id"},"content":{"type":"string","title":"Content"},"citations":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Citations"},"latency_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Latency Ms"}},"type":"object","required":["message_id","content"],"title":"WidgetMessageOut"},"WidgetThemeIn":{"properties":{"primary_color":{"anyOf":[{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"},{"type":"null"}],"title":"Primary Color"},"bot_bubble_bg":{"anyOf":[{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"},{"type":"null"}],"title":"Bot Bubble Bg"},"bot_bubble_text":{"anyOf":[{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"},{"type":"null"}],"title":"Bot Bubble Text"},"chat_bg_color":{"anyOf":[{"type":"string","pattern":"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"},{"type":"null"}],"title":"Chat Bg Color"},"welcome_message":{"anyOf":[{"type":"string","maxLength":300},{"type":"null"}],"title":"Welcome Message"},"bot_name":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Bot Name"}},"type":"object","title":"WidgetThemeIn","description":"Per-site appearance overrides. All fields optional — sparse storage."},"YandexAuthorizeOut":{"properties":{"authorize_url":{"type":"string","title":"Authorize Url"}},"type":"object","required":["authorize_url"],"title":"YandexAuthorizeOut"},"YandexExchangeIn":{"properties":{"code":{"type":"string","title":"Code"}},"type":"object","required":["code"],"title":"YandexExchangeIn"},"src__app__schemas__auth__MessageOut":{"properties":{"message":{"type":"string","title":"Message"}},"type":"object","required":["message"],"title":"MessageOut"},"src__app__schemas__conversation__MessageOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"role":{"type":"string","enum":["visitor","assistant","operator","system"],"title":"Role"},"content":{"type":"string","title":"Content"},"citations":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Citations"},"latency_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Latency Ms"},"llm_provider":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Llm Provider"},"created_at":{"type":"string","format":"date-time","title":"Created At"}},"type":"object","required":["id","role","content","created_at"],"title":"MessageOut"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}},"tags":[]}