{"openapi":"3.1.0","info":{"title":"Tầm Long API","version":"1.0.0","description":"REST API của nền tảng thẩm định bất động sản theo Phong Thủy **Tầm Long**.\n\nMọi endpoint nằm dưới tiền tố `/api` (frontend Next.js proxy cùng origin qua `/api/:path*`).\n\nMọi thao tác ghi (`POST`, `PUT`, `PATCH`, `DELETE`) yêu cầu header `Origin` khớp `WEB_ORIGIN` và không chấp nhận `Sec-Fetch-Site` chéo trang (trừ webhook `/api/ai/callback` ký HMAC-SHA256)."},"servers":[{"url":"/api","description":"Same-origin API prefix (Next.js rewrite hoặc host API)"}],"tags":[{"name":"Hệ thống","description":"Kiểm tra sức khỏe dịch vụ và tài liệu OpenAPI."},{"name":"Xác thực & Phiên","description":"Đăng ký, đăng nhập, đổi/đặt lại mật khẩu và quản lý phiên đăng nhập theo chuẩn OWASP."},{"name":"Không gian làm việc","description":"Thông tin gói, hạn mức tín dụng AI, chuyển workspace và quản lý thành viên."},{"name":"Lời mời","description":"Xem thông tin và chấp nhận lời mời tham gia workspace."},{"name":"Cư dân","description":"Hồ sơ người ở / chủ doanh nghiệp kèm tính toán Mệnh Quái theo tiết Lập Xuân."},{"name":"Bất động sản","description":"Hồ sơ nhà đất, đặc trưng môi trường (Chính Thần / Linh Thần) và mục Sát Khí."},{"name":"Tệp đính kèm","description":"Tải lên ảnh hiện trường, bản vẽ mặt bằng và truy xuất tệp có kiểm soát hoặc URL ký ngắn hạn."},{"name":"Báo cáo thẩm định","description":"Lập, lưu trữ và bật/tắt chia sẻ báo cáo chấm điểm Phong Thủy."},{"name":"Báo cáo công khai","description":"Truy cập báo cáo chia sẻ đã lược bỏ dữ liệu nhạy cảm."},{"name":"Tác vụ AI & Cố vấn","description":"Tác vụ AI bất đồng bộ (ảnh, mặt bằng, diễn giải), webhook callback HMAC và hội thoại cố vấn SSE."},{"name":"Gói cước & Quản trị","description":"Bảng giá, đơn nâng cấp gói và bảng điều khiển quản trị hệ thống."}],"components":{"securitySchemes":{"sessionCookie":{"type":"apiKey","in":"cookie","name":"tl_session","description":"Cookie phiên HttpOnly SameSite=Lax (dùng tiền tố `__Host-tl_session` khi `COOKIE_SECURE=true`)."},"hmacSignature":{"type":"apiKey","in":"header","name":"X-Signature","description":"Chữ ký webhook AI: `t=<unix_seconds>,v1=<hex(HMAC_SHA256(AI_CALLBACK_SECRET, \"${t}.${rawBody}\"))>`, lệch giờ tối đa 300 giây."}},"schemas":{"OkResponse":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean","example":true}}},"ErrorResponse":{"type":"object","required":["statusCode","message"],"properties":{"statusCode":{"type":"integer","example":400},"message":{"type":"string","example":"Dữ liệu không hợp lệ"},"issues":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"}}}}}},"RegisterInput":{"type":"object","required":["email","password","name"],"properties":{"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","minLength":10,"maxLength":200},"name":{"type":"string","minLength":1,"maxLength":120}}},"LoginInput":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string","minLength":1,"maxLength":200},"remember":{"type":"boolean","default":false,"description":"true: tối đa 30 ngày / idle 7 ngày; false: 24 giờ / idle 2 giờ."}}},"PasswordChangeInput":{"type":"object","required":["current","password"],"properties":{"current":{"type":"string","maxLength":200},"password":{"type":"string","minLength":10,"maxLength":200}}},"PasswordResetInput":{"type":"object","required":["token","password"],"properties":{"token":{"type":"string","minLength":20,"maxLength":100},"password":{"type":"string","minLength":10,"maxLength":200}}},"SessionInfo":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"ip":{"type":["string","null"]},"userAgent":{"type":["string","null"]},"remember":{"type":"boolean"},"lastActiveAt":{"type":"string","format":"date-time"},"expiresAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"current":{"type":"boolean"}}},"InviteCreateInput":{"type":"object","required":["email","role"],"properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["ADMIN","MEMBER","VIEWER"]}}},"PersonInput":{"type":"object","required":["name","gender","birthDate"],"properties":{"name":{"type":"string","minLength":1,"maxLength":120},"gender":{"type":"string","enum":["MALE","FEMALE"]},"birthDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"Ngày sinh dương lịch YYYY-MM-DD (từ 1900-03-01)."},"birthTime":{"type":["string","null"],"pattern":"^([01]\\d|2[0-3]):[0-5]\\d$","description":"Giờ sinh HH:mm (quan trọng khi sinh sát tiết Lập Xuân)."},"note":{"type":["string","null"],"maxLength":2000}}},"MissingCorner":{"type":"object","required":["sector","pct"],"properties":{"sector":{"type":"string","enum":["N","NE","E","SE","S","SW","W","NW"]},"pct":{"type":"number","minimum":0,"maximum":100}}},"PropertyInput":{"type":"object","required":["name","type"],"properties":{"name":{"type":"string","minLength":1,"maxLength":160},"type":{"type":"string","enum":["LANDED","APARTMENT","COMMERCIAL","LAND"]},"address":{"type":["string","null"],"maxLength":400},"lat":{"type":["number","null"],"minimum":-90,"maximum":90},"lng":{"type":["number","null"],"minimum":-180,"maximum":180},"priceVnd":{"type":["integer","null"],"minimum":0},"areaM2":{"type":["number","null"],"minimum":0},"facingDeg":{"type":["number","null"],"minimum":0,"maximum":360},"doorDeg":{"type":["number","null"],"minimum":0,"maximum":360},"floorLabel":{"type":["string","null"],"maxLength":10},"firstOccupiedOn":{"type":["string","null"],"pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"entranceLevel":{"type":["string","null"],"enum":["ABOVE","SAME","SLIGHTLY_BELOW","FAR_BELOW",null]},"rearLower":{"type":["boolean","null"]},"missing":{"type":["array","null"],"maxItems":8,"items":{"$ref":"#/components/schemas/MissingCorner"}},"hasDepartments":{"type":["boolean","null"]},"environmentSurveyed":{"type":"boolean","default":false},"shaSurveyed":{"type":"boolean","default":false},"note":{"type":["string","null"],"maxLength":5000}}},"FeatureInput":{"type":"object","required":["kind","bearingDeg"],"properties":{"kind":{"type":"string","enum":["RIVER","CONFLUENCE","SEA","LAKE","POOL","FISH_POND","DRAIN","ROUNDABOUT","JUNCTION","BRIDGE","ROAD_INCOMING","OPEN_SPACE","MOUNTAIN_GREEN","MOUNTAIN_ROCKY","HIGH_GROUND"]},"bearingDeg":{"type":"number","minimum":0,"maximum":360},"distanceM":{"type":["number","null"],"minimum":0,"maximum":200000},"lat":{"type":["number","null"],"minimum":-90,"maximum":90},"lng":{"type":["number","null"],"minimum":-180,"maximum":180},"visible":{"type":"boolean","default":true},"clean":{"type":["string","null"],"enum":["CLEAN","DIRTY",null]},"speed":{"type":["string","null"],"enum":["SLOW","FAST",null]},"flow":{"type":["string","null"],"enum":["TOWARD","AWAY",null]},"shape":{"type":["string","null"],"enum":["WATER","WOOD","FIRE","EARTH","METAL",null]},"layers":{"type":["integer","null"],"minimum":1,"maximum":20},"note":{"type":["string","null"],"maxLength":1000}}},"ShaInput":{"type":"object","required":["code"],"properties":{"code":{"type":"string","enum":["POWER_PYLON","WATER_TOWER","CONSTRUCTION","SKY_CUT","RAILWAY","HIGHWAY","SHARP_ROOF","SATELLITE_DISH","ANTENNA","T_JUNCTION","STRAIGHT_ROAD","PIERCING_HEART","POLE_NEAR_HOUSE","DEAD_TREE","TREE_BLOCKING","REVERSE_BOW","CUTTING_FEET","PIERCING_SHOULDER","PULLING_NOSE","UNDERGROUND_WATER","FAST_WATER","MOUNTAIN_TOO_CLOSE","HILLTOP","LIFT_FACING_DOOR","EXTERNAL_CORNER","DOOR_INNER_CORNER","DOOR_BEAM","DOOR_TO_BACK_DOOR","BED_UNDER_BEAM","BED_FACING_DOOR","BED_AGAINST_WINDOW","ROOM_DOOR_CORNER","SLOPED_CEILING","FAN_OVER_HEAD","STOVE_FACING_DOOR","STOVE_UNDER_BEAM","STOVE_FACING_SINK","STOVE_NEAR_SINK","ISLAND_STOVE","STOVE_NW"]},"bearingDeg":{"type":["number","null"],"minimum":0,"maximum":360},"distanceM":{"type":["number","null"],"minimum":0,"maximum":200000},"visible":{"type":"boolean","default":true},"mitigated":{"type":"boolean","default":false},"fallsOnHouse":{"type":["boolean","null"]},"floorsAbove":{"type":["integer","null"],"minimum":-100,"maximum":100},"note":{"type":["string","null"],"maxLength":1000}}},"AssessmentCreateInput":{"type":"object","required":["propertyId","purpose","people"],"properties":{"propertyId":{"type":"string","format":"uuid"},"purpose":{"type":"string","enum":["RESIDENCE","BUSINESS","INVESTMENT"]},"people":{"type":"array","maxItems":20,"items":{"type":"object","required":["id","role"],"properties":{"id":{"type":"string","format":"uuid"},"role":{"type":"string","enum":["HEAD","MEMBER","EXECUTIVE"]}}}}}},"AiJobCreateInput":{"oneOf":[{"type":"object","required":["type","fileId"],"properties":{"type":{"const":"SITE_PHOTO"},"fileId":{"type":"string","format":"uuid"}}},{"type":"object","required":["type","fileId"],"properties":{"type":{"const":"FLOORPLAN"},"fileId":{"type":"string","format":"uuid"}}},{"type":"object","required":["type","assessmentId"],"properties":{"type":{"const":"NARRATIVE"},"assessmentId":{"type":"string","format":"uuid"}}}]},"AiCallbackInput":{"type":"object","required":["job_id","status"],"properties":{"job_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["queued","running","succeeded","failed"]},"result":{"type":"object","description":"SitePhotoResult | FloorplanResult | NarrativeResult"},"error":{"type":["string","null"],"maxLength":2000}}},"OrderCreateInput":{"type":"object","required":["plan","months"],"properties":{"plan":{"type":"string","enum":["PRO","AGENCY"]},"months":{"type":"integer","enum":[1,6,12],"description":"Mua 12 tháng được tính tiền 10 tháng."}}},"PlansResponse":{"type":"object","properties":{"plans":{"type":"object","example":{"FREE":{"name":"Miễn phí","priceVnd":0,"properties":3,"members":1,"credits":10},"PRO":{"name":"Chuyên nghiệp","priceVnd":299000,"properties":50,"members":3,"credits":200},"AGENCY":{"name":"Đại lý","priceVnd":990000,"properties":1000,"members":15,"credits":1000}}},"costs":{"type":"object","example":{"CHAT":1,"SITE_PHOTO":2,"FLOORPLAN":3,"NARRATIVE":3}}}}}},"paths":{"/health":{"get":{"security":[],"tags":["Hệ thống"],"summary":"Kiểm tra kết nối API và PostgreSQL","x-access":"PUBLIC","responses":{"200":{"description":"API và database hoạt động bình thường","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/openapi.json":{"get":{"security":[],"tags":["Hệ thống"],"summary":"Lấy đặc tả OpenAPI 3.1.0 dạng JSON","x-access":"PUBLIC","responses":{"200":{"description":"Tài liệu OpenAPI 3.1.0","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/docs":{"get":{"security":[],"tags":["Hệ thống"],"summary":"Trang tài liệu API HTML độc lập từ backend","x-access":"PUBLIC","responses":{"200":{"description":"Trang HTML hiển thị OpenAPI 3.1","content":{"text/html":{"schema":{"type":"string"}}}}}}},"/auth/register":{"post":{"security":[],"tags":["Xác thực & Phiên"],"summary":"Đăng ký tài khoản mới và tạo workspace cá nhân","description":"Kiểm tra độ mạnh mật khẩu, tự tạo workspace đầu tiên với quyền OWNER và cấp cookie phiên HttpOnly.","x-access":"PUBLIC","x-rateLimit":"10 req / phút","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterInput"},"example":{"email":"user@example.com","password":"mat-khau-an-toan-2026","name":"Nguyễn Văn A"}}}},"responses":{"201":{"description":"Đã tạo tài khoản và đặt cookie phiên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Email đã được đăng ký","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/login":{"post":{"security":[],"tags":["Xác thực & Phiên"],"summary":"Đăng nhập và cấp cookie phiên mới","description":"Hủy phiên cũ (chống session fixation), giới hạn tối đa 10 phiên hoạt động/tài khoản, tự khóa 15 phút sau 8 lần nhập sai liên tiếp.","x-access":"PUBLIC","x-rateLimit":"10 req / phút","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginInput"},"example":{"email":"demo@tamlong.local","password":"tamlong-demo-2026","remember":false}}}},"responses":{"200":{"description":"Đăng nhập thành công, đặt Set-Cookie","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Sai email hoặc mật khẩu","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Quá giới hạn hoặc tài khoản tạm khóa 15 phút","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/logout":{"post":{"security":[{"sessionCookie":[]}],"tags":["Xác thực & Phiên"],"summary":"Đăng xuất phiên hiện tại","x-access":"VIEWER","responses":{"200":{"description":"Đã hủy phiên và xóa cookie","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Chưa đăng nhập hoặc phiên đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Không đủ quyền hoặc sai Origin CSRF","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/forgot":{"post":{"security":[],"tags":["Xác thực & Phiên"],"summary":"Gửi liên kết đặt lại mật khẩu qua email","description":"Luôn trả `{ ok: true }` để tránh lộ sự tồn tại của email; áp dụng cooldown 2 phút giữa các lần gửi.","x-access":"PUBLIC","x-rateLimit":"10 req / phút","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email"],"properties":{"email":{"type":"string","format":"email"}}},"example":{"email":"user@example.com"}}}},"responses":{"200":{"description":"Yêu cầu đã được ghi nhận","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/auth/reset":{"post":{"security":[],"tags":["Xác thực & Phiên"],"summary":"Đặt lại mật khẩu bằng token một lần","description":"Xác thực token 1 giờ, cập nhật mật khẩu, mở khóa tài khoản và hủy toàn bộ phiên cũ.","x-access":"PUBLIC","x-rateLimit":"10 req / phút","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordResetInput"},"example":{"token":"0123456789abcdef0123456789abcdef","password":"mat-khau-moi-2026"}}}},"responses":{"200":{"description":"Đã đặt lại mật khẩu","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/password":{"post":{"security":[{"sessionCookie":[]}],"tags":["Xác thực & Phiên"],"summary":"Đổi mật khẩu và xoay vòng cookie phiên","description":"Thu hồi toàn bộ phiên trên mọi thiết bị khác và cấp lại cookie phiên mới cho trình duyệt hiện tại.","x-access":"VIEWER","x-rateLimit":"10 req / phút","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordChangeInput"},"example":{"current":"mat-khau-cu-2026","password":"mat-khau-moi-2026"}}}},"responses":{"200":{"description":"Đã đổi mật khẩu và xoay phiên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Chưa đăng nhập hoặc phiên đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/me":{"get":{"security":[{"sessionCookie":[]}],"tags":["Xác thực & Phiên"],"summary":"Lấy thông tin người dùng, vai trò và danh sách workspace","x-access":"VIEWER","responses":{"200":{"description":"Thông tin tài khoản hiện tại","content":{"application/json":{"schema":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"name":{"type":"string"},"isPlatformAdmin":{"type":"boolean"}}},"role":{"type":"string","enum":["OWNER","ADMIN","MEMBER","VIEWER"]},"workspace":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}},"workspaces":{"type":"array","items":{"type":"object"}}}}}}},"401":{"description":"Chưa đăng nhập hoặc phiên đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/sessions":{"get":{"security":[{"sessionCookie":[]}],"tags":["Xác thực & Phiên"],"summary":"Liệt kê các phiên đăng nhập đang hoạt động của tài khoản","x-access":"VIEWER","responses":{"200":{"description":"Danh sách phiên còn hiệu lực","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SessionInfo"}}}}},"401":{"description":"Chưa đăng nhập hoặc phiên đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/sessions/revoke-others":{"post":{"security":[{"sessionCookie":[]}],"tags":["Xác thực & Phiên"],"summary":"Đăng xuất toàn bộ thiết bị khác, giữ lại phiên hiện tại","x-access":"VIEWER","responses":{"200":{"description":"Đã thu hồi các phiên khác","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Chưa đăng nhập hoặc phiên đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Không đủ quyền hoặc sai Origin CSRF","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/auth/sessions/{id}":{"delete":{"security":[{"sessionCookie":[]}],"tags":["Xác thực & Phiên"],"summary":"Thu hồi một phiên đăng nhập cụ thể theo ID","x-access":"VIEWER","parameters":[{"name":"id","in":"path","required":true,"description":"ID phiên đăng nhập","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã thu hồi phiên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"404":{"description":"Không tìm thấy phiên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/workspace":{"get":{"security":[{"sessionCookie":[]}],"tags":["Không gian làm việc"],"summary":"Xem thông tin workspace hiện tại, gói cước và mức sử dụng","x-access":"VIEWER","responses":{"200":{"description":"Thông tin workspace, hạn mức và số lượng đã dùng","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Chưa đăng nhập hoặc phiên đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"security":[{"sessionCookie":[]}],"tags":["Không gian làm việc"],"summary":"Đổi tên workspace hiện tại","x-access":"ADMIN","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":1,"maxLength":120}}},"example":{"name":"Văn phòng Tầm Long Hà Nội"}}}},"responses":{"200":{"description":"Đã đổi tên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"403":{"description":"Không đủ quyền hoặc sai Origin CSRF","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/workspace/switch/{id}":{"post":{"security":[{"sessionCookie":[]}],"tags":["Không gian làm việc"],"summary":"Chuyển phiên hiện tại sang một workspace khác mà người dùng tham gia","x-access":"VIEWER","parameters":[{"name":"id","in":"path","required":true,"description":"ID workspace đích","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã chuyển workspace","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"404":{"description":"Không tìm thấy workspace","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/workspace/members":{"get":{"security":[{"sessionCookie":[]}],"tags":["Không gian làm việc"],"summary":"Liệt kê thành viên và lời mời đang chờ của workspace","x-access":"VIEWER","responses":{"200":{"description":"Danh sách members và invites","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/workspace/invites":{"post":{"security":[{"sessionCookie":[]}],"tags":["Không gian làm việc"],"summary":"Mời thành viên mới vào workspace (hạn 7 ngày)","x-access":"ADMIN","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteCreateInput"},"example":{"email":"colleague@example.com","role":"MEMBER"}}}},"responses":{"201":{"description":"Liên kết mời vừa tạo","content":{"application/json":{"schema":{"type":"object","properties":{"link":{"type":"string","format":"uri"}}}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Không đủ quyền hoặc sai Origin CSRF","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/workspace/invites/{id}":{"delete":{"security":[{"sessionCookie":[]}],"tags":["Không gian làm việc"],"summary":"Hủy một lời mời đang chờ","x-access":"ADMIN","parameters":[{"name":"id","in":"path","required":true,"description":"ID lời mời","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã hủy lời mời","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/workspace/members/{id}":{"delete":{"security":[{"sessionCookie":[]}],"tags":["Không gian làm việc"],"summary":"Xóa thành viên khỏi workspace (không thể xóa OWNER)","x-access":"ADMIN","parameters":[{"name":"id","in":"path","required":true,"description":"User ID của thành viên","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa thành viên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Không tìm thấy thành viên","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/invites/{token}":{"get":{"security":[],"tags":["Lời mời"],"summary":"Xem trước thông tin lời mời công khai bằng token","x-access":"PUBLIC","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"},"description":"Token từ đường dẫn /moi/{token}"}],"responses":{"200":{"description":"Email, quyền và tên workspace","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Lời mời không hợp lệ hoặc đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/invites/{token}/accept":{"post":{"security":[{"sessionCookie":[]}],"tags":["Lời mời"],"summary":"Chấp nhận lời mời và chuyển sang workspace mới","x-access":"VIEWER","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"},"description":"Token lời mời"}],"responses":{"200":{"description":"Đã tham gia workspace","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Lời mời không hợp lệ hoặc đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/people":{"get":{"security":[{"sessionCookie":[]}],"tags":["Cư dân"],"summary":"Danh sách cư dân trong workspace kèm Mệnh Quái đã tính","x-access":"VIEWER","responses":{"200":{"description":"Danh sách cư dân + kuaProfile","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}}}},"post":{"security":[{"sessionCookie":[]}],"tags":["Cư dân"],"summary":"Tạo hồ sơ cư dân mới","x-access":"MEMBER","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonInput"},"example":{"name":"Trần Minh An","gender":"MALE","birthDate":"1990-06-15","birthTime":null,"note":"Trạch chủ"}}}},"responses":{"201":{"description":"Hồ sơ cư dân + kua","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/people/{id}":{"put":{"security":[{"sessionCookie":[]}],"tags":["Cư dân"],"summary":"Cập nhật hồ sơ cư dân","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID cư dân","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonInput"},"example":{"name":"Trần Minh An","gender":"MALE","birthDate":"1990-06-15","birthTime":"09:30"}}}},"responses":{"200":{"description":"Hồ sơ đã cập nhật + kua","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"security":[{"sessionCookie":[]}],"tags":["Cư dân"],"summary":"Xóa hồ sơ cư dân","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID cư dân","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/properties":{"get":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Danh sách bất động sản kèm bản thẩm định mới nhất","x-access":"VIEWER","responses":{"200":{"description":"Danh sách bất động sản","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}}}},"post":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Tạo hồ sơ bất động sản mới (kiểm tra hạn mức gói)","x-access":"MEMBER","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PropertyInput"},"example":{"name":"Căn hộ ven Hồ Tây","type":"APARTMENT","address":"Quận Tây Hồ, Hà Nội","facingDeg":350,"firstOccupiedOn":"2025-03-01"}}}},"responses":{"201":{"description":"Bất động sản vừa tạo","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"402":{"description":"Vượt hạn mức gói cước","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/properties/{id}":{"get":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Chi tiết bất động sản kèm đặc trưng môi trường, Sát Khí và tệp đính kèm","x-access":"VIEWER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Chi tiết đầy đủ bất động sản","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Không tìm thấy bất động sản","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Cập nhật toàn bộ thông tin bất động sản","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PropertyInput"},"example":{"name":"Căn hộ ven Hồ Tây","type":"APARTMENT","facingDeg":350,"environmentSurveyed":true,"shaSurveyed":true}}}},"responses":{"200":{"description":"Bất động sản đã cập nhật","content":{"application/json":{"schema":{"type":"object"}}}}}},"delete":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Xóa bất động sản, toàn bộ khảo sát, tệp lưu trữ và báo cáo liên quan","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa bất động sản","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/properties/{id}/features":{"post":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Thêm đặc trưng môi trường (Sơn / Thủy) cho bất động sản","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeatureInput"},"example":{"kind":"LAKE","bearingDeg":350,"distanceM":140,"visible":true,"clean":"CLEAN","speed":"SLOW"}}}},"responses":{"201":{"description":"Đặc trưng vừa thêm","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/properties/{id}/features/{fid}":{"put":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Cập nhật đặc trưng môi trường","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}},{"name":"fid","in":"path","required":true,"description":"ID đặc trưng","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeatureInput"},"example":{"kind":"LAKE","bearingDeg":352,"distanceM":140,"visible":true}}}},"responses":{"200":{"description":"Đặc trưng đã cập nhật","content":{"application/json":{"schema":{"type":"object"}}}}}},"delete":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Xóa đặc trưng môi trường","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}},{"name":"fid","in":"path","required":true,"description":"ID đặc trưng","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa đặc trưng","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/properties/{id}/sha":{"post":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Thêm mục Sát Khí (ngoại cục hoặc nội cục)","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShaInput"},"example":{"code":"T_JUNCTION","bearingDeg":180,"distanceM":35,"visible":true,"mitigated":false}}}},"responses":{"201":{"description":"Mục Sát Khí vừa thêm","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/properties/{id}/sha/{sid}":{"put":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Cập nhật mục Sát Khí","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}},{"name":"sid","in":"path","required":true,"description":"ID mục Sát Khí","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShaInput"},"example":{"code":"T_JUNCTION","bearingDeg":180,"distanceM":35,"visible":true,"mitigated":true}}}},"responses":{"200":{"description":"Mục Sát Khí đã cập nhật","content":{"application/json":{"schema":{"type":"object"}}}}}},"delete":{"security":[{"sessionCookie":[]}],"tags":["Bất động sản"],"summary":"Xóa mục Sát Khí","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}},{"name":"sid","in":"path","required":true,"description":"ID mục Sát Khí","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa mục Sát Khí","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/properties/{id}/files":{"post":{"security":[{"sessionCookie":[]}],"tags":["Tệp đính kèm"],"summary":"Tải lên ảnh hiện trường hoặc bản vẽ mặt bằng (tối đa 10 MB)","description":"Gửi `multipart/form-data` gồm `file` (JPG, PNG, WebP; riêng `FLOORPLAN` nhận thêm PDF), `kind` (`PHOTO` | `FLOORPLAN`) và tùy chọn `bearingDeg`.","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file","kind"],"properties":{"file":{"type":"string","format":"binary"},"kind":{"type":"string","enum":["PHOTO","FLOORPLAN"]},"bearingDeg":{"type":["number","null"],"minimum":0,"maximum":360}}}}}},"responses":{"201":{"description":"Metadata tệp vừa tải lên","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/properties/{id}/files/{fid}":{"delete":{"security":[{"sessionCookie":[]}],"tags":["Tệp đính kèm"],"summary":"Xóa tệp đính kèm khỏi bất động sản và ổ lưu trữ","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID bất động sản","schema":{"type":"string","format":"uuid"}},{"name":"fid","in":"path","required":true,"description":"ID tệp","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa tệp","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/files/{id}":{"get":{"security":[{"sessionCookie":[]}],"tags":["Tệp đính kèm"],"summary":"Tải/xem tệp thuộc workspace hiện tại","x-access":"VIEWER","parameters":[{"name":"id","in":"path","required":true,"description":"ID tệp","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Luồng nhị phân của tệp kèm CSP sandbox"},"404":{"description":"Không tìm thấy file","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/files/{id}/signed":{"get":{"security":[],"tags":["Tệp đính kèm"],"summary":"Truy cập tệp bằng URL có chữ ký HMAC ngắn hạn (dành cho AI service)","x-access":"PUBLIC","parameters":[{"name":"id","in":"path","required":true,"description":"ID tệp","schema":{"type":"string","format":"uuid"}},{"name":"exp","in":"query","required":true,"schema":{"type":"integer"},"description":"Unix timestamp hết hạn (giây)"},{"name":"sig","in":"query","required":true,"schema":{"type":"string"},"description":"HMAC-SHA256 của `${id}.${exp}`"}],"responses":{"200":{"description":"Luồng nhị phân của tệp"},"401":{"description":"Chưa đăng nhập hoặc phiên đã hết hạn","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/assessments":{"get":{"security":[{"sessionCookie":[]}],"tags":["Báo cáo thẩm định"],"summary":"Danh sách báo cáo thẩm định trong workspace (tối đa 200 bản mới nhất)","x-access":"VIEWER","parameters":[{"name":"propertyId","in":"query","required":false,"schema":{"type":"string","format":"uuid"},"description":"Lọc theo một bất động sản cụ thể"}],"responses":{"200":{"description":"Danh sách báo cáo","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}}}},"post":{"security":[{"sessionCookie":[]}],"tags":["Báo cáo thẩm định"],"summary":"Chạy engine @tamlong/core và lưu bản chụp báo cáo thẩm định","x-access":"MEMBER","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssessmentCreateInput"},"example":{"propertyId":"00000000-0000-0000-0000-000000000000","purpose":"RESIDENCE","people":[]}}}},"responses":{"201":{"description":"ID báo cáo vừa lưu","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"}}}}}}}}},"/assessments/{id}":{"get":{"security":[{"sessionCookie":[]}],"tags":["Báo cáo thẩm định"],"summary":"Chi tiết báo cáo thẩm định kèm bài diễn giải AI mới nhất (nếu có)","x-access":"VIEWER","parameters":[{"name":"id","in":"path","required":true,"description":"ID báo cáo","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Chi tiết báo cáo + narrative","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Không tìm thấy báo cáo","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"security":[{"sessionCookie":[]}],"tags":["Báo cáo thẩm định"],"summary":"Xóa báo cáo thẩm định","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID báo cáo","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa báo cáo","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/assessments/{id}/share":{"post":{"security":[{"sessionCookie":[]}],"tags":["Báo cáo thẩm định"],"summary":"Bật chia sẻ công khai và lấy shareToken cho báo cáo","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID báo cáo","schema":{"type":"string","format":"uuid"}}],"responses":{"201":{"description":"Mã chia sẻ công khai","content":{"application/json":{"schema":{"type":"object","properties":{"shareToken":{"type":"string"}}}}}}}},"delete":{"security":[{"sessionCookie":[]}],"tags":["Báo cáo thẩm định"],"summary":"Tắt liên kết chia sẻ công khai của báo cáo","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID báo cáo","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã ngừng chia sẻ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/public/reports/{token}":{"get":{"security":[],"tags":["Báo cáo công khai"],"summary":"Xem báo cáo chia sẻ công khai (đã ẩn ngày giờ sinh, tọa độ, giá và ghi chú)","x-access":"PUBLIC","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"},"description":"shareToken của báo cáo"}],"responses":{"200":{"description":"Dữ liệu báo cáo đã lược bỏ thông tin cá nhân","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Báo cáo không tồn tại hoặc đã ngừng chia sẻ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/ai/costs":{"get":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Bảng chi phí tín dụng cho từng loại tác vụ AI","x-access":"VIEWER","responses":{"200":{"description":"Số tín dụng theo tác vụ","content":{"application/json":{"schema":{"type":"object","example":{"CHAT":1,"SITE_PHOTO":2,"FLOORPLAN":3,"NARRATIVE":3}}}}}}}},"/ai/jobs":{"post":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Tạo tác vụ AI bất đồng bộ (SITE_PHOTO, FLOORPLAN, NARRATIVE)","description":"Trừ tín dụng nguyên tử trong giao dịch; tự hoàn tín dụng nếu tác vụ thất bại. Bấm trùng khi job đang chạy sẽ trả về job hiện có.","x-access":"MEMBER","x-rateLimit":"30 req / phút","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiJobCreateInput"},"example":{"type":"NARRATIVE","assessmentId":"00000000-0000-0000-0000-000000000000"}}}},"responses":{"201":{"description":"Trạng thái job AI","content":{"application/json":{"schema":{"type":"object"}}}},"402":{"description":"Hết tín dụng AI","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"get":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Danh sách tác vụ AI của một bất động sản","x-access":"VIEWER","parameters":[{"name":"propertyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"type","in":"query","required":false,"schema":{"type":"string","enum":["SITE_PHOTO","FLOORPLAN","NARRATIVE"]}}],"responses":{"200":{"description":"Danh sách job AI","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}}}}},"/ai/jobs/{id}":{"get":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Kiểm tra trạng thái và kết quả một tác vụ AI","x-access":"VIEWER","parameters":[{"name":"id","in":"path","required":true,"description":"ID tác vụ AI","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Chi tiết job AI","content":{"application/json":{"schema":{"type":"object"}}}},"404":{"description":"Không tìm thấy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/ai/callback":{"post":{"security":[{"hmacSignature":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Webhook nhận kết quả từ AI service (xác thực chữ ký HMAC-SHA256)","x-access":"WEBHOOK_HMAC","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiCallbackInput"},"example":{"job_id":"00000000-0000-0000-0000-000000000000","status":"succeeded","result":{}}}}},"responses":{"200":{"description":"Đã ghi nhận kết quả","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"401":{"description":"Chữ ký X-Signature không hợp lệ hoặc quá hạn 300s","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/conversations":{"get":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Danh sách cuộc trò chuyện với Cố vấn AI của người dùng hiện tại","x-access":"VIEWER","responses":{"200":{"description":"Danh sách hội thoại","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}}}},"post":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Tạo cuộc trò chuyện mới (hỏi chung hoặc gắn với một bất động sản)","x-access":"MEMBER","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"propertyId":{"type":["string","null"],"format":"uuid"}}},"example":{"propertyId":null}}}},"responses":{"201":{"description":"Cuộc trò chuyện vừa tạo","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/conversations/{id}":{"get":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Chi tiết cuộc trò chuyện kèm toàn bộ lịch sử tin nhắn","x-access":"VIEWER","parameters":[{"name":"id","in":"path","required":true,"description":"ID cuộc trò chuyện","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Hội thoại và mảng messages","content":{"application/json":{"schema":{"type":"object"}}}}}},"delete":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Xóa cuộc trò chuyện","x-access":"MEMBER","parameters":[{"name":"id","in":"path","required":true,"description":"ID cuộc trò chuyện","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã xóa cuộc trò chuyện","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/conversations/{id}/messages":{"post":{"security":[{"sessionCookie":[]}],"tags":["Tác vụ AI & Cố vấn"],"summary":"Gửi câu hỏi cho Cố vấn AI và nhận phản hồi luồng SSE","description":"Trả `text/event-stream` với các sự kiện: `delta` (`{\"text\":\"...\"}`), `citations` (`{\"citations\":[{\"page\":39,\"quote\":\"...\"}]}`), `done` (`{}`), `error` (`{\"message\":\"...\"}`).","x-access":"MEMBER","x-rateLimit":"20 req / phút","parameters":[{"name":"id","in":"path","required":true,"description":"ID cuộc trò chuyện","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["content"],"properties":{"content":{"type":"string","minLength":1,"maxLength":4000}}},"example":{"content":"Trong vận 9 nên đặt Thủy ở hướng nào?"}}}},"responses":{"200":{"description":"Luồng Server-Sent Events (delta, citations, done, error)","content":{"text/event-stream":{"schema":{"type":"string"}}}},"402":{"description":"Hết tín dụng AI","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"AI service không phản hồi (đã hoàn tín dụng nếu chưa trả nội dung)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/billing/plans":{"get":{"security":[],"tags":["Gói cước & Quản trị"],"summary":"Lấy danh sách gói cước (FREE, PRO, AGENCY) và bảng chi phí tín dụng AI","x-access":"PUBLIC","responses":{"200":{"description":"Cấu hình gói cước và tín dụng","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlansResponse"}}}}}}},"/billing/orders":{"get":{"security":[{"sessionCookie":[]}],"tags":["Gói cước & Quản trị"],"summary":"Lịch sử đơn hàng của workspace kèm thông tin tài khoản chuyển khoản","x-access":"VIEWER","responses":{"200":{"description":"Danh sách đơn và thông tin ngân hàng","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"security":[{"sessionCookie":[]}],"tags":["Gói cước & Quản trị"],"summary":"Tạo đơn nâng cấp hoặc gia hạn gói (tối đa 3 đơn chờ thanh toán)","x-access":"OWNER","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCreateInput"},"example":{"plan":"PRO","months":12}}}},"responses":{"201":{"description":"Đơn hàng vừa tạo kèm mã chuyển khoản TL*","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Dữ liệu đầu vào không hợp lệ","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/billing/orders/{id}/cancel":{"post":{"security":[{"sessionCookie":[]}],"tags":["Gói cước & Quản trị"],"summary":"Hủy một đơn hàng đang ở trạng thái PENDING","x-access":"OWNER","parameters":[{"name":"id","in":"path","required":true,"description":"ID đơn hàng","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã hủy đơn hàng","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}}}}},"/admin/overview":{"get":{"security":[{"sessionCookie":[]}],"tags":["Gói cước & Quản trị"],"summary":"Thống kê toàn hệ thống (người dùng, workspace, bất động sản, báo cáo, job lỗi, doanh thu)","x-access":"PLATFORM_ADMIN","responses":{"200":{"description":"Số liệu tổng quan hệ thống","content":{"application/json":{"schema":{"type":"object"}}}},"403":{"description":"Không đủ quyền hoặc sai Origin CSRF","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/admin/orders":{"get":{"security":[{"sessionCookie":[]}],"tags":["Gói cước & Quản trị"],"summary":"Danh sách tối đa 200 đơn hàng gần nhất trên toàn hệ thống","x-access":"PLATFORM_ADMIN","responses":{"200":{"description":"Danh sách đơn hàng toàn hệ thống","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"403":{"description":"Không đủ quyền hoặc sai Origin CSRF","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/admin/orders/{id}/paid":{"post":{"security":[{"sessionCookie":[]}],"tags":["Gói cước & Quản trị"],"summary":"Xác nhận đã nhận chuyển khoản và kích hoạt/cộng dồn thời hạn gói cho workspace","x-access":"PLATFORM_ADMIN","parameters":[{"name":"id","in":"path","required":true,"description":"ID đơn hàng","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Đã kích hoạt gói","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkResponse"}}}},"404":{"description":"Đơn không tồn tại hoặc đã xử lý","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}