{"openapi":"3.1.0","info":{"title":"Porter API","description":"\nPorter là AI Agent trực 24/7 cho ban quản lý chung cư. Cư dân nhắn tin qua Zalo, Messenger, Telegram như nhắn cho\nlễ tân; Porter hiểu yêu cầu, tạo đơn sửa chữa, cấp mã cho khách, trả lời nội quy và báo sớm khi nhiều cư dân cùng\nbức xúc. Porter API mở các khả năng đó cho phần mềm khác dùng.\n\n## Ai dùng API này\n\n| Bạn là | Bạn muốn | Đọc phần |\n|---|---|---|\n| Đơn vị làm **app / web của tòa nhà** | Cư dân chat với Porter ngay trong app của bạn | **App của tòa nhà** · nhóm *Partner API* |\n| Đơn vị làm **phần mềm quản lý tòa nhà** | Đồng bộ căn hộ, nhận đơn sửa chữa và lượt khách | **Phần mềm quản lý tòa nhà** · nhóm *Tích hợp hệ thống tòa nhà* |\n| Đơn vị lắp **barrier / đầu đọc QR** | Cổng tự mở khi khách đưa mã hợp lệ | **Đầu đọc QR ở cổng** · nhóm *Kiểm soát ra vào* |\n| Đội phát triển **web điều hành** | Màn hình cho ban quản lý, kỹ thuật viên, bảo vệ | **Xác thực** · các nhóm *Vận hành*, *Lễ tân*, *Cư dân* |\n\n## Bắt đầu\n\n1. **Lấy thông tin xác thực** — theo đúng loại bên gọi ở mục **Xác thực**.\n2. **Gọi thử request đầu tiên** — ngay trên trang này: chọn một endpoint, điền thông tin xác thực, bấm **Test Request**.\n3. **Làm theo hướng dẫn tích hợp** — chọn mục phù hợp ở **Hướng dẫn tích hợp**.\n\nRequest đầu tiên — đăng nhập rồi lấy dữ liệu bảng điều hành:\n\n```bash\ncurl -X POST https://<địa-chỉ-porter>/api/v1/auth/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"username\": \"<tên đăng nhập>\", \"password\": \"<mật khẩu>\"}'\n\ncurl https://<địa-chỉ-porter>/api/v1/dashboard/initial-state \\\n  -H \"Authorization: Bearer <access_token>\"\n```\n\n## Xác thực\n\nMỗi loại bên gọi dùng một cách xác thực. Khóa tích hợp chỉ dùng từ **máy chủ** của bạn — không nhúng vào trình\nduyệt hay app di động.\n\n**Nhân viên (ban quản lý, kỹ thuật viên, bảo vệ)** — header `Authorization: Bearer <token>`\n\n1. Gọi `POST /api/v1/auth/login` với tên đăng nhập và mật khẩu.\n2. Lấy `access_token` trong kết quả. Token hết hạn sau 12 giờ; hết hạn thì đăng nhập lại.\n3. Gửi kèm mọi request. Quyền theo vai `role`: `MANAGER` dùng mọi chức năng quản trị, `TECHNICIAN` chỉ thấy việc\n   được giao, `GUARD` chỉ dùng kiểm soát ra vào.\n\n**App / web đối tác** — header `X-Partner-Key: pk_…`\n\n1. Ban quản lý vào **Kênh kết nối → Đối tác tích hợp**, tạo đối tác (hoặc `POST /api/v1/partners`).\n2. Lưu `api_key` và `webhook_secret` ngay — **chỉ hiện một lần**.\n3. Lộ khóa thì cấp lại bằng `POST /api/v1/partners/{partner_id}/rotate-key`; khóa cũ hết hiệu lực ngay.\n\n**Phần mềm quản lý tòa nhà** — header `X-Integration-Token: <token>`\nĐội vận hành Porter cấp token khi khởi tạo tòa nhà.\n\n**Đầu đọc QR ở cổng** — header `X-Access-Device-Key: <key>`\nĐội vận hành Porter cấp khóa khi lắp thiết bị.\n\n## Hướng dẫn tích hợp\n\n### App của tòa nhà\n\nĐưa Porter vào app sẵn có: người dùng chat trong app, Porter trả lời như trên Zalo.\n\n1. **Gửi tin của người dùng** — `POST /api/v1/partner/messages` với `message_id` duy nhất, `user_id` phía bạn và\n   `text` (hoặc `image_urls`). Nếu app đã xác minh số điện thoại, gửi kèm `resident_phone` để Porter nhận ra cư dân\n   ngay, không cần ban quản lý duyệt (đối tác phải được đánh dấu tin cậy).\n2. **Nhận câu trả lời**, chọn một trong hai:\n   - **Webhook** — Porter `POST` tới `webhook_url` của bạn (xem *Webhooks → Tin trả lời cho đối tác*).\n   - **Polling** — `GET /api/v1/partner/messages?user_id=…&after=<seq>`; lưu `next_after` để lần sau chỉ lấy tin mới.\n3. **Nút bấm** — tin có `buttons` (vd *Đồng ý* / *Hủy* báo giá): khi người dùng chọn, gửi lại một tin có `text` là\n   số thứ tự nút (`\"1\"`, `\"2\"`).\n\n### Phần mềm quản lý tòa nhà\n\n1. **Đồng bộ căn hộ** — `POST /api/v1/integrations/apartments`, mỗi phần tử một dòng\n   (`apartment_code`, `block`, `floor`, `unit`, `resident_name`, `phone`), tối đa 5.000 dòng / lần. Gửi lại được\n   nhiều lần: cư dân khớp theo số điện thoại nên không bị nhân bản.\n2. **Nhận đơn sửa chữa** — qua webhook `ticket.created` / `ticket.updated`, hoặc kéo bằng\n   `GET /api/v1/integrations/tickets?updated_since=<next_since lần trước>`.\n3. **Kiểm soát ra vào (nếu có)** — nhận webhook `guest_pass.created` / `cancelled` để tự cấp quyền; khi khách qua cổng\n   của bạn, báo lại bằng `POST /api/v1/integrations/access-events` để Porter nhắn cư dân.\n\n### Đầu đọc QR ở cổng\n\n1. Khi quét được mã, gọi `POST /api/v1/access/device-verify` với nội dung QR (`qr`), tên cổng (`gate`) và biển số nếu\n   camera đọc được (`plate`).\n2. Mở cổng khi `allow` là `true` — chỉ xảy ra với `result` là `VALID`. Không có thông tin cá nhân nào được trả về\n   thiết bị.\n\n| `result` | Ý nghĩa |\n|---|---|\n| `VALID` | Hợp lệ, cho qua |\n| `NOT_YET` | Chưa tới giờ — mã có hiệu lực từ 30 phút trước giờ hẹn |\n| `EXPIRED` | Đã hết hạn |\n| `CANCELLED` | Cư dân đã hủy |\n| `PLATE_MISMATCH` | Sai biển số xe |\n| `UNKNOWN` | Không có mã này |\n\n## Quy ước\n\n- **Định dạng**: JSON UTF-8, cả request lẫn response.\n- **Thời gian**: ISO 8601, múi giờ UTC — ví dụ `2026-11-22T12:30:00Z`.\n- **Mã định danh**: đơn sửa chữa `TK-215`, căn hộ `A1205` (tòa, 2 số tầng, 2 số căn), mã khách 6 ký tự `K7M2QX`.\n- **Lấy dữ liệu mới**: danh sách dài dùng con trỏ tăng dần (`after`, `since`, `updated_since`) thay cho số trang;\n  lưu giá trị trả về (`next_after`, `next_since`) để lần sau chỉ lấy phần mới.\n- **Chống gửi trùng**: tin nhắn mang `message_id` duy nhất; gửi lại cùng mã thì Porter bỏ qua và trả `duplicate: true`.\n  Webhook mang `X-Porter-Event-Id` để bên nhận tự chống xử lý trùng.\n- **Dữ liệu riêng tư**: số điện thoại cư dân trả về đã che (`091****678`).\n\n## Mã lỗi\n\nLỗi có mã HTTP chuẩn, kèm `code` ổn định (dùng để rẽ nhánh trong code) và `message` tiếng Việt (hiển thị được cho\nngười dùng):\n\n```json\n{ \"detail\": { \"code\": \"TICKET_INVALID_STATE\", \"message\": \"Đơn TK-215 đang ở SCHEDULED, không phải WAIT_BQL_HITL\" } }\n```\n\nLỗi dữ liệu do FastAPI kiểm tra (sai kiểu, thiếu trường) cũng trả `422`, nhưng `detail` là danh sách lỗi theo trường.\n\n**`400` · Yêu cầu sai nghiệp vụ**\n\n- `ALERT_NOT_ACTIVE` — Cảnh báo không còn ở trạng thái xử lý được\n- `INVALID_FILE_TYPE`, `INVALID_PDF_SIGNATURE`, `PDF_TOO_LARGE`, `EMPTY_CONTENT`, `INGEST_ERROR` — Tài liệu nội quy tải lên không hợp lệ\n- `INVALID_STATUS_FOR_APPROVAL`, `PARSE_BLOCKED`, `DRAFT_LABEL_NOT_ACKNOWLEDGED`, `VERSION_NOT_READY`, `CANNOT_ROLLBACK_TO_UNREADY`, `ALREADY_ACTIVE`, `INVALID_EFFECTIVE_TIME` — Phiên bản tài liệu chưa ở trạng thái cho phép duyệt / xuất bản / quay lui, hoặc thời điểm hiệu lực đã qua\n\n**`401` · Xác thực**\n\n- `UNAUTHENTICATED`, `INVALID_TOKEN` — Chưa đăng nhập, hoặc token sai / hết hạn\n- `INVALID_CREDENTIALS` — Sai tên đăng nhập hoặc mật khẩu\n- `PARTNER_KEY_REQUIRED`, `INVALID_PARTNER_KEY` — Thiếu, sai hoặc đã thu hồi `X-Partner-Key`\n- `INVALID_INTEGRATION_TOKEN` — Thiếu hoặc sai `X-Integration-Token`\n- `INVALID_DEVICE_KEY` — Thiếu hoặc sai `X-Access-Device-Key`\n\n**`403` · Không có quyền**\n\n- `FORBIDDEN` — Vai của tài khoản không có quyền\n- `NOT_YOUR_TICKET` — Kỹ thuật viên thao tác trên việc không được giao\n\n**`404` · Không tìm thấy**\n\n- `TICKET_NOT_FOUND`, `RESIDENT_NOT_FOUND`, `TECH_NOT_FOUND`, `BUILDING_NOT_FOUND`, `PASS_NOT_FOUND`, `BOOKING_NOT_FOUND`, `SCHEDULE_NOT_FOUND`, `CONVERSATION_NOT_FOUND`, `PARTNER_NOT_FOUND`, `ALERT_NOT_FOUND`, `LOG_NOT_FOUND`, `DOCUMENT_NOT_FOUND`, `VERSION_NOT_FOUND`, `ARTIFACT_NOT_FOUND`, `DEVICE_NOT_FOUND`, `LINK_REQUEST_NOT_FOUND` — Không có đối tượng này\n- `DEMO_MODE_OFF` — Công cụ giả lập đang tắt\n\n**`409` · Xung đột trạng thái**\n\n- `TICKET_INVALID_STATE` — Đơn không ở trạng thái cho phép thao tác này\n- `RESIDENT_COST_CHANGED` — Chi phí đã đổi, cần cư dân xác nhận lại\n- `RESIDENT_SCHEDULE_PENDING`, `RESIDENT_SCHEDULE_UNAVAILABLE` — Chưa có lịch cư dân, hoặc giờ hẹn ngoài khoảng cư dân chọn\n- `TECH_BUSY`, `TECH_HAS_JOBS` — Thợ đã có việc gần giờ này / còn việc chưa xong\n- `USERNAME_TAKEN`, `PHONE_TAKEN`, `PARTNER_EXISTS` — Đã tồn tại\n- `LINK_REQUEST_DECIDED` — Yêu cầu xác minh đã được xử lý\n- `FACEBOOK_TAKEN` — Link Facebook đã thuộc cư dân khác\n- `BUILDING_IN_USE` — Tòa nhà còn căn hộ, không xóa được\n- `NOT_CONNECTED`, `APP_NOT_CONFIGURED`, `DEPLAO_DISABLED` — Kênh nhắn tin chưa kết nối / chưa cấu hình\n\n**`422` · Dữ liệu không hợp lệ**\n\n- `TECH_INACTIVE`, `TECH_SKILL_MISMATCH`, `NO_TECHNICIAN` — Thợ ngừng hoạt động, sai chuyên môn, hoặc chưa chọn thợ\n- `ETA_IN_PAST`, `NOTHING_TO_CHANGE`, `NOTE_REQUIRED` — Giờ hẹn đã qua, không có gì thay đổi, thiếu lý do\n- `INVALID_APARTMENT`, `INVALID_PHONE`, `INVALID_BLOCK`, `INVALID_USERNAME`, `PASSWORD_TOO_SHORT`, `INVALID_SKILLS`, `BAD_ORIGIN`, `INVALID_FACEBOOK` — Dữ liệu sai định dạng\n- `INVALID_HOURS`, `INVALID_WINDOW`, `BAD_TIME_RANGE`, `BAD_RANGE` — Khoảng thời gian không hợp lệ\n- `EMPTY_MESSAGE`, `ID_MISMATCH`, `NOT_A_GROUP_CHANNEL`, `APP_SECRET_REQUIRED` — Yêu cầu thiếu hoặc mâu thuẫn\n\n**`429` · Quá giới hạn**\n\n- `ACCOUNT_LOCKED` — Đăng nhập sai quá 5 lần, khóa 15 phút\n\n**`500` · Lỗi phía Porter**\n\n- `INTERNAL_INGEST_ERROR` — Lỗi khi xử lý tài liệu — thử lại sau\n\n## Giới hạn\n\n| Giới hạn | Giá trị |\n|---|---|\n| Đăng nhập sai liên tiếp | 5 lần → khóa 15 phút |\n| Độ dài một tin nhắn | 5.000 ký tự |\n| Ảnh trong một tin (Partner API) | 5 ảnh, URL công khai |\n| Đồng bộ căn hộ một lần | 5.000 dòng |\n| Polling tin trả lời một lần | 200 tin |\n| Kéo ticket một lần | 500 đơn |\n\nKhi polling, giãn mỗi lần gọi vài giây; cần nhận ngay thì dùng webhook.\n\n## Webhook\n\nPorter chủ động báo sự kiện tới máy chủ của bạn bằng `POST` JSON — chi tiết từng sự kiện ở mục **Webhooks**.\n\n| Header | Ý nghĩa |\n|---|---|\n| `X-Porter-Event` | Loại sự kiện, ví dụ `ticket.updated` |\n| `X-Porter-Event-Id` | Mã sự kiện, dùng để chống xử lý trùng |\n| `X-Porter-Timestamp` | Thời điểm ký, Unix giây |\n| `X-Porter-Signature` | `sha256=` + HMAC-SHA256(secret, `<timestamp>.<body>`) |\n\n**Kiểm chữ ký** trước khi tin dữ liệu, và từ chối request có timestamp quá cũ (ví dụ > 5 phút):\n\n```python\nimport hashlib, hmac\n\ndef verify(secret: str, timestamp: str, body: bytes, signature: str) -> bool:\n    expected = \"sha256=\" + hmac.new(secret.encode(), timestamp.encode() + b\".\" + body, hashlib.sha256).hexdigest()\n    return hmac.compare_digest(expected, signature)\n```\n\n```javascript\nimport crypto from \"node:crypto\";\n\nfunction verify(secret, timestamp, rawBody, signature) {\n  const expected = \"sha256=\" + crypto.createHmac(\"sha256\", secret).update(`${timestamp}.${rawBody}`).digest(\"hex\");\n  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));\n}\n```\n\nTrả mã `2xx` trong 10 giây là xong. Lỗi hoặc quá thời gian thì Porter gửi lại, giãn dần, tối đa 8 lần; sau đó sự kiện\nđược đánh dấu hỏng và ban quản lý được báo. Webhook lỗi vẫn kéo được dữ liệu bằng API polling.\n\n## Phiên bản\n\nPhiên bản nằm trong đường dẫn: `/api/v1`. Trong cùng phiên bản, Porter chỉ **thêm** (endpoint, trường, giá trị mới)\nvà không xóa hay đổi nghĩa trường cũ — code của bạn nên bỏ qua trường không biết. Thay đổi phá vỡ tương thích sẽ ra\n`/api/v2` và được báo trước trong **Nhật ký thay đổi**.\n\n## Nhật ký thay đổi\n\n**22/11/2026 — v1.0.0**\n\n- Công bố tài liệu API: hướng dẫn tích hợp, bảng mã lỗi, webhook có ký HMAC.\n- Xác thực cho 4 loại bên gọi: nhân viên, đối tác, phần mềm quản lý tòa nhà, đầu đọc QR.\n- Partner API, đồng bộ căn hộ, kéo ticket, kiểm soát ra vào qua thiết bị.\n\n## Điều khoản sử dụng\n\n- **Dữ liệu cư dân** (họ tên, số điện thoại, căn hộ, nội dung tin nhắn) là dữ liệu cá nhân. Chỉ dùng cho vận hành\n  tòa nhà mà ban quản lý đã đồng ý; không bán, không chia sẻ cho bên thứ ba, không lưu lâu hơn mức cần thiết.\n- **Giữ bí mật khóa** (`X-Partner-Key`, `X-Integration-Token`, `X-Access-Device-Key`, webhook secret). Nghi bị lộ thì báo\n  ngay để thu hồi.\n- **Tôn trọng giới hạn** ở mục **Giới hạn**. Porter có thể tạm khóa khóa tích hợp gây quá tải hoặc\n  vi phạm điều khoản.\n- **Không dùng để gửi tin quảng cáo** hay tin hàng loạt tới cư dân qua Porter.\n- Dùng cho mục đích thương mại ngoài phạm vi tòa nhà (tích hợp cho nhiều tòa, bán lại) cần thỏa thuận riêng với\n  đội Porter.\n\n## Hỗ trợ\n\nCần cấp khóa, báo lỗi hoặc hỏi về tích hợp: liên hệ **ban quản lý tòa nhà** hoặc **đội vận hành Porter**. Khi báo lỗi,\ngửi kèm thời điểm gọi (UTC), endpoint, mã HTTP và `code` trong phản hồi — **không** gửi kèm khóa bí mật.\n","version":"1.0.0"},"paths":{"/api/v1/auth/login":{"post":{"summary":"Đăng nhập","operationId":"login_api_v1_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"},"example":{"username":"<tên đăng nhập>","password":"<mật khẩu>"}}},"required":true},"responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Login Api V1 Auth Login Post"},"example":{"access_token":"<access_token>","token_type":"bearer","user":{"user_id":"u_1a2b3c","username":"quanly.toa-a","display_name":"Ban quản lý Tòa A","role":"MANAGER","technician_id":null}}}}},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Xác thực"],"description":"**Xác thực:** không cần.\n\n**Kết quả:** `access_token` dùng cho header `Authorization: Bearer`, hết hạn sau 12 giờ. `user.role`: `MANAGER`, `TECHNICIAN` hoặc `GUARD`.\n\n**Lỗi riêng:** `401 INVALID_CREDENTIALS` sai tên hoặc mật khẩu · `429 ACCOUNT_LOCKED` sai quá 5 lần, khóa 15 phút"}},"/api/v1/auth/me":{"get":{"summary":"Tài khoản hiện tại","operationId":"me_api_v1_auth_me_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Xác thực"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/config":{"get":{"summary":"Cấu hình công khai","description":"Frontend đọc để biết có bật công cụ demo không (không lộ bí mật).\n\n**Xác thực:** không cần.","operationId":"public_config_api_v1_config_get","responses":{"200":{"description":"Thành công"}},"tags":["Xác thực"]}},"/api/v1/dashboard/initial-state":{"get":{"summary":"Dữ liệu bảng điều hành","operationId":"initial_state_api_v1_dashboard_initial_state_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/buildings":{"get":{"summary":"Danh sách tòa nhà","operationId":"list_buildings_api_v1_buildings_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/buildings/{code}":{"put":{"summary":"Tạo hoặc sửa tòa nhà","operationId":"save_building_api_v1_buildings__code__put","parameters":[{"name":"code","in":"path","required":true,"schema":{"type":"string","title":"Code"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BuildingIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"delete":{"summary":"Xóa tòa nhà","operationId":"delete_building_api_v1_buildings__code__delete","parameters":[{"name":"code","in":"path","required":true,"schema":{"type":"string","title":"Code"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/imports/apartments/preview":{"post":{"summary":"Xem trước file căn hộ","operationId":"import_preview_api_v1_imports_apartments_preview_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApartmentItems"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/imports/apartments/suggest-mapping":{"post":{"summary":"Gợi ý ghép cột","description":"Gợi ý cách đọc file lạ: AI (nếu có khóa API, dữ liệu mẫu đã che) hoặc theo quy tắc.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"import_suggest_mapping_api_v1_imports_apartments_suggest_mapping_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MappingRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}]}},"/api/v1/imports/apartments":{"post":{"summary":"Nhập danh sách căn hộ","operationId":"import_commit_api_v1_imports_apartments_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApartmentItems"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/integrations/apartments":{"post":{"summary":"Đồng bộ căn hộ","description":"Phần mềm quản lý tòa nhà đẩy danh sách căn hộ + cư dân (đồng bộ định kỳ hoặc khi có thay đổi).\n\n**Xác thực:** `X-Integration-Token`.\n\n**Kết quả:** Mỗi phần tử một dòng: `apartment_code`, `block`, `floor`, `unit`, `resident_name`, `phone` (tên cột tiếng Việt như trong file Excel cũng được). Tối đa 5.000 dòng. Cư dân khớp theo số điện thoại nên gửi lại không bị nhân bản.\n\n**Lỗi riêng:** `401 INVALID_INTEGRATION_TOKEN`","operationId":"integration_apartments_api_v1_integrations_apartments_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApartmentItems"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}},"tags":["Tích hợp hệ thống tòa nhà"],"security":[{"IntegrationToken":[]}]}},"/api/v1/residents":{"post":{"summary":"Thêm cư dân","operationId":"create_resident_api_v1_residents_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResidentIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"get":{"summary":"Danh bạ cư dân","description":"Danh bạ cư dân theo căn cho BQL: kênh đã liên kết, đã xác minh chưa, số việc đang mở.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"list_residents_api_v1_residents_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}]}},"/api/v1/residents/{resident_id}":{"patch":{"summary":"Sửa cư dân","operationId":"update_resident_api_v1_residents__resident_id__patch","parameters":[{"name":"resident_id","in":"path","required":true,"schema":{"type":"string","title":"Resident Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResidentPatch"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"delete":{"summary":"Xóa cư dân","operationId":"delete_resident_api_v1_residents__resident_id__delete","parameters":[{"name":"resident_id","in":"path","required":true,"schema":{"type":"string","title":"Resident Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/technicians":{"get":{"summary":"Danh sách kỹ thuật viên","operationId":"list_technicians_api_v1_technicians_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kỹ thuật viên"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"post":{"summary":"Thêm kỹ thuật viên","operationId":"create_technician_api_v1_technicians_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TechnicianIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kỹ thuật viên"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/technicians/{technician_id}":{"patch":{"summary":"Sửa kỹ thuật viên","operationId":"update_technician_api_v1_technicians__technician_id__patch","parameters":[{"name":"technician_id","in":"path","required":true,"schema":{"type":"string","title":"Technician Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TechnicianPatch"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kỹ thuật viên"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/tickets/{ticket_code}/candidates":{"get":{"summary":"Gợi ý thợ cho đơn","operationId":"ticket_candidates_api_v1_tickets__ticket_code__candidates_get","parameters":[{"name":"ticket_code","in":"path","required":true,"schema":{"type":"string","title":"Ticket Code"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/tickets/{ticket_code}/reassign":{"post":{"summary":"Đổi thợ hoặc giờ hẹn","operationId":"reassign_ticket_api_v1_tickets__ticket_code__reassign_post","parameters":[{"name":"ticket_code","in":"path","required":true,"schema":{"type":"string","title":"Ticket Code"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReassignRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`).\n\n**Lỗi riêng:** `404 TICKET_NOT_FOUND` · `404 TECH_NOT_FOUND` · `409 TICKET_INVALID_STATE` · `409 TECH_BUSY` · `409 RESIDENT_SCHEDULE_UNAVAILABLE` · `422 ETA_IN_PAST` · `422 NOTHING_TO_CHANGE` · `422 TECH_INACTIVE` · `422 TECH_SKILL_MISMATCH`"}},"/api/v1/tickets/{ticket_code}/bql-approve":{"post":{"summary":"Duyệt đơn và giao thợ","operationId":"bql_approve_api_v1_tickets__ticket_code__bql_approve_post","parameters":[{"name":"ticket_code","in":"path","required":true,"schema":{"type":"string","title":"Ticket Code"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BqlApproveRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`).\n\n**Lỗi riêng:** `404 TICKET_NOT_FOUND` · `404 TECH_NOT_FOUND` · `409 TICKET_INVALID_STATE` đơn không chờ duyệt · `409 RESIDENT_COST_CHANGED` cần cư dân xác nhận lại giá · `409 RESIDENT_SCHEDULE_PENDING` · `409 RESIDENT_SCHEDULE_UNAVAILABLE` · `422 NO_TECHNICIAN` · `422 TECH_SKILL_MISMATCH` · `422 NOTE_REQUIRED` từ chối phải có lý do"}},"/api/v1/tickets/{ticket_code}/tech-progress":{"patch":{"summary":"Cập nhật tiến độ sửa","operationId":"tech_progress_api_v1_tickets__ticket_code__tech_progress_patch","parameters":[{"name":"ticket_code","in":"path","required":true,"schema":{"type":"string","title":"Ticket Code"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TechProgressRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/tech/notifications":{"get":{"summary":"Thông báo của tôi","operationId":"my_notifications_api_v1_tech_notifications_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kỹ thuật viên"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/tech/notifications/read":{"post":{"summary":"Đánh dấu đã đọc","operationId":"read_notifications_api_v1_tech_notifications_read_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarkReadRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kỹ thuật viên"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/integrations/tickets":{"get":{"summary":"Kéo ticket thay đổi","description":"Hệ thống quản lý tòa nhà kéo ticket thay đổi sau `updated_since` (ISO-8601). Dùng `updated_at` cuối làm mốc kế tiếp.\n\n**Xác thực:** `X-Integration-Token`.\n\n**Kết quả:** `tickets` thay đổi sau `updated_since`, cũ trước. Dùng `next_since` làm `updated_since` lần sau.\n\n**Lỗi riêng:** `401 INVALID_INTEGRATION_TOKEN`","operationId":"integration_tickets_api_v1_integrations_tickets_get","parameters":[{"name":"updated_since","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated Since"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":200,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}},"tags":["Tích hợp hệ thống tòa nhà"],"security":[{"IntegrationToken":[]}]}},"/api/v1/integrations/outbox":{"get":{"summary":"Sự kiện chờ gửi","operationId":"integration_outbox_api_v1_integrations_outbox_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Tích hợp hệ thống tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/integrations/outbox/{event_id}/retry":{"post":{"summary":"Gửi lại sự kiện","operationId":"integration_retry_api_v1_integrations_outbox__event_id__retry_post","parameters":[{"name":"event_id","in":"path","required":true,"schema":{"type":"string","title":"Event Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Tích hợp hệ thống tòa nhà"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/groups":{"get":{"summary":"Danh sách nhóm","operationId":"list_groups_api_v1_groups_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Nhóm Zalo"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/groups/{group_id}":{"patch":{"summary":"Sửa nhóm","operationId":"update_group_api_v1_groups__group_id__patch","parameters":[{"name":"group_id","in":"path","required":true,"schema":{"type":"string","title":"Group Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupPatch"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Nhóm Zalo"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/groups/{group_id}/members":{"get":{"summary":"Thành viên nhóm","operationId":"group_members_api_v1_groups__group_id__members_get","parameters":[{"name":"group_id","in":"path","required":true,"schema":{"type":"string","title":"Group Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Nhóm Zalo"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/group-members/{member_id}/confirm":{"post":{"summary":"Xác nhận ghép thành viên","operationId":"confirm_member_api_v1_group_members__member_id__confirm_post","parameters":[{"name":"member_id","in":"path","required":true,"schema":{"type":"integer","title":"Member Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberConfirm"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Nhóm Zalo"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/group-members/{member_id}/reject":{"post":{"summary":"Từ chối ghép thành viên","operationId":"reject_member_api_v1_group_members__member_id__reject_post","parameters":[{"name":"member_id","in":"path","required":true,"schema":{"type":"integer","title":"Member Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Nhóm Zalo"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/link-requests":{"get":{"summary":"Yêu cầu xác minh cư dân","description":"Người nhắn riêng chưa khớp danh sách cư dân, chờ BQL xác nhận là cư dân căn nào.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"list_link_requests_api_v1_link_requests_get","parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string","pattern":"^(PENDING|APPROVED|REJECTED|ALL)$","default":"PENDING","title":"Status"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}]}},"/api/v1/link-requests/{request_id}/approve":{"post":{"summary":"Xác nhận cư dân","description":"Gắn tài khoản chat với cư dân đã chọn; Porter nhắn báo cho người gửi.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"approve_link_request_api_v1_link_requests__request_id__approve_post","parameters":[{"name":"request_id","in":"path","required":true,"schema":{"type":"integer","title":"Request Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkApprove"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}]}},"/api/v1/link-requests/{request_id}/reject":{"post":{"summary":"Từ chối yêu cầu xác minh","description":"Không phải cư dân / không xác nhận được; Porter nhắn hướng dẫn liên hệ lễ tân.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"reject_link_request_api_v1_link_requests__request_id__reject_post","parameters":[{"name":"request_id","in":"path","required":true,"schema":{"type":"integer","title":"Request Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkReject"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Cư dân & tòa nhà"],"security":[{"BearerAuth":[]}]}},"/api/v1/sla/policies":{"get":{"summary":"Danh sách chỉ tiêu SLA","operationId":"sla_policies_api_v1_sla_policies_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/sla/policies/{priority_level}":{"patch":{"summary":"Sửa chỉ tiêu SLA","description":"Sửa chỉ tiêu của một mức ưu tiên. Áp cho đơn mới; đơn đang chạy giữ chỉ tiêu lúc bắt đầu.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"update_sla_policy_api_v1_sla_policies__priority_level__patch","parameters":[{"name":"priority_level","in":"path","required":true,"schema":{"type":"string","title":"Priority Level"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SlaPolicyPatch"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}]}},"/api/v1/sla/summary":{"get":{"summary":"Báo cáo SLA","operationId":"sla_summary_api_v1_sla_summary_get","parameters":[{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"default":30,"title":"Days"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/simulator/inject-sensor-event":{"post":{"summary":"Giả lập sự kiện cảm biến","operationId":"inject_sensor_event_api_v1_simulator_inject_sensor_event_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InjectSensorRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Demo"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/conversations":{"get":{"summary":"Danh sách hội thoại","operationId":"conversations_api_v1_conversations_get","parameters":[{"name":"channel","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Channel"}},{"name":"q","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Q"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Hội thoại"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/conversations/{conversation_id}/messages":{"get":{"summary":"Tin nhắn trong hội thoại","operationId":"conversation_messages_api_v1_conversations__conversation_id__messages_get","parameters":[{"name":"conversation_id","in":"path","required":true,"schema":{"type":"integer","title":"Conversation Id"}},{"name":"before","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Before"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":100,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Hội thoại"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/access/pass/{token}":{"get":{"summary":"Xem mã của khách","operationId":"public_pass_api_v1_access_pass__token__get","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","title":"Token"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Kiểm soát ra vào"],"description":"**Xác thực:** không cần."}},"/api/v1/access/pass/{token}/qr.svg":{"get":{"summary":"Ảnh QR của mã","operationId":"public_pass_qr_api_v1_access_pass__token__qr_svg_get","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","title":"Token"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Kiểm soát ra vào"],"description":"**Xác thực:** không cần."}},"/api/v1/access/verify":{"post":{"summary":"Bảo vệ kiểm tra mã","operationId":"verify_api_v1_access_verify_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kiểm soát ra vào"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/access/expected":{"get":{"summary":"Khách dự kiến hôm nay","operationId":"expected_api_v1_access_expected_get","parameters":[{"name":"q","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Q"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kiểm soát ra vào"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/access/device-verify":{"post":{"summary":"Đầu đọc QR kiểm tra mã","description":"Thiết bị chỉ nhận kết quả mở / không mở — không trả thông tin cá nhân.\n\n**Xác thực:** `X-Access-Device-Key`.\n\n**Kết quả:** Mở cổng khi `allow` là `true`. `result`: `VALID`, `NOT_YET`, `EXPIRED`, `CANCELLED`, `PLATE_MISMATCH`, `UNKNOWN`. Không trả thông tin cá nhân.\n\n**Lỗi riêng:** `401 INVALID_DEVICE_KEY`","operationId":"device_verify_api_v1_access_device_verify_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceVerifyIn"},"example":{"qr":"K7M2QX","gate":"Cổng B1","plate":"30A-123.45"}}}},"responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Device Verify Api V1 Access Device Verify Post"},"example":{"allow":true,"result":"VALID","valid_until":"2026-11-22T16:30:00Z"}}}},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}},"tags":["Kiểm soát ra vào"],"security":[{"AccessDeviceKey":[]}]}},"/api/v1/integrations/access-events":{"post":{"summary":"Báo lượt khách vào cổng","operationId":"access_event_api_v1_integrations_access_events_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessEventIn"},"example":{"code":"K7M2QX","gate":"Barrier hầm B1","plate":"30A-123.45"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}},"tags":["Tích hợp hệ thống tòa nhà"],"security":[{"IntegrationToken":[]}],"description":"**Xác thực:** `X-Integration-Token`.\n\n**Kết quả:** `result` và `allow` như `device-verify`. Khách vào lần đầu thì Porter nhắn riêng cho cư dân.\n\n**Lỗi riêng:** `401 INVALID_INTEGRATION_TOKEN`"}},"/api/v1/reception/passes":{"get":{"summary":"Danh sách mã","description":"Mã còn hiệu lực từ `date` (mặc định hôm nay) trong `days` ngày.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"list_passes_api_v1_reception_passes_get","parameters":[{"name":"date","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Date"}},{"name":"kind","in":"query","required":false,"schema":{"anyOf":[{"type":"string","pattern":"^(GUEST|FACILITY)$"},{"type":"null"}],"title":"Kind"}},{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":31,"minimum":1,"default":1,"title":"Days"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}]},"post":{"summary":"Tạo mã khách","description":"Lễ tân tạo mã giúp cư dân (gọi điện / đến quầy). Trả link để gửi cho khách.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"create_pass_api_v1_reception_passes_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PassIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}]}},"/api/v1/reception/passes/{pass_id}/cancel":{"post":{"summary":"Hủy mã","operationId":"cancel_pass_api_v1_reception_passes__pass_id__cancel_post","parameters":[{"name":"pass_id","in":"path","required":true,"schema":{"type":"string","title":"Pass Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/bookings":{"get":{"summary":"Lịch đặt tiện ích","operationId":"list_bookings_api_v1_reception_bookings_get","parameters":[{"name":"start","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Start"}},{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":62,"minimum":1,"default":7,"title":"Days"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/bookings/{booking_id}/cancel":{"post":{"summary":"Hủy lượt đặt","operationId":"cancel_booking_api_v1_reception_bookings__booking_id__cancel_post","parameters":[{"name":"booking_id","in":"path","required":true,"schema":{"type":"integer","title":"Booking Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/requests":{"get":{"summary":"Yêu cầu chờ duyệt","operationId":"list_requests_api_v1_reception_requests_get","parameters":[{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string","pattern":"^(OPEN|APPROVED|REJECTED)$"},{"type":"null"}],"default":"OPEN","title":"Status"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/requests/{request_id}/approve":{"post":{"summary":"Duyệt yêu cầu","operationId":"approve_request_api_v1_reception_requests__request_id__approve_post","parameters":[{"name":"request_id","in":"path","required":true,"schema":{"type":"integer","title":"Request Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecisionIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/requests/{request_id}/reject":{"post":{"summary":"Từ chối yêu cầu","operationId":"reject_request_api_v1_reception_requests__request_id__reject_post","parameters":[{"name":"request_id","in":"path","required":true,"schema":{"type":"integer","title":"Request Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecisionIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/parking":{"get":{"summary":"Chỗ gửi xe cho khách","operationId":"get_parking_api_v1_reception_parking_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"put":{"summary":"Cập nhật chỗ gửi xe","operationId":"put_parking_api_v1_reception_parking_put","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ParkingIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/facilities":{"get":{"summary":"Danh sách tiện ích","operationId":"list_facilities_api_v1_reception_facilities_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/facilities/{facility_id}":{"put":{"summary":"Cập nhật tiện ích","operationId":"put_facility_api_v1_reception_facilities__facility_id__put","parameters":[{"name":"facility_id","in":"path","required":true,"schema":{"type":"string","title":"Facility Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FacilityIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/reception/access-logs":{"get":{"summary":"Sổ ra vào","description":"Sổ ra vào điện tử (thay sổ giấy): 24 giờ gần nhất.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"access_logs_api_v1_reception_access_logs_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":100,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lễ tân"],"security":[{"BearerAuth":[]}]}},"/api/v1/documents":{"get":{"tags":["Nội quy (RAG)"],"summary":"Danh sách tài liệu","description":"Các bộ tài liệu nội quy, phiên bản của từng bộ và phiên bản đang được dùng để trả lời.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"list_documents_api_v1_documents_get","parameters":[{"name":"family_key","in":"query","required":false,"schema":{"type":"string","default":"building_rules","title":"Family Key"}},{"name":"scope_type","in":"query","required":false,"schema":{"type":"string","default":"complex","title":"Scope Type"}},{"name":"scope_key","in":"query","required":false,"schema":{"type":"string","default":"default","title":"Scope Key"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/documents/{document_id}":{"get":{"tags":["Nội quy (RAG)"],"summary":"Chi tiết tài liệu","description":"Toàn bộ lịch sử của tài liệu: các phiên bản, các lần xuất bản và nhật ký thao tác.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"get_document_details_api_v1_documents__document_id__get","parameters":[{"name":"document_id","in":"path","required":true,"schema":{"type":"string","title":"Document Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/documents/upload":{"post":{"tags":["Nội quy (RAG)"],"summary":"Tải lên tài liệu PDF","description":"Tải lên file PDF. Porter đọc nội dung trong môi trường cách ly và tạo phiên bản nháp ở trạng thái chờ duyệt.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"upload_document_api_v1_documents_upload_post","parameters":[{"name":"reparse_key","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Explicit reparse key to force new draft","title":"Reparse Key"},"description":"Explicit reparse key to force new draft"},{"name":"family_key","in":"query","required":false,"schema":{"type":"string","default":"building_rules","title":"Family Key"}},{"name":"scope_type","in":"query","required":false,"schema":{"type":"string","default":"complex","title":"Scope Type"}},{"name":"scope_key","in":"query","required":false,"schema":{"type":"string","default":"default","title":"Scope Key"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_document_api_v1_documents_upload_post"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/documents/versions/{version_id}/preview":{"get":{"tags":["Nội quy (RAG)"],"summary":"Xem trước phiên bản","description":"Nội dung Porter đã đọc được từ phiên bản này, để ban quản lý kiểm tra trước khi duyệt. Không thay đổi sau khi tạo.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"get_version_preview_api_v1_documents_versions__version_id__preview_get","parameters":[{"name":"version_id","in":"path","required":true,"schema":{"type":"string","title":"Version Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/documents/versions/{version_id}/approve":{"post":{"tags":["Nội quy (RAG)"],"summary":"Duyệt phiên bản","description":"Ban quản lý duyệt phiên bản (xác nhận cả nhãn bản nháp nếu có), Porter bắt đầu lập chỉ mục để tra cứu.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"approve_version_api_v1_documents_versions__version_id__approve_post","parameters":[{"name":"version_id","in":"path","required":true,"schema":{"type":"string","title":"Version Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApproveVersionRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/documents/versions/{version_id}/publish":{"post":{"tags":["Nội quy (RAG)"],"summary":"Xuất bản phiên bản","description":"Xuất bản phiên bản đã sẵn sàng. Phiên bản đang dùng trước đó tự ngừng — chỉ một phiên bản có hiệu lực tại một thời điểm.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"publish_version_api_v1_documents_versions__version_id__publish_post","parameters":[{"name":"version_id","in":"path","required":true,"schema":{"type":"string","title":"Version Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublishVersionRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/documents/versions/{version_id}/rollback":{"post":{"tags":["Nội quy (RAG)"],"summary":"Quay lui phiên bản","description":"Quay về một phiên bản đã duyệt và lập chỉ mục trước đây, ghi thành một lần phát hành mới.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"rollback_version_api_v1_documents_versions__version_id__rollback_post","parameters":[{"name":"version_id","in":"path","required":true,"schema":{"type":"string","title":"Version Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RollbackVersionRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/documents/versions/{version_id}/retire":{"post":{"tags":["Nội quy (RAG)"],"summary":"Ngừng dùng phiên bản","description":"Ngừng dùng một phiên bản đang có hiệu lực hoặc đã sẵn sàng.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"retire_version_api_v1_documents_versions__version_id__retire_post","parameters":[{"name":"version_id","in":"path","required":true,"schema":{"type":"string","title":"Version Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetireVersionRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/radar":{"get":{"tags":["Không khí cư dân"],"summary":"Tổng quan không khí","description":"Tổng quan Radar Không khí Cư dân: Vibe Index, Điểm nóng đang mở, thống kê 24h.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"get_atmosphere_radar_api_v1_atmosphere_radar_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/stats":{"get":{"tags":["Không khí cư dân"],"summary":"Thống kê cảm xúc","description":"Thống kê cảm xúc: tổng theo nhãn, chuỗi thời gian (giờ / ngày), phân tích theo chủ đề / tòa / căn hộ.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"atmosphere_stats_api_v1_atmosphere_stats_get","parameters":[{"name":"range","in":"query","required":false,"schema":{"type":"string","description":"today | 7d | 30d","default":"today","title":"Range"},"description":"today | 7d | 30d"},{"name":"tz","in":"query","required":false,"schema":{"type":"integer","maximum":840,"minimum":-720,"description":"Phút lệch giờ địa phương so với UTC","default":420,"title":"Tz"},"description":"Phút lệch giờ địa phương so với UTC"},{"name":"group_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Group Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/logs":{"get":{"tags":["Không khí cư dân"],"summary":"Tin đã chấm cảm xúc","description":"Danh sách chi tiết tin đã chấm cảm xúc (mới nhất trước), có phân trang.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"atmosphere_logs_api_v1_atmosphere_logs_get","parameters":[{"name":"range","in":"query","required":false,"schema":{"type":"string","default":"today","title":"Range"}},{"name":"tz","in":"query","required":false,"schema":{"type":"integer","maximum":840,"minimum":-720,"default":420,"title":"Tz"}},{"name":"group_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Group Id"}},{"name":"sentiment","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"NEGATIVE | POSITIVE | NEUTRAL | FRUSTRATED | ANGRY_CRITICAL (phân tách bằng dấu phẩy)","title":"Sentiment"},"description":"NEGATIVE | POSITIVE | NEUTRAL | FRUSTRATED | ANGRY_CRITICAL (phân tách bằng dấu phẩy)"},{"name":"topic","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Topic"}},{"name":"block","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Block"}},{"name":"apartment","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Apartment"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":1,"title":"Page"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":5,"default":20,"title":"Page Size"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/logs/export":{"get":{"tags":["Không khí cư dân"],"summary":"Xuất CSV","description":"Xuất danh sách ra CSV (UTF-8 có BOM, Excel mở đúng tiếng Việt). Tối đa 5.000 dòng.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"atmosphere_logs_export_api_v1_atmosphere_logs_export_get","parameters":[{"name":"range","in":"query","required":false,"schema":{"type":"string","default":"today","title":"Range"}},{"name":"tz","in":"query","required":false,"schema":{"type":"integer","maximum":840,"minimum":-720,"default":420,"title":"Tz"}},{"name":"group_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Group Id"}},{"name":"sentiment","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sentiment"}},{"name":"topic","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Topic"}},{"name":"block","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Block"}},{"name":"apartment","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Apartment"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/logs/{log_id}/context":{"get":{"tags":["Không khí cư dân"],"summary":"Ngữ cảnh của tin","description":"Đoạn chat quanh một tin: các tin cùng nhóm (hoặc cùng người gửi nếu không có nhóm) trong ±`minutes` phút.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"atmosphere_log_context_api_v1_atmosphere_logs__log_id__context_get","parameters":[{"name":"log_id","in":"path","required":true,"schema":{"type":"integer","title":"Log Id"}},{"name":"minutes","in":"query","required":false,"schema":{"type":"integer","maximum":240,"minimum":5,"default":30,"title":"Minutes"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/alerts":{"get":{"tags":["Không khí cư dân"],"summary":"Danh sách cảnh báo","description":"Tra cứu danh sách cảnh báo điểm nóng.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"list_alerts_api_v1_atmosphere_alerts_get","parameters":[{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"ACTIVE | RESOLVED | DISMISSED","title":"Status"},"description":"ACTIVE | RESOLVED | DISMISSED"},{"name":"topic","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"POWER_OUTAGE, WATER_OUTAGE...","title":"Topic"},"description":"POWER_OUTAGE, WATER_OUTAGE..."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/alerts/{alert_code}":{"get":{"tags":["Không khí cư dân"],"summary":"Chi tiết cảnh báo","description":"Chi tiết 1 cảnh báo điểm nóng.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"get_alert_detail_api_v1_atmosphere_alerts__alert_code__get","parameters":[{"name":"alert_code","in":"path","required":true,"schema":{"type":"string","title":"Alert Code"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/alerts/{alert_code}/approve-and-publish":{"post":{"tags":["Không khí cư dân"],"summary":"Duyệt và phát thông báo","description":"BQL duyệt và phát thông báo trấn an chính thức vào Group Chat cư dân.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"approve_and_publish_announcement_api_v1_atmosphere_alerts__alert_code__approve_and_publish_post","parameters":[{"name":"alert_code","in":"path","required":true,"schema":{"type":"string","title":"Alert Code"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublishAnnouncementRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/atmosphere/alerts/{alert_code}/dismiss":{"post":{"tags":["Không khí cư dân"],"summary":"Bỏ qua cảnh báo","description":"BQL bỏ qua / đóng cảnh báo (báo động giả, cư dân đùa vui, đã xử lý trước đó).\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"dismiss_alert_api_v1_atmosphere_alerts__alert_code__dismiss_post","parameters":[{"name":"alert_code","in":"path","required":true,"schema":{"type":"string","title":"Alert Code"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DismissAlertRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}]}},"/api/v1/maintenance":{"get":{"summary":"Danh sách lịch bảo trì","operationId":"list_maintenance_api_v1_maintenance_get","parameters":[{"name":"include_past","in":"query","required":false,"schema":{"type":"boolean","description":"true = cả lịch đã xong / đã hủy","default":false,"title":"Include Past"},"description":"true = cả lịch đã xong / đã hủy"}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lịch bảo trì"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"post":{"summary":"Tạo lịch bảo trì","operationId":"create_maintenance_api_v1_maintenance_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MaintenanceIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lịch bảo trì"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/maintenance/{schedule_id}":{"patch":{"summary":"Sửa lịch bảo trì","operationId":"update_maintenance_api_v1_maintenance__schedule_id__patch","parameters":[{"name":"schedule_id","in":"path","required":true,"schema":{"type":"integer","title":"Schedule Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MaintenancePatch"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lịch bảo trì"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"delete":{"summary":"Hủy lịch bảo trì","description":"Hủy lịch (giữ lại để tra cứu, không xóa hẳn).\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"cancel_maintenance_api_v1_maintenance__schedule_id__delete","parameters":[{"name":"schedule_id","in":"path","required":true,"schema":{"type":"integer","title":"Schedule Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Lịch bảo trì"],"security":[{"BearerAuth":[]}]}},"/api/v1/tickets/{ticket_code}/timeline":{"get":{"summary":"Dòng thời gian của đơn","operationId":"ticket_timeline_api_v1_tickets__ticket_code__timeline_get","parameters":[{"name":"ticket_code","in":"path","required":true,"schema":{"type":"string","title":"Ticket Code"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Sự cố & điều phối"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/overview":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Tổng quan cảnh báo sớm","operationId":"overview_api_v1_resident_intelligence_overview_get","parameters":[{"name":"building","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Building"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/incidents":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Danh sách sự việc cư dân phản ánh","operationId":"incidents_api_v1_resident_intelligence_incidents_get","parameters":[{"name":"building","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Building"}},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/incidents/{incident_id}":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Chi tiết sự việc","operationId":"incident_detail_api_v1_resident_intelligence_incidents__incident_id__get","parameters":[{"name":"incident_id","in":"path","required":true,"schema":{"type":"string","title":"Incident Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/incidents/{incident_id}/status":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Cập nhật trạng thái sự việc","operationId":"incident_status_api_v1_resident_intelligence_incidents__incident_id__status_post","parameters":[{"name":"incident_id","in":"path","required":true,"schema":{"type":"string","title":"Incident Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentAction"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/incidents/{incident_id}/tickets":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Gắn đơn sửa chữa vào sự việc","operationId":"link_ticket_api_v1_resident_intelligence_incidents__incident_id__tickets_post","parameters":[{"name":"incident_id","in":"path","required":true,"schema":{"type":"string","title":"Incident Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkInput"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/alerts":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Danh sách cảnh báo","operationId":"alerts_api_v1_resident_intelligence_alerts_get","parameters":[{"name":"kind","in":"query","required":false,"schema":{"anyOf":[{"enum":["SAFETY","OPERATIONAL","REPUTATION"],"type":"string"},{"type":"null"}],"title":"Kind"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/alerts/{alert_id}":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Chi tiết cảnh báo","operationId":"alert_detail_api_v1_resident_intelligence_alerts__alert_id__get","parameters":[{"name":"alert_id","in":"path","required":true,"schema":{"type":"string","title":"Alert Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/alerts/{alert_id}/status":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Cập nhật trạng thái cảnh báo","operationId":"alert_status_api_v1_resident_intelligence_alerts__alert_id__status_post","parameters":[{"name":"alert_id","in":"path","required":true,"schema":{"type":"string","title":"Alert Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Action"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/sources":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Nguồn tin được theo dõi","operationId":"sources_api_v1_resident_intelligence_sources_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Đăng ký nguồn tin","operationId":"register_source_api_v1_resident_intelligence_sources_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SourceInput"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/identities":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Tài khoản chat và cư dân tương ứng","operationId":"identities_api_v1_resident_intelligence_identities_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":100,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/identities/{identity_id}":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Gắn tài khoản chat với cư dân","operationId":"link_identity_api_v1_resident_intelligence_identities__identity_id__post","parameters":[{"name":"identity_id","in":"path","required":true,"schema":{"type":"string","title":"Identity Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdentityInput"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/catalog":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Danh mục loại vấn đề và vị trí","operationId":"catalog_api_v1_resident_intelligence_catalog_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/locations":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Thêm vị trí","operationId":"location_api_v1_resident_intelligence_locations_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocationInput"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/policies":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Danh sách ngưỡng cảnh báo","operationId":"policies_api_v1_resident_intelligence_policies_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Tạo ngưỡng cảnh báo","operationId":"create_policy_api_v1_resident_intelligence_policies_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Policy"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/trends":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Xu hướng phản ánh","operationId":"trends_api_v1_resident_intelligence_trends_get","parameters":[{"name":"building","in":"query","required":true,"schema":{"type":"string","title":"Building"}},{"name":"category","in":"query","required":true,"schema":{"type":"string","title":"Category"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":1344,"minimum":1,"default":168,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/issue-groups/{group_id}":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Chi tiết nhóm vấn đề","operationId":"group_detail_api_v1_resident_intelligence_issue_groups__group_id__get","parameters":[{"name":"group_id","in":"path","required":true,"schema":{"type":"string","title":"Group Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/jobs":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Tác vụ phân tích","operationId":"jobs_api_v1_resident_intelligence_jobs_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/jobs/{job_id}/retry":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Chạy lại tác vụ phân tích","operationId":"retry_api_v1_resident_intelligence_jobs__job_id__retry_post","parameters":[{"name":"job_id","in":"path","required":true,"schema":{"type":"string","title":"Job Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Reason"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/analyses":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Kết quả phân tích tin nhắn","operationId":"analyses_api_v1_resident_intelligence_analyses_get","parameters":[{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/analyses/{analysis_id}/review":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Duyệt kết quả phân tích","operationId":"review_api_v1_resident_intelligence_analyses__analysis_id__review_post","parameters":[{"name":"analysis_id","in":"path","required":true,"schema":{"type":"string","title":"Analysis Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Review"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/observations/{observation_id}/exclude":{"post":{"tags":["Cảnh báo sớm cư dân"],"summary":"Loại tin khỏi thống kê","operationId":"exclude_observation_api_v1_resident_intelligence_observations__observation_id__exclude_post","parameters":[{"name":"observation_id","in":"path","required":true,"schema":{"type":"string","title":"Observation Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Exclusion"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/resident-intelligence/health":{"get":{"tags":["Cảnh báo sớm cư dân"],"summary":"Tình trạng hệ thống cảnh báo sớm","operationId":"health_api_v1_resident_intelligence_health_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/integrations/resident-intelligence/coverage":{"post":{"summary":"Báo độ phủ của nguồn tin","operationId":"report_integrations_resident_intelligence_coverage_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Coverage"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}},"tags":["Cảnh báo sớm cư dân"],"security":[{"IntegrationToken":[]}],"description":"**Xác thực:** `X-Integration-Token`."}},"/api/v1/dev/simulate-inbound":{"post":{"summary":"Giả lập tin cư dân","description":"Bắn 1 tin cư dân giả lập — chạy y như tin thật, xử lý đồng bộ để thấy kết quả ngay.\n\n**Xác thực:** không cần.\n\n**Kết quả:** Tin đi qua đúng luồng như tin thật và được xử lý ngay. Câu trả lời xem ở `GET /api/v1/dev/outbox`.\n\n**Lỗi riêng:** `404 DEMO_MODE_OFF`","operationId":"simulate_inbound_api_v1_dev_simulate_inbound_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InboundMessage"},"example":{"message_id":"Messenger:demo-001","source_channel":"Messenger","channel_user_id":"demo_fb_a1205","kind":"TEXT","text":"Phòng khách nhà em mất điện"}}},"required":true},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Demo"]}},"/api/v1/dev/outbox":{"get":{"summary":"Tin Porter đã trả lời","operationId":"dev_outbox_api_v1_dev_outbox_get","parameters":[{"name":"since","in":"query","required":false,"schema":{"type":"integer","default":0,"title":"Since"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Demo"],"description":"**Xác thực:** không cần."}},"/api/v1/dev/reset":{"post":{"summary":"Nạp lại dữ liệu mẫu","description":"Xóa sạch & nạp lại dữ liệu mẫu — dùng giữa các lần tập demo.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"dev_reset_api_v1_dev_reset_post","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Demo"],"security":[{"BearerAuth":[]}]}},"/api/v1/channels/status":{"get":{"summary":"Trạng thái kênh","operationId":"channels_status_api_v1_channels_status_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/channels/test-send":{"post":{"summary":"Gửi tin thử","description":"Gửi thử 1 tin qua Deplao — kiểm tra API key, account ID, đường dẫn gửi tin.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"channels_test_send_api_v1_channels_test_send_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestSendRequest"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}]}},"/api/v1/channels/zalo-oa":{"get":{"summary":"Trạng thái Zalo OA","operationId":"zalo_oa_status_api_v1_channels_zalo_oa_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"delete":{"summary":"Ngắt kết nối Zalo OA","description":"Ngắt kết nối: xóa token (giữ App ID để kết nối lại nhanh). Không gửi tin qua Zalo OA nữa.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"zalo_oa_disconnect_api_v1_channels_zalo_oa_delete","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}]}},"/api/v1/channels/zalo-oa/app":{"put":{"summary":"Lưu thông tin ứng dụng Zalo OA","description":"Bước 1: lưu App ID / App Secret / OA Secret Key (lấy ở developers.zalo.me).\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"zalo_oa_save_app_api_v1_channels_zalo_oa_app_put","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}]}},"/api/v1/channels/zalo-oa/authorize":{"post":{"summary":"Tạo link cấp quyền Zalo OA","description":"Bước 2: tạo link cấp quyền của Zalo. Callback URL phải khai báo trùng trong cài đặt ứng dụng Zalo.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"zalo_oa_authorize_api_v1_channels_zalo_oa_authorize_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthorizeIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}]}},"/api/v1/channels/zalo-oa/tokens":{"put":{"summary":"Nhập token Zalo OA","description":"Cách 2: dán access token (+ refresh token để tự làm mới) lấy từ Zalo API Explorer.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"zalo_oa_save_tokens_api_v1_channels_zalo_oa_tokens_put","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokensIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}]}},"/api/v1/channels/zalo-oa/test":{"post":{"summary":"Kiểm tra kết nối Zalo OA","description":"Kiểm tra kết nối: gọi Zalo lấy thông tin OA; token hết hạn thì thử làm mới bằng refresh token.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"zalo_oa_test_api_v1_channels_zalo_oa_test_post","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}]}},"/api/v1/partner/messages":{"post":{"tags":["Partner API"],"summary":"Gửi tin của người dùng","operationId":"partner_inbound_api_v1_partner_messages_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerInbound"},"example":{"message_id":"m-1001","user_id":"u-42","display_name":"Hà Trần","gender":"female","text":"Bồn rửa bếp nhà em rò nước","image_urls":[],"resident_phone":"0901234567"}}}},"responses":{"200":{"description":"Thành công","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Partner Inbound Api V1 Partner Messages Post"},"example":{"accepted":true,"duplicate":false,"resident_linked":true}}}},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}},"security":[{"PartnerKey":[]}],"description":"**Xác thực:** `X-Partner-Key`.\n\n**Kết quả:** `accepted` đã nhận · `duplicate` trùng `message_id` nên bỏ qua · `resident_linked` đã nhận ra cư dân. Câu trả lời đến sau qua webhook hoặc `GET /api/v1/partner/messages`.\n\n**Lỗi riêng:** `401 PARTNER_KEY_REQUIRED` · `401 INVALID_PARTNER_KEY` · `422 EMPTY_MESSAGE` thiếu cả `text` lẫn ảnh"},"get":{"tags":["Partner API"],"summary":"Lấy tin trả lời","operationId":"partner_replies_api_v1_partner_messages_get","parameters":[{"name":"user_id","in":"query","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"User Id"}},{"name":"after","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"After"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}},"security":[{"PartnerKey":[]}],"description":"**Xác thực:** `X-Partner-Key`.\n\n**Kết quả:** `messages` các tin có `seq` lớn hơn `after`, cũ trước. Lưu `next_after` để gọi lần sau.\n\n**Lỗi riêng:** `401 PARTNER_KEY_REQUIRED` · `401 INVALID_PARTNER_KEY`"}},"/api/v1/partners":{"get":{"summary":"Danh sách đối tác","operationId":"list_partners_api_v1_partners_get","responses":{"200":{"description":"Thành công"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."},"post":{"summary":"Tạo đối tác","description":"Tạo đối tác. API key + webhook secret CHỈ trả về một lần ở đây.\n\n**Xác thực:** token nhân viên (`Authorization: Bearer`).","operationId":"create_partner_api_v1_partners_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerIn"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}]}},"/api/v1/partners/{partner_id}":{"patch":{"summary":"Sửa đối tác","operationId":"update_partner_api_v1_partners__partner_id__patch","parameters":[{"name":"partner_id","in":"path","required":true,"schema":{"type":"string","title":"Partner Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerPatch"}}}},"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/api/v1/partners/{partner_id}/rotate-key":{"post":{"summary":"Cấp lại khóa đối tác","operationId":"rotate_partner_key_api_v1_partners__partner_id__rotate_key_post","parameters":[{"name":"partner_id","in":"path","required":true,"schema":{"type":"string","title":"Partner Id"}}],"responses":{"200":{"description":"Thành công"},"422":{"description":"Dữ liệu không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}},"tags":["Kênh nhắn tin"],"security":[{"BearerAuth":[]}],"description":"**Xác thực:** token nhân viên (`Authorization: Bearer`)."}},"/health":{"get":{"summary":"Kiểm tra tình trạng","operationId":"health_health_get","responses":{"200":{"description":"Thành công"}},"tags":["Hệ thống"],"description":"**Xác thực:** không cần."}}},"components":{"schemas":{"AccessEventIn":{"properties":{"code":{"type":"string","maxLength":300,"minLength":4,"title":"Code"},"gate":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Gate"},"plate":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Plate"}},"type":"object","required":["code"],"title":"AccessEventIn"},"Action":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"version":{"type":"integer","minimum":1.0,"title":"Version"},"action":{"type":"string","enum":["ACKNOWLEDGED","RESOLVED","DISMISSED"],"title":"Action"}},"additionalProperties":false,"type":"object","required":["reason","version","action"],"title":"Action"},"ApartmentItems":{"properties":{"items":{"items":{"additionalProperties":true,"type":"object"},"type":"array","maxItems":5000,"minItems":1,"title":"Items"},"mapping":{"anyOf":[{"$ref":"#/components/schemas/ImportMapping"},{"type":"null"}]}},"type":"object","required":["items"],"title":"ApartmentItems","description":"Mỗi phần tử là một dòng: khóa là tên cột trong file (Mã căn, Tòa, Tầng, Chủ hộ, Số điện thoại…)\nhoặc tên chuẩn (apartment_code, block, floor, unit, resident_name, phone)."},"AppIn":{"properties":{"app_id":{"type":"string","maxLength":100,"minLength":3,"pattern":"^\\d+$","title":"App Id"},"app_secret":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"App Secret"},"oa_secret_key":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Oa Secret Key"}},"type":"object","required":["app_id"],"title":"AppIn"},"ApproveVersionRequest":{"properties":{"draft_acknowledged":{"type":"boolean","title":"Draft Acknowledged","description":"Explicit acknowledgment if the document source contains a DỰ THẢO label","default":false}},"type":"object","title":"ApproveVersionRequest"},"AuthorizeIn":{"properties":{"origin":{"type":"string","maxLength":200,"title":"Origin","description":"window.location.origin của trang BQL"}},"type":"object","required":["origin"],"title":"AuthorizeIn"},"Body_upload_document_api_v1_documents_upload_post":{"properties":{"file":{"type":"string","contentMediaType":"application/octet-stream","title":"File"}},"type":"object","required":["file"],"title":"Body_upload_document_api_v1_documents_upload_post"},"BqlApproveRequest":{"properties":{"approved":{"type":"boolean","title":"Approved"},"technician_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Technician Id"},"note":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Note"}},"type":"object","required":["approved"],"title":"BqlApproveRequest"},"BuildingIn":{"properties":{"name":{"type":"string","maxLength":60,"minLength":1,"title":"Name"},"floors":{"type":"integer","maximum":80.0,"minimum":1.0,"title":"Floors"},"units_per_floor":{"type":"integer","maximum":20.0,"minimum":1.0,"title":"Units Per Floor"},"skip_floors":{"items":{"type":"integer"},"type":"array","maxItems":20,"title":"Skip Floors"},"podium_floors":{"type":"integer","maximum":5.0,"minimum":0.0,"title":"Podium Floors","default":1},"shape":{"type":"string","enum":["square","rect","L"],"title":"Shape","default":"square"},"sort_order":{"type":"integer","title":"Sort Order","default":0}},"type":"object","required":["name","floors","units_per_floor"],"title":"BuildingIn"},"Classification":{"properties":{"is_complaint":{"type":"boolean","title":"Is Complaint"},"escalation_signal":{"type":"string","enum":["NONE","REPEATED_REPORT","FORMAL_COMPLAINT"],"title":"Escalation Signal","default":"NONE"},"sentiment":{"type":"string","enum":["POSITIVE","NEUTRAL","FRUSTRATED","ANGRY_CRITICAL"],"title":"Sentiment"},"summary":{"type":"string","maxLength":500,"minLength":1,"title":"Summary"},"issues":{"items":{"$ref":"#/components/schemas/ExtractedIssue"},"type":"array","maxItems":8,"title":"Issues"}},"additionalProperties":false,"type":"object","required":["is_complaint","sentiment","summary","issues"],"title":"Classification"},"Coverage":{"properties":{"source_id":{"type":"string","title":"Source Id"},"starts_at":{"type":"string","format":"date-time","title":"Starts At"},"ends_at":{"type":"string","format":"date-time","title":"Ends At"},"complete":{"type":"boolean","title":"Complete"}},"additionalProperties":false,"type":"object","required":["source_id","starts_at","ends_at","complete"],"title":"Coverage"},"DecisionIn":{"properties":{"note":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Note"}},"type":"object","title":"DecisionIn"},"DeviceVerifyIn":{"properties":{"qr":{"type":"string","maxLength":300,"minLength":4,"title":"Qr"},"gate":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Gate"},"plate":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Plate"}},"type":"object","required":["qr"],"title":"DeviceVerifyIn"},"DismissAlertRequest":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason","description":"Lý do bỏ qua / đóng cảnh báo (vd: Báo động giả, Spam...)"}},"type":"object","required":["reason"],"title":"DismissAlertRequest"},"Exclusion":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"excluded":{"type":"boolean","title":"Excluded"}},"additionalProperties":false,"type":"object","required":["reason","excluded"],"title":"Exclusion"},"ExtractedIssue":{"properties":{"issue_type":{"type":"string","maxLength":64,"minLength":1,"title":"Issue Type"},"location_text":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Location Text"},"evidence":{"type":"string","maxLength":1000,"minLength":1,"title":"Evidence"}},"additionalProperties":false,"type":"object","required":["issue_type","evidence"],"title":"ExtractedIssue"},"FacilityIn":{"properties":{"facility_id":{"type":"string","maxLength":30,"minLength":2,"pattern":"^[a-z0-9][a-z0-9-]*$","title":"Facility Id"},"name":{"type":"string","maxLength":100,"minLength":1,"title":"Name"},"keywords":{"items":{"type":"string"},"type":"array","maxItems":20,"title":"Keywords"},"building_block":{"anyOf":[{"type":"string","maxLength":10},{"type":"null"}],"title":"Building Block"},"open_hour":{"type":"integer","maximum":23.0,"minimum":0.0,"title":"Open Hour","default":6},"close_hour":{"type":"integer","maximum":24.0,"minimum":1.0,"title":"Close Hour","default":22},"default_minutes":{"type":"integer","maximum":720.0,"minimum":15.0,"title":"Default Minutes","default":120},"max_minutes":{"type":"integer","maximum":1440.0,"minimum":15.0,"title":"Max Minutes","default":180},"max_per_week":{"type":"integer","maximum":50.0,"minimum":1.0,"title":"Max Per Week","default":2},"max_people":{"type":"integer","maximum":1000.0,"minimum":1.0,"title":"Max People","default":20},"fee":{"type":"integer","minimum":0.0,"title":"Fee","default":0},"deposit":{"type":"integer","minimum":0.0,"title":"Deposit","default":0},"rules":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Rules"},"is_active":{"type":"boolean","title":"Is Active","default":true}},"type":"object","required":["facility_id","name"],"title":"FacilityIn"},"GroupPatch":{"properties":{"building_block":{"anyOf":[{"type":"string","maxLength":10},{"type":"null"}],"title":"Building Block"},"name":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Name"}},"type":"object","title":"GroupPatch"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"IdentityInput":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"resident_id":{"type":"string","maxLength":36,"minLength":1,"title":"Resident Id"}},"additionalProperties":false,"type":"object","required":["reason","resident_id"],"title":"IdentityInput"},"ImportMapping":{"properties":{"apartment":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Apartment"},"block":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Block"},"floor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Floor"},"unit":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Unit"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"facebook":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Facebook"},"code_regex":{"anyOf":[{"type":"string","maxLength":160},{"type":"null"}],"title":"Code Regex"},"block_map":{"additionalProperties":{"type":"string"},"type":"object","title":"Block Map"},"default_block":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Block"},"skip_values":{"items":{"type":"string"},"type":"array","maxItems":50,"title":"Skip Values"},"notes":{"type":"string","title":"Notes","default":""}},"type":"object","title":"ImportMapping"},"InboundMessage":{"properties":{"message_id":{"type":"string","maxLength":150,"minLength":3,"title":"Message Id","description":"<kênh>:<id tin gốc>"},"source_channel":{"$ref":"#/components/schemas/SourceChannel"},"channel_user_id":{"type":"string","maxLength":100,"minLength":1,"title":"Channel User Id"},"group_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Group Id"},"account_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Account Id","description":"Nick Deplao đã nhận tin"},"addressed_to_bot":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Addressed To Bot","description":"Tin nhóm có gọi bot không (Deplao tính từ mention/quote). None = nguồn không biết → gateway đoán theo chữ"},"sender_display_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sender Display Name"},"sender_gender":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sender Gender"},"mentions_bot":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Mentions Bot"},"reply_to_bot":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Reply To Bot"},"kind":{"$ref":"#/components/schemas/MessageKind","default":"TEXT"},"text":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Text"},"image_urls":{"items":{"type":"string"},"type":"array","title":"Image Urls"},"postback":{"anyOf":[{"$ref":"#/components/schemas/PostbackPayload"},{"type":"null"}]},"sent_at":{"type":"string","format":"date-time","title":"Sent At"}},"type":"object","required":["message_id","source_channel","channel_user_id"],"title":"InboundMessage","description":"Tin từ cư dân đã chuẩn hóa (lớp Đa kênh → Backend)."},"IncidentAction":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"version":{"type":"integer","minimum":1.0,"title":"Version"},"status":{"type":"string","enum":["INVESTIGATING","MONITORING","RESOLVED","DISMISSED"],"title":"Status"},"confirmed":{"type":"boolean","title":"Confirmed","default":false}},"additionalProperties":false,"type":"object","required":["reason","version","status"],"title":"IncidentAction"},"InjectSensorRequest":{"properties":{"apartment_id":{"type":"string","title":"Apartment Id"},"sub_location":{"type":"string","title":"Sub Location"},"sensor_type":{"$ref":"#/components/schemas/SensorType"},"metric_value":{"type":"number","title":"Metric Value","default":0.0},"simulate_offline":{"type":"boolean","title":"Simulate Offline","default":false}},"type":"object","required":["apartment_id","sub_location","sensor_type"],"title":"InjectSensorRequest"},"LinkApprove":{"properties":{"resident_id":{"type":"string","maxLength":36,"minLength":1,"title":"Resident Id"}},"type":"object","required":["resident_id"],"title":"LinkApprove"},"LinkInput":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"ticket_code":{"type":"string","maxLength":20,"minLength":1,"title":"Ticket Code"},"evidence_id":{"type":"string","maxLength":36,"minLength":1,"title":"Evidence Id"}},"additionalProperties":false,"type":"object","required":["reason","ticket_code","evidence_id"],"title":"LinkInput"},"LinkReject":{"properties":{"note":{"anyOf":[{"type":"string","maxLength":300},{"type":"null"}],"title":"Note"}},"type":"object","title":"LinkReject"},"LocationInput":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"building":{"type":"string","maxLength":4,"minLength":1,"title":"Building"},"name":{"type":"string","maxLength":200,"minLength":1,"title":"Name"},"apartment_id":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Apartment Id"}},"additionalProperties":false,"type":"object","required":["reason","building","name"],"title":"LocationInput"},"LoginRequest":{"properties":{"username":{"type":"string","maxLength":254,"minLength":1,"title":"Username"},"password":{"type":"string","maxLength":200,"minLength":1,"title":"Password"}},"type":"object","required":["username","password"],"title":"LoginRequest"},"MaintenanceIn":{"properties":{"topic_cluster":{"type":"string","pattern":"^(POWER_OUTAGE|WATER_OUTAGE|ELEVATOR_ISSUE|GARBAGE_SMELL|NOISE_DISTURBANCE|SECURITY_PARKING|OTHER)$","title":"Topic Cluster"},"building_block":{"anyOf":[{"type":"string","maxLength":10},{"type":"null"}],"title":"Building Block"},"affected_zone":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Affected Zone"},"title":{"type":"string","maxLength":200,"minLength":3,"title":"Title"},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Description"},"start_time":{"type":"string","format":"date-time","title":"Start Time"},"end_time":{"type":"string","format":"date-time","title":"End Time"}},"type":"object","required":["topic_cluster","title","start_time","end_time"],"title":"MaintenanceIn"},"MaintenancePatch":{"properties":{"topic_cluster":{"anyOf":[{"type":"string","pattern":"^(POWER_OUTAGE|WATER_OUTAGE|ELEVATOR_ISSUE|GARBAGE_SMELL|NOISE_DISTURBANCE|SECURITY_PARKING|OTHER)$"},{"type":"null"}],"title":"Topic Cluster"},"building_block":{"anyOf":[{"type":"string","maxLength":10},{"type":"null"}],"title":"Building Block"},"affected_zone":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Affected Zone"},"title":{"anyOf":[{"type":"string","maxLength":200,"minLength":3},{"type":"null"}],"title":"Title"},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Description"},"start_time":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Start Time"},"end_time":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"End Time"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},"type":"object","title":"MaintenancePatch"},"MappingRequest":{"properties":{"columns":{"items":{"type":"string"},"type":"array","maxItems":100,"minItems":1,"title":"Columns"},"rows":{"items":{"items":{},"type":"array"},"type":"array","maxItems":30,"title":"Rows"}},"type":"object","required":["columns"],"title":"MappingRequest"},"MarkReadRequest":{"properties":{"ids":{"anyOf":[{"items":{"type":"integer"},"type":"array"},{"type":"null"}],"title":"Ids"}},"type":"object","title":"MarkReadRequest"},"MemberConfirm":{"properties":{"resident_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Resident Id"}},"type":"object","title":"MemberConfirm"},"MessageKind":{"type":"string","enum":["TEXT","IMAGE","POSTBACK"],"title":"MessageKind"},"ParkingIn":{"properties":{"building_block":{"type":"string","maxLength":10,"minLength":1,"title":"Building Block"},"car_slots":{"type":"integer","maximum":1000.0,"minimum":0.0,"title":"Car Slots"},"motorbike_slots":{"type":"integer","maximum":5000.0,"minimum":0.0,"title":"Motorbike Slots"}},"type":"object","required":["building_block","car_slots","motorbike_slots"],"title":"ParkingIn"},"PartnerIn":{"properties":{"partner_id":{"type":"string","maxLength":40,"minLength":3,"pattern":"^[a-z0-9][a-z0-9-]*$","title":"Partner Id"},"name":{"type":"string","maxLength":100,"minLength":1,"title":"Name"},"webhook_url":{"anyOf":[{"type":"string","maxLength":500,"pattern":"^https?://"},{"type":"null"}],"title":"Webhook Url"},"trust_resident_phone":{"type":"boolean","title":"Trust Resident Phone","default":false}},"type":"object","required":["partner_id","name"],"title":"PartnerIn"},"PartnerInbound":{"properties":{"message_id":{"type":"string","maxLength":100,"minLength":1,"title":"Message Id"},"user_id":{"type":"string","maxLength":100,"minLength":1,"pattern":"^[^:\\s]+$","title":"User Id"},"display_name":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Display Name"},"text":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Text"},"image_urls":{"items":{"type":"string"},"type":"array","maxItems":5,"title":"Image Urls"},"gender":{"anyOf":[{"type":"string","pattern":"^(male|female)?$"},{"type":"null"}],"title":"Gender"},"resident_phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Resident Phone"}},"type":"object","required":["message_id","user_id"],"title":"PartnerInbound"},"PartnerPatch":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Name"},"webhook_url":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Webhook Url"},"trust_resident_phone":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Trust Resident Phone"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},"type":"object","title":"PartnerPatch"},"PassIn":{"properties":{"resident_id":{"type":"string","title":"Resident Id"},"guest_name":{"type":"string","maxLength":100,"minLength":1,"title":"Guest Name"},"guest_count":{"type":"integer","maximum":200.0,"minimum":1.0,"title":"Guest Count","default":1},"vehicle_type":{"type":"string","pattern":"^(NONE|CAR|MOTORBIKE)$","title":"Vehicle Type","default":"NONE"},"plate":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Plate"},"valid_from":{"type":"string","format":"date-time","title":"Valid From"},"valid_until":{"type":"string","format":"date-time","title":"Valid Until"}},"type":"object","required":["resident_id","guest_name","valid_from","valid_until"],"title":"PassIn"},"Policy":{"properties":{"version":{"type":"integer","minimum":1.0,"title":"Version","default":1},"n_weight":{"type":"number","maximum":1.0,"minimum":0.0,"title":"N Weight","default":0.2},"v_weight":{"type":"number","maximum":1.0,"minimum":0.0,"title":"V Weight","default":0.2},"g_weight":{"type":"number","maximum":1.0,"minimum":0.0,"title":"G Weight","default":0.2},"s_weight":{"type":"number","maximum":1.0,"minimum":0.0,"title":"S Weight","default":0.25},"u_weight":{"type":"number","maximum":1.0,"minimum":0.0,"title":"U Weight","default":0.15},"volume_target":{"type":"integer","maximum":10000.0,"minimum":1.0,"title":"Volume Target","default":10},"ewma_lambda":{"type":"number","maximum":1.0,"exclusiveMinimum":0.0,"title":"Ewma Lambda","default":0.3},"medium":{"type":"number","maximum":100.0,"minimum":0.0,"title":"Medium","default":45},"high":{"type":"number","maximum":100.0,"minimum":0.0,"title":"High","default":70},"cooldown_minutes":{"type":"integer","maximum":1440.0,"minimum":1.0,"title":"Cooldown Minutes","default":30}},"additionalProperties":false,"type":"object","title":"Policy"},"PostbackAction":{"type":"string","enum":["HITL_APPROVE","HITL_REJECT","ACCEPT_DONE","ACCEPT_NOT_DONE"],"title":"PostbackAction"},"PostbackPayload":{"properties":{"action":{"$ref":"#/components/schemas/PostbackAction"},"ticket_code":{"type":"string","maxLength":20,"minLength":1,"title":"Ticket Code"}},"type":"object","required":["action","ticket_code"],"title":"PostbackPayload"},"PublishAnnouncementRequest":{"properties":{"custom_title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Custom Title","description":"Tiêu đề thông báo chỉnh sửa (nếu có)"},"custom_content":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Custom Content","description":"Nội dung thông báo chỉnh sửa (nếu có)"}},"type":"object","title":"PublishAnnouncementRequest"},"PublishVersionRequest":{"properties":{"effective_from":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Effective From","description":"Effective start instant (must be now or future). Default is CURRENT_TIMESTAMP"},"effective_until":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Effective Until","description":"Optional effective end instant"},"reason":{"type":"string","maxLength":1000,"minLength":1,"title":"Reason","description":"Audit reason for publication"}},"type":"object","required":["reason"],"title":"PublishVersionRequest"},"Reason":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"}},"additionalProperties":false,"type":"object","required":["reason"],"title":"Reason"},"ReassignRequest":{"properties":{"technician_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Technician Id"},"eta_time":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Eta Time"},"note":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Note"},"force":{"type":"boolean","title":"Force","default":false}},"type":"object","title":"ReassignRequest"},"ResidentIn":{"properties":{"full_name":{"type":"string","maxLength":100,"minLength":1,"title":"Full Name"},"apartment_id":{"type":"string","maxLength":10,"minLength":5,"title":"Apartment Id"},"phone_number":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone Number"},"facebook_url":{"anyOf":[{"type":"string","maxLength":300},{"type":"null"}],"title":"Facebook Url"}},"type":"object","required":["full_name","apartment_id"],"title":"ResidentIn"},"ResidentPatch":{"properties":{"full_name":{"anyOf":[{"type":"string","maxLength":100,"minLength":1},{"type":"null"}],"title":"Full Name"},"apartment_id":{"anyOf":[{"type":"string","maxLength":10,"minLength":5},{"type":"null"}],"title":"Apartment Id"},"phone_number":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone Number"},"facebook_url":{"anyOf":[{"type":"string","maxLength":300},{"type":"null"}],"title":"Facebook Url"},"is_verified":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Verified"}},"type":"object","title":"ResidentPatch"},"RetireVersionRequest":{"properties":{"reason":{"type":"string","maxLength":1000,"minLength":1,"title":"Reason","description":"Audit reason for retiring active version"}},"type":"object","required":["reason"],"title":"RetireVersionRequest"},"Review":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"building":{"type":"string","maxLength":4,"minLength":1,"title":"Building"},"classification":{"$ref":"#/components/schemas/Classification"}},"additionalProperties":false,"type":"object","required":["reason","building","classification"],"title":"Review"},"RollbackVersionRequest":{"properties":{"reason":{"type":"string","maxLength":1000,"minLength":1,"title":"Reason","description":"Audit reason for rollback"},"effective_from":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Effective From","description":"Effective start instant (must be now or future). Default is CURRENT_TIMESTAMP"}},"type":"object","required":["reason"],"title":"RollbackVersionRequest"},"SensorType":{"type":"string","enum":["TEMPERATURE","POWER","WATER_FLOW","SMOKE"],"title":"SensorType"},"SlaPolicyPatch":{"properties":{"response_minutes":{"anyOf":[{"type":"integer","maximum":10080.0,"minimum":1.0},{"type":"null"}],"title":"Response Minutes"},"resolution_minutes":{"anyOf":[{"type":"integer","maximum":43200.0,"minimum":1.0},{"type":"null"}],"title":"Resolution Minutes"},"e2e_minutes":{"anyOf":[{"type":"integer","maximum":86400.0,"minimum":1.0},{"type":"null"}],"title":"E2E Minutes"},"warn_percent":{"anyOf":[{"type":"integer","maximum":99.0,"minimum":10.0},{"type":"null"}],"title":"Warn Percent"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"}},"type":"object","title":"SlaPolicyPatch"},"SourceChannel":{"type":"string","enum":["Zalo","Zalo_Group","Messenger","Telegram","Telegram_Group","Zalo_OA","App"],"title":"SourceChannel"},"SourceInput":{"properties":{"reason":{"type":"string","maxLength":500,"minLength":3,"title":"Reason"},"provider":{"type":"string","enum":["Zalo","Zalo_Group","Messenger","Zalo_OA","Telegram","Telegram_Group","App"],"title":"Provider"},"account_external_id":{"type":"string","maxLength":100,"minLength":1,"title":"Account External Id"},"source_key":{"type":"string","maxLength":100,"minLength":1,"title":"Source Key"},"group_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Group Id"},"building":{"anyOf":[{"type":"string","maxLength":4},{"type":"null"}],"title":"Building"},"enabled":{"type":"boolean","title":"Enabled","default":false}},"additionalProperties":false,"type":"object","required":["reason","provider","account_external_id","source_key"],"title":"SourceInput"},"TechProgressRequest":{"properties":{"status":{"type":"string","enum":["MOVING","IN_PROGRESS","COMPLETED","NO_SHOW"],"title":"Status"},"extra_cost_requested":{"type":"integer","minimum":0.0,"title":"Extra Cost Requested","default":0},"note":{"anyOf":[{"type":"string","maxLength":1000},{"type":"null"}],"title":"Note"}},"type":"object","required":["status"],"title":"TechProgressRequest"},"TechnicianIn":{"properties":{"full_name":{"type":"string","maxLength":100,"minLength":1,"title":"Full Name"},"skills":{"items":{"type":"string"},"type":"array","maxItems":5,"minItems":1,"title":"Skills"},"phone_number":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone Number"},"username":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Username"},"password":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Password"}},"type":"object","required":["full_name","skills"],"title":"TechnicianIn"},"TechnicianPatch":{"properties":{"full_name":{"anyOf":[{"type":"string","maxLength":100,"minLength":1},{"type":"null"}],"title":"Full Name"},"skills":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":5,"minItems":1},{"type":"null"}],"title":"Skills"},"phone_number":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone Number"},"is_active":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Active"},"username":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Username"},"password":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Password"}},"type":"object","title":"TechnicianPatch"},"TestSendRequest":{"properties":{"source_channel":{"$ref":"#/components/schemas/SourceChannel"},"conversation_id":{"type":"string","maxLength":100,"minLength":1,"title":"Conversation Id"},"is_group":{"type":"boolean","title":"Is Group","default":false},"text":{"type":"string","maxLength":1000,"minLength":1,"title":"Text","default":"Tin nhắn thử từ hệ thống BQL ✅"}},"type":"object","required":["source_channel","conversation_id"],"title":"TestSendRequest"},"TokensIn":{"properties":{"access_token":{"type":"string","maxLength":2000,"minLength":20,"title":"Access Token"},"refresh_token":{"anyOf":[{"type":"string","maxLength":2000},{"type":"null"}],"title":"Refresh Token"}},"type":"object","required":["access_token"],"title":"TokensIn"},"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"},"VerifyIn":{"properties":{"code":{"type":"string","maxLength":300,"minLength":4,"title":"Code"},"gate":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Gate"},"plate":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Plate"}},"type":"object","required":["code"],"title":"VerifyIn"},"Error":{"type":"object","title":"Lỗi","properties":{"detail":{"type":"object","properties":{"code":{"type":"string","description":"Mã lỗi ổn định, dùng để rẽ nhánh trong code"},"message":{"type":"string","description":"Mô tả tiếng Việt, hiển thị được cho người dùng"}},"required":["code","message"]}}},"TicketEvent":{"type":"object","title":"Sự kiện ticket","properties":{"event_id":{"type":"string"},"event_type":{"type":"string","enum":["ticket.created","ticket.updated"]},"occurred_at":{"type":"string","format":"date-time"},"changes":{"type":"array","items":{"type":"string"},"example":["status","assigned_tech_id"],"description":"Các trường đã đổi so với lần gửi trước"},"ticket":{"type":"object","properties":{"ticket_code":{"type":"string","example":"TK-215"},"status":{"type":"string","enum":["SLOT_FILLING","WAIT_RESIDENT_HITL","WAIT_BQL_HITL","SCHEDULED","MOVING","IN_PROGRESS","COMPLETED","CLOSED","CANCELLED","REJECTED","NO_SHOW"],"example":"WAIT_BQL_HITL"},"apartment_id":{"type":"string","example":"A1205"},"sub_location":{"type":["string","null"],"example":"Phòng khách"},"summary":{"type":"string","example":"Phòng khách mất điện"},"incident_type":{"type":"string","enum":["ELECTRICAL","PLUMBING","HVAC","FIRE_SAFETY","FACILITY"],"example":"ELECTRICAL"},"priority_level":{"type":"string","enum":["LOW","NORMAL","MEDIUM","HIGH","CRITICAL"],"example":"HIGH"},"is_emergency":{"type":"boolean","example":false},"estimated_cost":{"type":["number","null"],"example":150000},"assigned_technician":{"type":["object","null"],"properties":{"technician_id":{"type":"string"},"full_name":{"type":"string","example":"Trần Văn Bình"}}},"eta_time":{"type":["string","null"],"format":"date-time"},"source_channel":{"type":"string","example":"Messenger"},"image_urls":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}}}},"GuestPassEvent":{"type":"object","title":"Sự kiện mã khách","properties":{"event_id":{"type":"string"},"event_type":{"type":"string","enum":["guest_pass.created","guest_pass.cancelled","guest_pass.entered"]},"occurred_at":{"type":"string","format":"date-time"},"pass":{"type":"object","properties":{"kind":{"type":"string","enum":["GUEST","FACILITY"]},"status":{"type":"string","example":"ACTIVE"},"code":{"type":"string","example":"K7M2QX"},"guest_name":{"type":["string","null"],"example":"Tuấn"},"guest_count":{"type":"integer","example":1},"vehicle_type":{"type":["string","null"],"example":"CAR"},"plate":{"type":["string","null"],"example":"30A-123.45"},"apartment_id":{"type":"string","example":"A1205"},"building_block":{"type":"string","example":"A"},"valid_from":{"type":"string","format":"date-time"},"valid_until":{"type":"string","format":"date-time"},"facility":{"type":["object","null"]}}},"gate":{"type":"string","description":"Chỉ có ở `guest_pass.entered`"},"entered_at":{"type":"string","format":"date-time","description":"Chỉ có ở `guest_pass.entered`"}}},"PartnerReply":{"type":"object","title":"Tin trả lời cho đối tác","properties":{"seq":{"type":"integer","example":17,"description":"Số thứ tự, dùng làm `after` khi polling"},"outbound_id":{"type":"string","example":"out_ab12"},"user_id":{"type":"string","example":"u-42"},"intent":{"type":"string","example":"HITL_QUOTE"},"ticket_code":{"type":["string","null"],"example":"TK-215"},"text":{"type":"string"},"language":{"type":"string","example":"vi"},"buttons":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string","example":"✅ Đồng ý"},"action":{"type":"string","example":"HITL_APPROVE"}}}},"created_at":{"type":"string","format":"date-time"}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"Token nhận từ `POST /api/v1/auth/login`. Dùng cho nhân viên (BQL, kỹ thuật viên, bảo vệ)."},"IntegrationToken":{"type":"apiKey","in":"header","name":"X-Integration-Token","description":"Cho phần mềm quản lý tòa nhà."},"PartnerKey":{"type":"apiKey","in":"header","name":"X-Partner-Key","description":"Khóa đối tác `pk_…`, tạo ở **Kênh kết nối → Đối tác tích hợp**."},"AccessDeviceKey":{"type":"apiKey","in":"header","name":"X-Access-Device-Key","description":"Cho đầu đọc QR / barrier ở cổng."}},"responses":{"Unauthorized":{"description":"Thiếu hoặc sai thông tin xác thực","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"detail":{"code":"UNAUTHENTICATED","message":"Chưa đăng nhập"}}}}},"Forbidden":{"description":"Tài khoản không có quyền","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"detail":{"code":"FORBIDDEN","message":"Tài khoản không có quyền thực hiện thao tác này"}}}}}}},"servers":[{"url":"/","description":"Máy chủ hiện tại"},{"url":"http://localhost:8000","description":"Máy phát triển"}],"tags":[{"name":"Xác thực","description":"Đăng nhập lấy token và đọc thông tin tài khoản."},{"name":"Sự cố & điều phối","description":"Bảng điều hành, duyệt đơn, giao thợ, theo dõi tiến độ và SLA."},{"name":"Kỹ thuật viên","description":"Danh sách kỹ thuật viên và thông báo trong tài khoản của họ."},{"name":"Lịch bảo trì","description":"Lịch bảo trì tòa nhà. Porter dùng lịch này để trả lời cư dân và đối chiếu khi có phàn nàn."},{"name":"Lễ tân","description":"Mã khách, đặt tiện ích, yêu cầu chờ lễ tân duyệt, chỗ gửi xe, sổ ra vào."},{"name":"Kiểm soát ra vào","description":"Trang mã của khách, bảo vệ kiểm tra mã, đầu đọc QR ở cổng."},{"name":"Cư dân & tòa nhà","description":"Tòa nhà, căn hộ, cư dân và nhập danh sách từ Excel."},{"name":"Nhóm Zalo","description":"Nhóm Zalo tòa nhà và xác nhận ghép thành viên nhóm với cư dân."},{"name":"Hội thoại","description":"Lịch sử hội thoại giữa cư dân và Porter."},{"name":"Không khí cư dân","description":"Chỉ số không khí, điểm nóng, cảnh báo và thông báo trấn an."},{"name":"Cảnh báo sớm cư dân","description":"Theo dõi nguồn tin cư dân, gom phản ánh thành sự việc, phát cảnh báo an toàn / vận hành / uy tín theo ngưỡng, xu hướng và duyệt kết quả phân tích. Chỉ ban quản lý; bật bằng cấu hình `resident_intelligence_enabled`."},{"name":"Nội quy (RAG)","description":"Tài liệu nội quy mà Porter dùng để trả lời: tải lên, duyệt, xuất bản, quay lui."},{"name":"Kênh nhắn tin","description":"Trạng thái kênh, kết nối Zalo OA, quản lý đối tác dùng Partner API."},{"name":"Partner API","description":"Đưa Porter vào app / web sẵn có của tòa nhà: gửi tin của người dùng, nhận trả lời qua webhook hoặc polling. Xác thực bằng `X-Partner-Key`, chỉ gọi từ máy chủ."},{"name":"Tích hợp hệ thống tòa nhà","description":"Cho phần mềm quản lý / kiểm soát ra vào của tòa nhà: đồng bộ căn hộ, kéo ticket, báo lượt khách vào cổng. Xác thực bằng `X-Integration-Token`."},{"name":"Demo","description":"Công cụ giả lập cho môi trường thử nghiệm — chỉ có khi `DEMO_MODE=true`."},{"name":"Hệ thống","description":"Kiểm tra tình trạng dịch vụ."}],"x-tagGroups":[{"name":"Bắt đầu","tags":["Xác thực"]},{"name":"Vận hành","tags":["Sự cố & điều phối","Kỹ thuật viên","Lịch bảo trì"]},{"name":"Lễ tân","tags":["Lễ tân","Kiểm soát ra vào"]},{"name":"Cư dân","tags":["Cư dân & tòa nhà","Nhóm Zalo","Hội thoại","Không khí cư dân","Cảnh báo sớm cư dân","Nội quy (RAG)"]},{"name":"Kênh & tích hợp","tags":["Kênh nhắn tin","Partner API","Tích hợp hệ thống tòa nhà"]},{"name":"Khác","tags":["Demo","Hệ thống"]}],"webhooks":{"ticket":{"post":{"summary":"Ticket thay đổi","description":"Gửi tới địa chỉ webhook đã đăng ký với Porter mỗi khi đơn được tạo hoặc đổi trạng thái, thợ, giờ hẹn, mức ưu tiên. Ký bằng webhook secret của hệ thống tòa nhà.","parameters":[{"name":"X-Porter-Event","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-Porter-Event-Id","in":"header","required":true,"schema":{"type":"string"},"description":"Dùng để chống xử lý trùng"},{"name":"X-Porter-Timestamp","in":"header","required":true,"schema":{"type":"string"},"description":"Thời điểm ký, Unix giây"},{"name":"X-Porter-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`sha256=` + HMAC-SHA256(secret, `<timestamp>.<body>`)"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TicketEvent"}}}},"responses":{"2XX":{"description":"Đã nhận. Mã khác hoặc quá 10 giây thì Porter gửi lại."}}}},"guest_pass":{"post":{"summary":"Mã khách thay đổi","description":"Gửi tới hệ thống kiểm soát ra vào khi mã khách được tạo, bị hủy, hoặc khách vào cổng lần đầu — để hệ thống đó tự cấp quyền. Cùng địa chỉ và secret với webhook ticket.","parameters":[{"name":"X-Porter-Event","in":"header","required":true,"schema":{"type":"string"}},{"name":"X-Porter-Event-Id","in":"header","required":true,"schema":{"type":"string"},"description":"Dùng để chống xử lý trùng"},{"name":"X-Porter-Timestamp","in":"header","required":true,"schema":{"type":"string"},"description":"Thời điểm ký, Unix giây"},{"name":"X-Porter-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`sha256=` + HMAC-SHA256(secret, `<timestamp>.<body>`)"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GuestPassEvent"}}}},"responses":{"2XX":{"description":"Đã nhận. Mã khác hoặc quá 10 giây thì Porter gửi lại."}}}},"partner_reply":{"post":{"summary":"Tin trả lời cho đối tác","description":"Gửi tới `webhook_url` của đối tác mỗi khi Porter trả lời người dùng. Ký bằng webhook secret của đối tác. Webhook lỗi thì vẫn lấy được bằng `GET /api/v1/partner/messages`.","parameters":[{"name":"X-Porter-Timestamp","in":"header","required":true,"schema":{"type":"string"},"description":"Thời điểm ký, Unix giây"},{"name":"X-Porter-Signature","in":"header","required":true,"schema":{"type":"string"},"description":"`sha256=` + HMAC-SHA256(secret, `<timestamp>.<body>`)"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerReply"}}}},"responses":{"2XX":{"description":"Đã nhận. Mã khác hoặc quá 10 giây thì Porter gửi lại."}}}}}}