{"openapi":"3.1.0","info":{"title":"khachhang.app API","version":"1.0.0","description":"Dữ liệu thị trường, giá, chỉ số kinh tế – tài chính và tin tức tiếng Việt cho doanh nghiệp và trợ lý AI.\n\n**Cấu trúc:** `/v1/<mảng>/<tài nguyên>` — news (tin tức) · real-estate (bất động sản: dự án, giá, giá đất) · finance (tài chính: lãi suất, lịch kinh tế, chỉ số) · bot (trợ lý AI) · account (tài khoản) · notify (thông báo). Mảng sắp có: agriculture (nông nghiệp — Nongdan.ai), vehicles (mua bán xe) — cùng kiểu.\n\n**Xác thực:** khoá API ở header `X-API-Key` (hoặc `Authorization: Bearer …`). `na_pk_…` công khai (chỉ đọc, kiểm Origin — dùng trên web) · `na_sk_…` máy chủ · `na_ak_…` quản trị tài khoản. Tạo khoá ở app.p2c.vn hoặc `POST /v1/account/keys`.\n\n**Dữ liệu:** mọi số liệu kèm nguồn và ngày của số liệu; giờ ISO +07:00; giá theo đồng. Tin tức là bản AI viết lại — luôn hiển thị kèm `sources_list` (tên báo + link gốc). Ảnh đại diện `image` lấy từ báo gốc, ghi nguồn theo `image_source` ({ name, url }); dùng `referrerpolicy=\"no-referrer\"`. Dữ liệu riêng của doanh nghiệp (giá đất theo khoá dữ liệu, rổ hàng, kiến thức) chỉ trả cho chính doanh nghiệp đó.\n\n**Giới hạn:** theo gói (60 – 3.000 lượt / phút); vượt trả 429 kèm `retry-after`. Cache biên 60 giây; dùng `If-None-Match` với `etag`.\n\n**Lỗi:** `{ ok: false, error: { code: \"<mã>\", message: \"…\" } }`."},"servers":[{"url":"https://api.p2c.vn"}],"tags":[{"name":"News","description":"Tin tức theo mảng ngành — AI tổng hợp từ nhiều báo, kèm nguồn"},{"name":"Sync","description":"Đồng bộ kiến thức, tin tức, sự kiện sang hệ thống của doanh nghiệp (website, app, bot) — phạm vi do khachhang.app cấp; con trỏ tăng dần, không sót; tín hiệu ping_url. Hướng dẫn: docs/api/sync.md"},{"name":"Real estate — Projects","description":"Dự án bất động sản + giá sơ cấp / thứ cấp / cho thuê (kho chung có đóng góp của doanh nghiệp, khachhang.app xác nhận). Lịch sử giá chỉ thêm mốc khi giá đổi, ngày = ngày của giá."},{"name":"Real estate — Land","description":"Giá đất theo tỉnh / phường / tuyến đường, lịch sử theo ngày. Dữ liệu theo khoá dữ liệu của doanh nghiệp (khoá máy chủ)."},{"name":"Biz","description":"Doanh nghiệp theo ngành (kho chung): bất động sản — sàn, văn phòng môi giới, đại lý, chủ đầu tư; nông nghiệp — hợp tác xã, thu mua, vật tư, chế biến… để tìm đối tác hợp tác. Khoá bí mật + tính năng biz. SĐT / email cá nhân chỉ dùng nội bộ, có cách từ chối."},{"name":"Marketing","description":"Thông tin quảng cáo: quảng cáo đang chạy trên Facebook / Instagram theo từ khoá hoặc fanpage (nội dung, ngày chạy, nền tảng, link) + thông tin trang (đơn vị quản lý, SĐT, địa chỉ, lịch sử) — theo dõi đối thủ, tìm đối tác. Khoá bí mật + tính năng ads; hạn mức chi phí tháng theo tài khoản."},{"name":"SEO","description":"SEO desk theo site (website của doanh nghiệp): khai báo site, chuyển đổi tổng hợp do site gửi; sắp có từ khoá / thứ hạng / SERP / đối thủ / AI nhắc tên / audit. Endpoint chưa có trả 404."},{"name":"Knowledge","description":"Kiến thức chuyên ngành theo mảng (bất động sản, nông nghiệp…) — AI nghiên cứu văn bản / nguồn chính thức, viết mới, AI duyệt; rà lại định kỳ. Chỉ dùng trong ứng dụng / trợ lý của doanh nghiệp, không đăng lại lên website."},{"name":"Vehicles","description":"Giá xe niêm yết của hãng (ô tô, xe máy) + lịch sử đổi giá + ước tính giá lăn bánh theo tỉnh"},{"name":"Finance","description":"Tài chính: lãi suất ngân hàng (đọc từ trang ngân hàng 4 lần / ngày), lịch kinh tế, chuỗi chỉ số, bối cảnh thị trường"},{"name":"Văn bản pháp luật","description":"Luật, nghị định, thông tư, quyết định… của nhà nước từ Cổng văn bản Chính phủ, AI gắn mảng + tóm tắt từ trích yếu; ngày ban hành / hiệu lực; link văn bản chính thức (không trả toàn văn)."},{"name":"Sự kiện","description":"Lịch sự kiện theo mảng tổng hợp từ tin tức + sự kiện riêng của doanh nghiệp + lễ tết âm lịch (tính năng riêng trong gói)."},{"name":"Lịch","description":"Lịch vạn niên, ngày tốt theo việc, cung mệnh, thần số học, cung hoàng đạo — mảng Phong thủy – Tâm linh (tính năng riêng trong gói). Tham khảo theo quan niệm dân gian."},{"name":"Bot","description":"Trợ lý AI theo thương hiệu doanh nghiệp (widget web, app, Zalo / Telegram)"},{"name":"Account","description":"Tài khoản doanh nghiệp: khoá API, webhook, khoá AI riêng, kiến thức, thực thể, lượt dùng"},{"name":"Notify","description":"Kênh thông báo: bot Zalo / Telegram, Discord, đẩy app"}],"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"X-API-Key","description":"na_pk_… · na_sk_… · na_ak_…"},"bearer":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","properties":{"ok":{"const":false},"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}}}}}},"responses":{"Bad":{"description":"Tham số sai","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"Thiếu / sai khoá API","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"Khoá không đủ quyền hoặc gói không gồm dữ liệu này","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"Vượt giới hạn tần suất / hạn mức tháng (header retry-after)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"security":[{"apiKey":[]},{"bearer":[]}],"paths":{"/v1/news/verticals":{"get":{"tags":["News"],"summary":"Danh sách mảng tin","description":"Các mảng khoá được đọc, kèm danh mục và loại tin.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/{vertical}/stories":{"get":{"tags":["News"],"summary":"Tin của một mảng","description":"Mới nhất trước; phân trang bằng cursor.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}},{"name":"category","in":"query","description":"danh mục","required":false,"schema":{"type":"string"}},{"name":"kind","in":"query","description":"loại tin","required":false,"schema":{"type":"string"}},{"name":"entity","in":"query","description":"thực thể (dự án, mã CK, tỉnh…)","required":false,"schema":{"type":"string"}},{"name":"label","in":"query","description":"nhãn phân loại chuẩn: chiều:mã[,mã] — lặp được (các chiều AND), vd label=tinh:ha-noi&label=loai-hinh:can-ho; chiều / mã xem /taxonomy","required":false,"schema":{"type":"string"}},{"name":"min","in":"query","description":"điểm tối thiểu","required":false,"schema":{"type":"integer"}},{"name":"since","in":"query","description":"từ thời điểm (ISO)","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 50","required":false,"schema":{"type":"integer"}},{"name":"cursor","in":"query","description":"trang kế","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/{vertical}/facets":{"get":{"tags":["News"],"summary":"Bộ lọc hay gặp (30 ngày)","description":"Danh mục, thực thể, thẻ, và `labels` (số tin theo từng chiều phân loại / giá trị) xuất hiện nhiều.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/vehicles":{"get":{"tags":["Vehicles"],"summary":"Nguồn giá xe","description":"Hãng, trang gốc, giờ kiểm / đổi, số dòng giá; not_covered = hãng chưa có nguồn chính thức.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/vehicles/prices":{"get":{"tags":["Vehicles"],"summary":"Bảng giá xe niêm yết","description":"Mỗi dòng: hãng, mẫu, phiên bản, màu, price (VND, gồm VAT), price_type (listed · from), promo, fuel, page, changed_at, checked_at.","parameters":[{"name":"segment","in":"query","description":"car · bike","required":false,"schema":{"type":"string"}},{"name":"brand","in":"query","description":"mã hãng, nhiều mã cách dấu phẩy (toyota,honda…)","required":false,"schema":{"type":"string"}},{"name":"fuel","in":"query","description":"xang · dau · hybrid · dien · phev","required":false,"schema":{"type":"string"}},{"name":"source","in":"query","description":"mã nguồn","required":false,"schema":{"type":"string"}},{"name":"min","in":"query","description":"giá tối thiểu (VND)","required":false,"schema":{"type":"integer"}},{"name":"max","in":"query","description":"giá tối đa (VND)","required":false,"schema":{"type":"integer"}},{"name":"q","in":"query","description":"tìm mẫu / phiên bản / màu","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 500","required":false,"schema":{"type":"integer"}},{"name":"offset","in":"query","description":"phân trang","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/vehicles/prices/{id}":{"get":{"tags":["Vehicles"],"summary":"Một dòng giá + lịch sử","description":"history: mỗi lần đổi (at, event new · price · promo · gone · back, price, prev_price, promo).","parameters":[{"name":"id","in":"path","required":true,"description":"id dòng giá","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/vehicles/changes":{"get":{"tags":["Vehicles"],"summary":"Thay đổi giá gần đây","description":"Đổi giá / ưu đãi, mẫu mới, mẫu gỡ — mới nhất trước, kèm diff.","parameters":[{"name":"days","in":"query","description":"≤ 365","required":false,"schema":{"type":"integer"}},{"name":"brand","in":"query","description":"mã hãng","required":false,"schema":{"type":"string"}},{"name":"segment","in":"query","description":"car · bike","required":false,"schema":{"type":"string"}},{"name":"event","in":"query","description":"new · price · promo · gone · back","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/vehicles/fees":{"get":{"tags":["Vehicles"],"summary":"Bảng phí lăn bánh","description":"Lệ phí trước bạ, biển số (khu vực I / II), phí đường bộ, bảo hiểm TNDS, đăng kiểm + 34 tỉnh / thành; mỗi mức kèm văn bản, ngày hiệu lực, verify (goc · thu-cap).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/vehicles/calc":{"get":{"tags":["Vehicles"],"summary":"Ước tính giá lăn bánh","description":"lines (khoản, số tiền, văn bản căn cứ), total, notes. Ước tính — chưa gồm phí dịch vụ đại lý, bảo hiểm vật chất.","parameters":[{"name":"price","in":"query","description":"giá xe (VND) — hoặc id","required":false,"schema":{"type":"integer"}},{"name":"id","in":"query","description":"id dòng giá (/v1/vehicles/prices)","required":false,"schema":{"type":"string"}},{"name":"province","in":"query","description":"mã hoặc tên tỉnh / thành","required":false,"schema":{"type":"string"}},{"name":"segment","in":"query","description":"car · bike","required":false,"schema":{"type":"string"}},{"name":"fuel","in":"query","description":"dien = ô tô điện chạy pin","required":false,"schema":{"type":"string"}},{"name":"seats","in":"query","description":"số chỗ","required":false,"schema":{"type":"integer"}},{"name":"first","in":"query","description":"0 = đăng ký lần 2 trở đi","required":false,"schema":{"type":"string"}},{"name":"pickup","in":"query","description":"1 = bán tải","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/sync/catalog":{"get":{"tags":["Sync"],"summary":"Phạm vi được đồng bộ","description":"Khoá bí mật / quản trị. knowledge { kinds[{ key (\"mảng:nhóm\"), vertical, vertical_name, group, label, desc, articles, last_updated_at }], license, notice, standard { skill, title, version, body } = skill chuẩn nền tảng nen-tang-kien-thuc-dong-bo } · news { verticals[{ vertical, name, stories_7d }], license } · events { verticals[{ vertical, name }], license, own } · scope_at · ping_url. 403 sync khi chưa được cấp gì.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/sync/knowledge/changes":{"get":{"tags":["Sync"],"summary":"Kiến thức — thêm / đổi / gỡ","description":"Tăng dần theo (updated_at, id), không sót (chỉ thay đổi đã cũ ≥ 60 giây). Bỏ trống cursor = đồng bộ đủ (chỉ bài đang dùng); có cursor = mọi thay đổi. items[{ id, slug, kind, vertical (mảng chủ quản), vertical_name, group, group_label, type, version, status (published · stale · removed), title, summary, commodities, audiences, aliases, tags, reviewed_at, next_review_at, updated_at }] — removed chỉ có id, slug, kind, vertical, group, version, status, updated_at. Luôn lưu next_cursor; has_more = gọi tiếp ngay.","parameters":[{"name":"cursor","in":"query","description":"next_cursor lần trước (bỏ trống = đồng bộ đủ)","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 100, mặc định 50","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/sync/knowledge/articles/{id}":{"get":{"tags":["Sync"],"summary":"Kiến thức — một bài đầy đủ","description":"vectors=1 → article.chunks [{ id, idx, heading, text, embedding }] (bge-m3 1024 chiều, đúng các đoạn bot dùng). body (markdown, mục ##), faq, laws, facts, sources, version, kind, vertical_name, group_label + license (rewrite: true — viết lại, không đăng nguyên văn). 404 removed = không còn trong phạm vi hoặc đang rà lại → gỡ khỏi bot / website.","parameters":[{"name":"id","in":"path","required":true,"description":"id bài (từ /changes)","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/sync/news/changes":{"get":{"tags":["Sync"],"summary":"Tin tức — thêm / cập nhật / ẩn","description":"vectors=1 → chuẩn kh-emb-1: items[].embed_title + chunks[] { id, idx, text, embedding } (bge-m3 1024 chiều, đoạn ~800 ký tự; ≤ 20 tin / trang; vector_format=array|base64). Tin của các mảng được cấp, đủ nội dung như GET /v1/news/stories/{id} (content Markdown nhẹ, sources_list, image, image_source, labels, version, update_note) + vertical_name, status (published · removed). Giữ nguyên bản tin, luôn hiện nguồn. Bỏ trống cursor = bắt đầu từ days ngày trước (chỉ tin đang hiện).","parameters":[{"name":"cursor","in":"query","description":"next_cursor lần trước","required":false,"schema":{"type":"string"}},{"name":"days","in":"query","description":"lần đầu: số ngày lấy lại, mặc định 3, ≤ 30","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"≤ 50","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/sync/events/changes":{"get":{"tags":["Sync"],"summary":"Sự kiện — thêm / dời / huỷ / gỡ","description":"vectors=1 → chuẩn kh-emb-1: embed_title + chunks[] (1 đoạn). Sự kiện của các mảng được cấp + sự kiện riêng của doanh nghiệp, trường như GET /v1/events + vertical_name; sources [{story_id, title, url (link báo gốc), outlet (tên báo), at}]. status: sap-dien-ra · dang-dien-ra · da-qua · da-huy · removed (bị ẩn / xoá). Bỏ trống cursor = sự kiện chưa qua.","parameters":[{"name":"cursor","in":"query","description":"next_cursor lần trước","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 100","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/sync/settings":{"get":{"tags":["Sync"],"summary":"Cài đặt đồng bộ","description":"Khoá quản trị: ping_url, scope_at, knowledge, news, events.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"put":{"tags":["Sync"],"summary":"Đặt địa chỉ nhận tín hiệu","description":"Khoá quản trị. { ping_url: \"https://…\" | null }. khachhang.app POST { event: \"sync.changed\", tenant, knowledge, news, events (số thay đổi), scope_changed, until } (gộp, tối đa 10 phút / lần) — chỉ tín hiệu, tự kéo lại bằng /changes.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ ping_url }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/sync/sources":{"get":{"tags":["Sync"],"summary":"Nguồn quét doanh nghiệp đề nghị","description":"Trạng thái từng link: pending (chờ dò) · active (đã thành nguồn — source_id, feed_url) · skipped (bài lẻ, không quét định kỳ được) · failed (lỗi, thử lại ≤ 3 lần — note) · removed. counts theo trạng thái.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"put":{"tags":["Sync"],"summary":"Gửi danh sách link để quét","description":"Cần được cấp sự kiện. { items: [{ url, name?, kind? (website · news · event · tag), entity? (dự án / chủ đầu tư) }] } — danh sách ĐẦY ĐỦ (≤ 500): link mới chờ dò, link không còn → removed (nguồn chỉ do link đó tạo thì tắt). Pipeline tự dò RSS / trang tin tức + mẫu link bài, tạo nguồn trong mảng sự kiện được cấp (bất động sản ưu tiên) → tin + sự kiện về qua /changes như mọi nguồn.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ items: [{ url, name, kind, entity }] }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/knowledge/{vertical}/facts":{"get":{"tags":["Knowledge"],"summary":"Dữ kiện chuẩn của mảng","description":"Số liệu hay đổi (hạn mức, thuế phí, lãi suất ưu đãi…) — một giá trị có nguồn, ngày áp dụng; gồm dữ kiện mảng khác chia sẻ tới. disputed = đang có nguồn ghi khác.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/knowledge/{vertical}":{"get":{"tags":["Knowledge"],"summary":"Danh sách bài kiến thức","description":"Bài đã duyệt (status published / stale), sắp theo nhóm. Mỗi bài: group, type (cam-nang · quy-trinh · thuat-ngu · hoi-dap), audiences, title, summary, tags, reviewed_at, next_review_at.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng có kiến thức: bat-dong-san · nong-nghiep · o-to-xe-may","schema":{"type":"string"}},{"name":"group","in":"query","description":"mã nhóm (GET …/taxonomy)","required":false,"schema":{"type":"string"}},{"name":"type","in":"query","description":"loại bài","required":false,"schema":{"type":"string"}},{"name":"audience","in":"query","description":"mã đối tượng","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"tìm trong tiêu đề / tóm tắt / thẻ","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 100","required":false,"schema":{"type":"integer"}},{"name":"offset","in":"query","description":"phân trang","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/knowledge/{vertical}/taxonomy":{"get":{"tags":["Knowledge"],"summary":"Nhóm và đối tượng","description":"Nhóm bài (key, label, desc, số bài) + đối tượng đọc của mảng.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng có kiến thức: bat-dong-san · nong-nghiep · o-to-xe-may","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/biz/{vertical}":{"get":{"tags":["Biz"],"summary":"Tổng quan kho doanh nghiệp của mảng","description":"Loại doanh nghiệp (kinds — nhãn + số lượng), tỉnh có nhiều doanh nghiệp, vùng quét gợi ý, tổng số / có email / có SĐT / có giấy phép, lần quét gần nhất. Mảng có kho: bat-dong-san, nong-nghiep.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng: bat-dong-san · nong-nghiep","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/biz/{vertical}/companies":{"get":{"tags":["Biz"],"summary":"Danh sách doanh nghiệp","description":"Lọc + phân trang. sort=score (mặc định, cursor) · updated (cũ → mới, cursor — dùng đồng bộ: updated_since + include_deleted=1 để nhận cả bản đã xoá) · name (offset). near=lat,lng + radius_km → có distance_km, gần trước (offset). Doanh nghiệp optout: không trả phone / email / zalo / legal_rep.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng","schema":{"type":"string"}},{"name":"q","in":"query","description":"tìm tên, địa chỉ, SĐT, mã số thuế","required":false,"schema":{"type":"string"}},{"name":"kind","in":"query","description":"mã loại, nhiều mã cách dấu phẩy","required":false,"schema":{"type":"string"}},{"name":"province","in":"query","description":"tỉnh / khu vực (chứa chuỗi)","required":false,"schema":{"type":"string"}},{"name":"has","in":"query","description":"email · phone · website · tax_code · zalo (phẩy)","required":false,"schema":{"type":"string"}},{"name":"licensed","in":"query","description":"1 = có giấy phép","required":false,"schema":{"type":"string"}},{"name":"min_score","in":"query","description":"điểm tối thiểu","required":false,"schema":{"type":"integer"}},{"name":"source","in":"query","description":"map (bản đồ) · tay · import · tenant","required":false,"schema":{"type":"string"}},{"name":"bbox","in":"query","description":"nam,tây,bắc,đông","required":false,"schema":{"type":"string"}},{"name":"near","in":"query","description":"lat,lng","required":false,"schema":{"type":"string"}},{"name":"radius_km","in":"query","description":"bán kính khi có near (≤ 100)","required":false,"schema":{"type":"number"}},{"name":"updated_since","in":"query","description":"ISO hoặc YYYY-MM-DD HH:MM:SS (giờ VN)","required":false,"schema":{"type":"string"}},{"name":"include_deleted","in":"query","description":"1 = kèm bản đã xoá (deleted: true) khi có updated_since","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","description":"score · updated · name","required":false,"schema":{"type":"string"}},{"name":"cursor","in":"query","description":"next_cursor của trang trước","required":false,"schema":{"type":"string"}},{"name":"offset","in":"query","description":"khi sort=name / near","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"≤ 500, mặc định 100","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Biz"],"summary":"Đóng góp doanh nghiệp vào kho chung","description":"{ items: [{ ref?, name, kind?, phone, email, zalo, website, facebook, address, ward, province, area, lat, lng, tax_code, legal_rep, licensed, place_id, categories, map_url, rating, reviews }] } (≤ 200) hoặc một đối tượng. Dò trùng place_id → mã số thuế → SĐT → tên + tỉnh: trùng thì chỉ điền chỗ trống. Trả items [{ ref, id, action: added | updated | skipped, reason? }].","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/biz/{vertical}/companies/{id}":{"get":{"tags":["Biz"],"summary":"Một doanh nghiệp","description":"Theo id của khachhang.app hoặc place_id (mã địa điểm trên bản đồ).","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"id hoặc place_id","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/biz/{vertical}/companies/{id}/optout":{"post":{"tags":["Biz"],"summary":"Doanh nghiệp yêu cầu không liên hệ / xoá thông tin liên hệ","description":"Áp cho MỌI tài khoản: API thôi trả SĐT / email / Zalo / người đại diện. Chỉ dùng khi doanh nghiệp yêu cầu xoá dữ liệu hoặc không muốn ai liên hệ; việc \"huỷ nhận thư của riêng bạn\" giữ ở hệ thống của bạn. Body: { note }.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng","schema":{"type":"string"}},{"name":"id","in":"path","required":true,"description":"id","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/biz/{vertical}/scans":{"get":{"tags":["Biz"],"summary":"Lượt quét vùng","description":"Vùng đã quét xong (mọi tài khoản) + yêu cầu của bạn (kèm chi phí, lỗi). status: cho-duyet · cho · chay · xong · loi · tu-choi.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Biz"],"summary":"Yêu cầu quét một vùng trên bản đồ","description":"{ area, lat, lng, radius_km (1–20), queries? (mặc định theo mảng), max_places?, note? } — tự chạy trong trần chi phí của nền tảng hoặc chờ khachhang.app duyệt; xong thì doanh nghiệp mới vào kho (10–20 phút). Tối đa 5 yêu cầu / ngày.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/marketing/ads/searches":{"get":{"tags":["Marketing"],"summary":"Lượt tìm quảng cáo của bạn","description":"100 lượt gần nhất + month { spent_usd, cap_usd }.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Marketing"],"summary":"Tìm quảng cáo đang chạy (chạy nền)","description":"Một trong hai: keyword (tìm trong thư viện quảng cáo, vd tên dự án) hoặc page_urls (≤ 100 link fanpage). Tuỳ chọn: country (mặc định VN), active_only (mặc định true), days (1–365, mặc định 90 — với page_urls), limit (≤ 500), page_info (true = kèm thông tin trang, với page_urls), max_usd (0.1–10, mặc định 1 — hạn mức chi phí lượt, dừng khi chạm, phần đã lấy vẫn đọc được), purpose. Trả { id, status } — hỏi GET …/searches/{id} mỗi 1–5 phút (thường 2–15 phút). 429 khi vượt hạn mức tháng.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/marketing/ads/searches/{id}":{"get":{"tags":["Marketing"],"summary":"Trạng thái một lượt","description":"status: READY · RUNNING · SUCCEEDED · FAILED · ABORTED (dừng do chạm hạn mức — có phần kết quả) · TIMED-OUT; ads (số quảng cáo), cost_usd, query.","parameters":[{"name":"id","in":"path","required":true,"description":"id lượt","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/marketing/ads/searches/{id}/ads":{"get":{"tags":["Marketing"],"summary":"Quảng cáo tìm được","description":"items [{ ad_id, page_id, page_name, page_url, text, title, description, cta, link_url, started_at, ended_at, active, platforms, images, videos, library_url, input_url }], phân trang offset / limit (≤ 500) → next_offset.","parameters":[{"name":"id","in":"path","required":true,"description":"id lượt","schema":{"type":"string"}},{"name":"offset","in":"query","description":"vị trí","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"≤ 500","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/marketing/ads/searches/{id}/pages":{"get":{"tags":["Marketing"],"summary":"Trang đang quảng cáo","description":"Lượt theo page_urls: mỗi trang đầu vào { page_url, page_id, name, owner (đơn vị quản lý), phone, address, city, about, likes, admin_countries, history, ads, found }. Lượt theo keyword: các trang có quảng cáo khớp { page_id, name, page_url, ads, first_started_at }, nhiều quảng cáo trước.","parameters":[{"name":"id","in":"path","required":true,"description":"id lượt","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/knowledge/{vertical}/market":{"get":{"tags":["Knowledge"],"summary":"Thống kê thị trường của mảng","description":"Số liệu từng mặt hàng (nông nghiệp: ngành hàng — kim ngạch xuất khẩu, tăng trưởng, diện tích, sản lượng, tỉ trọng vùng trọng tâm, thị trường, tỉnh; kèm nguồn, năm) + độ phủ kiến thức (bài trong kho, chủ đề đang viết, bài doanh nghiệp đã đăng nếu được viết lại) + điểm ưu tiên viết bài 0–100 (parts: size, growth, focus, gap). Mảng có khai báo thống kê: nong-nghiep.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng: nong-nghiep","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/knowledge/{vertical}/{slug}":{"get":{"tags":["Knowledge"],"summary":"Một bài kiến thức","description":"Bài đầy đủ: body (markdown, mục ##), faq [{q, a}], laws [{code, name, effective_from}], facts [{label, value, effective_from, source}], sources [{name, url, accessed}].","parameters":[{"name":"vertical","in":"path","required":true,"description":"mảng có kiến thức: bat-dong-san · nong-nghiep · o-to-xe-may","schema":{"type":"string"}},{"name":"slug","in":"path","required":true,"description":"slug hoặc id bài","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/kn-desk/keywords":{"get":{"tags":["Knowledge"],"summary":"Từ khoá hot","description":"Doanh nghiệp có mảng kiến thức (gói hoặc phạm vi đồng bộ /v1/sync — khoá bí mật hoặc quản trị): cụm từ người Việt đang tìm trên Google theo ngành hàng của mảng — volume (lượt tìm / tháng), monthly (12 tháng, cũ → mới), trend (3 tháng gần nhất so với 3 tháng trước), group, state (new: kho chưa có bài · covered · queued: đang viết · skip), source_slug, published_url (bài đã đăng của bạn). Cập nhật mỗi tháng.","parameters":[{"name":"vertical","in":"query","description":"mảng (mặc định theo tiêu chuẩn viết)","required":false,"schema":{"type":"string"}},{"name":"state","in":"query","description":"new · covered · queued · skip","required":false,"schema":{"type":"string"}},{"name":"commodity","in":"query","description":"mã ngành hàng","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"tìm trong từ khoá","required":false,"schema":{"type":"string"}},{"name":"rising","in":"query","description":"1 = chỉ từ khoá tăng ≥ 20%","required":false,"schema":{"type":"string"}},{"name":"sort","in":"query","description":"trend","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 200","required":false,"schema":{"type":"integer"}},{"name":"offset","in":"query","description":"phân trang","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/seo/sites":{"get":{"tags":["SEO"],"summary":"Site đã khai báo","description":"SEO desk theo site: mỗi doanh nghiệp tối đa 10 site (tên miền). Khoá quản trị hoặc khoá bí mật.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/seo/sites/{site}":{"get":{"tags":["SEO"],"summary":"Một site","description":"","parameters":[{"name":"site","in":"path","required":true,"description":"tên miền, vd nongdan.ai","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"put":{"tags":["SEO"],"summary":"Khai báo / sửa site","description":"Chỉ trường gửi lên được đổi.","parameters":[{"name":"site","in":"path","required":true,"description":"tên miền","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ name?, vertical?, sitemap? (https), gsc_property?, locale? (vi-VN), competitors?: [tên miền], content_rules?: [string], ai_prompts?: [{ q, cluster? }] }","content":{"application/json":{"schema":{"type":"object"}}}}},"delete":{"tags":["SEO"],"summary":"Xoá site + số liệu","description":"Chỉ khoá quản trị.","parameters":[{"name":"site","in":"path","required":true,"description":"tên miền","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/seo/sites/{site}/content-audit":{"get":{"tags":["SEO"],"summary":"Điểm chuẩn SEO bài kiến thức","description":"Luôn rỗng từ 27/11/2026 (Phòng biên tập đã gỡ — giữ hợp đồng). Trước đây: bài đã duyệt / đã đăng ở Phòng biên tập cho site: standard (kn-seo-1), checked, passed, avg_score, items [{ id, state, target_slug, url, score, pass, issues[{ code, msg }], checked_at }].","parameters":[{"name":"site","in":"path","required":true,"description":"tên miền","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/seo/sites/{site}/conversions":{"post":{"tags":["SEO"],"summary":"Gửi chuyển đổi tổng hợp","description":"Số tổng hợp ngày × nguồn × trang vào — KHÔNG gửi dữ liệu cá nhân. Ghi đè toàn bộ số của các ngày có trong rows (gửi lại cả cửa sổ an toàn). Site chưa khai báo → tự khai báo. ≤ 5000 dòng. source: google · bing · coccoc · duckduckgo · chatgpt · perplexity · gemini · copilot · claude · facebook · zalo · youtube · tiktok · other · direct · utm:<nguồn> · unknown. landing: đường dẫn, không query. Trả { accepted, days, rejected, errors[] }.","parameters":[{"name":"site","in":"path","required":true,"description":"tên miền","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ metric: \"signup\", tz: \"UTC\", days?: 35, rows: [{ day: \"YYYY-MM-DD\", source, landing, signups }] }","content":{"application/json":{"schema":{"type":"object"}}}}},"get":{"tags":["SEO"],"summary":"Chuyển đổi đã nhận","description":"Tổng, by_day, by_source, by_landing (top 50) — kèm source (\"site\") và updated.","parameters":[{"name":"site","in":"path","required":true,"description":"tên miền","schema":{"type":"string"}},{"name":"metric","in":"query","description":"mặc định signup","required":false,"schema":{"type":"string"}},{"name":"from","in":"query","description":"YYYY-MM-DD (mặc định 28 ngày trước to)","required":false,"schema":{"type":"string","format":"date"}},{"name":"to","in":"query","description":"YYYY-MM-DD","required":false,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/kn-desk/requests":{"get":{"tags":["Knowledge"],"summary":"Yêu cầu viết / cập nhật bài đã gửi","description":"50 yêu cầu gần nhất: kind, keyword, state (open · queued · covered · done · rejected), reply.","parameters":[{"name":"limit","in":"query","description":"≤ 200","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Knowledge"],"summary":"Gửi yêu cầu viết / cập nhật bài","description":"JSON { kind: new | update, keyword, commodity?, source_slug? (slug bài gốc — update), target_slug? (slug bài trên website, trùng slug / tên cũ bài gốc thì nhận), signals? { impressions, clicks, position, ctr, page, source } (số liệu Search Console tổng hợp), note? }. new: kho có bài → state covered (nhận qua /v1/sync/knowledge); chưa có → chủ đề mới cho AI nghiên cứu + viết. update: thêm từ khoá vào bài gốc, rà lại nếu bài cũ hơn 14 ngày. Trùng yêu cầu trong 14 ngày → trả yêu cầu cũ (duplicate). Tối đa 100 / ngày.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/{vertical}/widget":{"get":{"tags":["News"],"summary":"Cấu hình khối trang tin","description":"Cho khối nhúng https://api.p2c.vn/news.js: title, brand kit (kit), filters [{key, label, values[{value, label}]}] (nhãn có tin trong 30 ngày).","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/{vertical}/radio":{"get":{"tags":["News"],"summary":"Radio — danh sách phát","description":"Tin mới nhất kèm `audio` (MP3 từng giọng, media.p2c.tech), `speech` (lời đọc), `kit` (brand kit). Lọc `label` như danh sách tin. Khối nhúng: https://api.p2c.vn/radio.js","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}},{"name":"label","in":"query","description":"nhãn chiều:mã","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 60","required":false,"schema":{"type":"integer"}},{"name":"since","in":"query","description":"từ thời điểm (ISO)","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/{vertical}/taxonomy":{"get":{"tags":["News"],"summary":"Các chiều phân loại của mảng","description":"Mỗi chiều: key, label, source (enum · province · region · project · entity) và danh sách giá trị (enum, 34 tỉnh / thành mới kèm miền, Bắc / Trung / Nam). Tin trả trường `labels` { chiều: [{ value, label, in_catalog? }] }.","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/stories/{id}":{"get":{"tags":["News"],"summary":"Một tin","description":"Nội dung đầy đủ + nguồn + tin liên quan.","parameters":[{"name":"id","in":"path","required":true,"description":"mã 20 ký tự","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/search":{"get":{"tags":["News"],"summary":"Tìm theo nghĩa","description":"Tìm vector theo câu hỏi tự nhiên.","parameters":[{"name":"q","in":"query","description":"câu tìm","required":true,"schema":{"type":"string"}},{"name":"vertical","in":"query","description":"mã mảng","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 30","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/{vertical}/rss":{"get":{"tags":["News"],"summary":"RSS 2.0","description":"Dùng ?key=na_pk_…","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/news/{vertical}/live":{"get":{"tags":["News"],"summary":"Realtime (WebSocket)","description":"?key=na_pk_… — nhận { t: \"story\", kind: \"new\" | \"update\", item }; gửi \"ping\" nhận \"pong\".","parameters":[{"name":"vertical","in":"path","required":true,"description":"mã mảng tin: bat-dong-san · tai-chinh · chung-khoan · crypto · nong-nghiep · cong-nghe · o-to-xe-may (GET /v1/news/verticals)","schema":{"type":"string"}}],"responses":{"101":{"description":"Đã nâng cấp WebSocket"}}}},"/v1/news/stories/{id}/events":{"post":{"tags":["News"],"summary":"Ghi sự kiện người đọc","description":"{ v, view?, read?, click?, share?, react? }","parameters":[{"name":"id","in":"path","required":true,"description":"mã tin","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"sự kiện","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/real-estate/projects":{"get":{"tags":["Real estate — Projects"],"summary":"Danh sách dự án + giá mới nhất","description":"Dự án trong kho chung (và dự án doanh nghiệp gắn), giá mới nhất từng phân khúc, toạ độ cho bản đồ.","parameters":[{"name":"province","in":"query","description":"tỉnh / thành","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"tên dự án","required":false,"schema":{"type":"string"}},{"name":"segment","in":"query","description":"so-cap (chủ đầu tư bán) · thu-cap (chuyển nhượng) · thue (cho thuê)","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/projects/compare":{"get":{"tags":["Real estate — Projects"],"summary":"So sánh dự án","description":"Giá theo thời gian của nhiều dự án.","parameters":[{"name":"ids","in":"query","description":"mã dự án, cách nhau dấu phẩy","required":true,"schema":{"type":"string"}},{"name":"segment","in":"query","description":"so-cap (chủ đầu tư bán) · thu-cap (chuyển nhượng) · thue (cho thuê)","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/projects/{id}":{"get":{"tags":["Real estate — Projects"],"summary":"Chi tiết dự án + lịch sử giá","description":"Thông tin có nguồn (chủ đầu tư, pháp lý, quy mô, cơ cấu căn…), toàn bộ mốc giá, dự án lân cận.","parameters":[{"name":"id","in":"path","required":true,"description":"mã dự án","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"put":{"tags":["Real estate — Projects"],"summary":"Gắn / sửa dự án của doanh nghiệp","description":"Gắn dự án vào danh sách theo dõi (mã riêng own_slug). Khoá quản trị.","parameters":[{"name":"id","in":"path","required":true,"description":"mã dự án","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ own_slug?, … }","content":{"application/json":{"schema":{"type":"object"}}}}},"delete":{"tags":["Real estate — Projects"],"summary":"Bỏ gắn dự án","description":"Dự án doanh nghiệp thêm chưa vào kho chung thì xoá hẳn.","parameters":[{"name":"id","in":"path","required":true,"description":"mã dự án","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/projects/{id}/info":{"put":{"tags":["Real estate — Projects"],"summary":"Đề xuất sửa thông tin dự án","description":"Mỗi trường thành một đề xuất chờ khachhang.app xác nhận (kèm link nguồn).","parameters":[{"name":"id","in":"path","required":true,"description":"mã dự án","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ field: value, cite: { field: url } }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/real-estate/prices":{"post":{"tags":["Real estate — Projects"],"summary":"Đóng góp mốc giá","description":"Giá chờ xác nhận rồi mới vào kho chung. Trùng giá mốc trước thì không thêm mốc mới.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ prices: [{ project, segment, ptype, rooms?, observed, min, max, avg, source_url }] }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/real-estate/prices/{id}":{"delete":{"tags":["Real estate — Projects"],"summary":"Rút mốc giá đã gửi","description":"Chỉ mốc đang chờ của chính doanh nghiệp.","parameters":[{"name":"id","in":"path","required":true,"description":"mã mốc giá","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/private/prices":{"put":{"tags":["Real estate — Projects"],"summary":"Giá riêng (rổ hàng)","description":"Thay toàn bộ mốc giá riêng của các dự án gửi lên — chỉ doanh nghiệp này thấy.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ projects: [own_slug], points: [{ project, segment, ptype, observed, min, max, avg }] }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/real-estate/public/area-stats":{"get":{"tags":["Real estate — Projects"],"summary":"Giá tổng hợp theo khu vực (công khai)","description":"Không cần khoá. Trung vị / 25–75 % giá theo tỉnh / phường × loại căn × phân khúc, 12 tháng gần nhất, chỉ nhóm ≥ 3 dự án, không tên dự án. Cache 12 giờ.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/price-level":{"get":{"tags":["Real estate — Projects"],"summary":"Mặt bằng giá khu vực","description":"Tổng hợp giá theo khu vực / bán kính quanh một dự án — dùng cho trợ lý AI (không nêu tên dự án của doanh nghiệp khác).","parameters":[{"name":"khu_vuc","in":"query","description":"tỉnh / quận / phường","required":false,"schema":{"type":"string"}},{"name":"gan_du_an","in":"query","description":"mã dự án tâm","required":false,"schema":{"type":"string"}},{"name":"ban_kinh_km","in":"query","description":"bán kính km","required":false,"schema":{"type":"number"}},{"name":"loai","in":"query","description":"can-ho · nha-pho · biet-thu · dat-nen…","required":false,"schema":{"type":"string"}},{"name":"phan_khuc","in":"query","description":"so-cap · thu-cap · thue","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/changes":{"get":{"tags":["Real estate — Projects"],"summary":"Lịch sử đề xuất thay đổi","description":"Đề xuất của doanh nghiệp và trạng thái xác nhận.","parameters":[{"name":"status","in":"query","description":"cho · ap-dung · bo-qua","required":false,"schema":{"type":"string"}},{"name":"project","in":"query","description":"mã dự án","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/notes":{"get":{"tags":["Real estate — Projects"],"summary":"Góp ý","description":"Góp ý giá / thông tin dạng chữ.","parameters":[{"name":"status","in":"query","description":"trạng thái","required":false,"schema":{"type":"string"}},{"name":"project","in":"query","description":"mã dự án","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Real estate — Projects"],"summary":"Gửi góp ý","description":"khachhang.app xác nhận (có thể nhờ AI kiểm).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ project, content, price_min?, price_max?, source_url? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/real-estate/requests":{"get":{"tags":["Real estate — Projects"],"summary":"Yêu cầu AI tìm / cập nhật","description":"Trạng thái yêu cầu; done_since lấy các yêu cầu xong từ thời điểm.","parameters":[{"name":"done_since","in":"query","description":"yyyy-mm-dd hh:mm:ss","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Real estate — Projects"],"summary":"Yêu cầu AI tìm dự án / cập nhật giá","description":"AI của khachhang.app tìm có nguồn rồi đưa vào kho.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ kind: them | cap-nhat, project_id?, name?, map_url?, lat?, lng?, note? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/real-estate/land/provinces":{"get":{"tags":["Real estate — Land"],"summary":"Giá đất đại diện theo tỉnh","description":"","parameters":[{"name":"date","in":"query","description":"giá tại ngày (yyyy-mm-dd)","required":false,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/wards":{"get":{"tags":["Real estate — Land"],"summary":"Phường / xã của một tỉnh","description":"","parameters":[{"name":"p","in":"query","description":"mã tỉnh","required":true,"schema":{"type":"string"}},{"name":"date","in":"query","description":"giá tại ngày","required":false,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/geo/{p}":{"get":{"tags":["Real estate — Land"],"summary":"Ranh giới phường (GeoJSON) của tỉnh","description":"","parameters":[{"name":"p","in":"path","required":true,"description":"mã tỉnh","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/roads":{"get":{"tags":["Real estate — Land"],"summary":"Giá theo tuyến đường của phường","description":"","parameters":[{"name":"w","in":"query","description":"mã phường","required":true,"schema":{"type":"string"}},{"name":"date","in":"query","description":"giá tại ngày","required":false,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/history":{"get":{"tags":["Real estate — Land"],"summary":"Lịch sử giá phường / tuyến đường","description":"Mỗi mốc khi giá đổi (valid_from – valid_to).","parameters":[{"name":"w","in":"query","description":"mã phường","required":true,"schema":{"type":"string"}},{"name":"road","in":"query","description":"mã tuyến đường","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/province-history":{"get":{"tags":["Real estate — Land"],"summary":"Lịch sử giá đại diện của tỉnh","description":"","parameters":[{"name":"p","in":"query","description":"mã tỉnh","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/at":{"get":{"tags":["Real estate — Land"],"summary":"Giá đất tại toạ độ","description":"Phường + tuyến gần nhất.","parameters":[{"name":"lat","in":"query","description":"vĩ độ","required":true,"schema":{"type":"number"}},{"name":"lng","in":"query","description":"kinh độ","required":true,"schema":{"type":"number"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/summary":{"get":{"tags":["Real estate — Land"],"summary":"Tóm tắt giá đất khu vực","description":"Văn bản ngắn cho trợ lý AI.","parameters":[{"name":"khu_vuc","in":"query","description":"tỉnh / phường","required":false,"schema":{"type":"string"}},{"name":"lat","in":"query","description":"vĩ độ","required":false,"schema":{"type":"number"}},{"name":"lng","in":"query","description":"kinh độ","required":false,"schema":{"type":"number"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/real-estate/land/search":{"get":{"tags":["Real estate — Land"],"summary":"Tìm tỉnh / phường / đường","description":"","parameters":[{"name":"q","in":"query","description":"từ khoá","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/finance/bank-rates":{"get":{"tags":["Finance"],"summary":"Lãi suất tiền gửi mới nhất","description":"Mỗi ngân hàng: kỳ hạn → lãi suất (%/năm), kênh tại quầy / online, ngày hiệu lực, link nguồn.","parameters":[{"name":"bank","in":"query","description":"mã ngân hàng, nhiều mã cách dấu phẩy (vcb,acb…)","required":false,"schema":{"type":"string"}},{"name":"kind","in":"query","description":"deposit · base · lending_avg · policy · interbank","required":false,"schema":{"type":"string"}},{"name":"term","in":"query","description":"0m (không kỳ hạn), 1m … 36m; on, 1w (liên ngân hàng)","required":false,"schema":{"type":"string"}},{"name":"channel","in":"query","description":"quay · online","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/finance/bank-rates/compare":{"get":{"tags":["Finance"],"summary":"So sánh ngân hàng theo kỳ hạn","description":"Xếp hạng theo lãi suất.","parameters":[{"name":"term","in":"query","description":"kỳ hạn, mặc định 12m","required":false,"schema":{"type":"string"}},{"name":"channel","in":"query","description":"quay · online","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/finance/bank-rates/history":{"get":{"tags":["Finance"],"summary":"Lịch sử lãi suất","description":"Mỗi mốc khi lãi suất đổi.","parameters":[{"name":"bank","in":"query","description":"mã ngân hàng","required":false,"schema":{"type":"string"}},{"name":"term","in":"query","description":"kỳ hạn","required":false,"schema":{"type":"string"}},{"name":"channel","in":"query","description":"quay · online","required":false,"schema":{"type":"string"}},{"name":"kind","in":"query","description":"loại lãi suất","required":false,"schema":{"type":"string"}},{"name":"days","in":"query","description":"số ngày (≤ 730)","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/finance/calendar":{"get":{"tags":["Finance"],"summary":"Lịch kinh tế","description":"Sự kiện kinh tế (dự báo, thực tế, kỳ trước).","parameters":[{"name":"from","in":"query","description":"từ ngày","required":false,"schema":{"type":"string","format":"date"}},{"name":"to","in":"query","description":"đến ngày","required":false,"schema":{"type":"string","format":"date"}},{"name":"country","in":"query","description":"mã nước","required":false,"schema":{"type":"string"}},{"name":"impact","in":"query","description":"mức ảnh hưởng","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/finance/context":{"get":{"tags":["Finance"],"summary":"Bối cảnh thị trường","description":"Ảnh chụp chỉ số chính + nhận định ngắn cho trợ lý AI.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/finance/series/{name}":{"get":{"tags":["Finance"],"summary":"Chuỗi chỉ số","description":"Chuỗi theo ngày của một chỉ số.","parameters":[{"name":"name","in":"path","required":true,"description":"tên chỉ số","schema":{"type":"string"}},{"name":"from","in":"query","description":"từ ngày","required":false,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/finance/brief":{"get":{"tags":["Finance"],"summary":"Bản tin thị trường (AI)","description":"Khoá máy chủ / quản trị.","parameters":[{"name":"vertical","in":"query","description":"mã mảng","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/bot/config":{"get":{"tags":["Bot"],"summary":"Cấu hình trợ lý","description":"Tên, lời chào, màu, câu gợi ý theo thương hiệu doanh nghiệp.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/events":{"get":{"tags":["Sự kiện"],"summary":"Lịch sự kiện","description":"Sắp / đang diễn ra theo mảng doanh nghiệp được đọc + sự kiện riêng. Mặc định hôm qua → 90 ngày tới. sources [{story_id, title, url (link báo gốc), outlet (tên báo), at}].","parameters":[{"name":"from","in":"query","description":"YYYY-MM-DD","required":false,"schema":{"type":"string"}},{"name":"to","in":"query","description":"YYYY-MM-DD","required":false,"schema":{"type":"string"}},{"name":"vertical","in":"query","description":"mã mảng","required":false,"schema":{"type":"string"}},{"name":"kind","in":"query","description":"loại sự kiện","required":false,"schema":{"type":"string"}},{"name":"province","in":"query","description":"tỉnh / thành","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"tìm theo tên, dự án, địa điểm","required":false,"schema":{"type":"string"}},{"name":"status","in":"query","description":"all = gồm sự kiện đã huỷ","required":false,"schema":{"type":"string"}},{"name":"le_tet","in":"query","description":"1 = thêm lễ tết âm lịch","required":false,"schema":{"type":"string"}},{"name":"moon","in":"query","description":"1 = thêm mùng 1 / rằm","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"1–200","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/events/{id}":{"get":{"tags":["Sự kiện"],"summary":"Một sự kiện","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã sự kiện","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/legal":{"get":{"tags":["Văn bản pháp luật"],"summary":"Văn bản pháp luật theo mảng","description":"Luật, nghị định, thông tư, quyết định… từ Cổng văn bản Chính phủ, theo mảng doanh nghiệp được đọc. Mỗi văn bản: code, doc_type, title (trích yếu), issuer, signer, issued_at, effective_at, expires_at, status (sap-hieu-luc · con-hieu-luc · het-mot-phan · het-hieu-luc · chua-ro), verticals, importance (0–3), summary (AI, từ trích yếu), audiences, url (văn bản chính thức), files, stories. Mới ban hành trước, keyset.","parameters":[{"name":"vertical","in":"query","description":"mã mảng","required":false,"schema":{"type":"string"}},{"name":"status","in":"query","description":"sap-hieu-luc · con-hieu-luc · het-hieu-luc","required":false,"schema":{"type":"string"}},{"name":"type","in":"query","description":"loại văn bản, vd Nghị định","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"số hiệu hoặc trích yếu","required":false,"schema":{"type":"string"}},{"name":"min_importance","in":"query","description":"0–3, mặc định 1","required":false,"schema":{"type":"integer"}},{"name":"effective_from","in":"query","description":"YYYY-MM-DD","required":false,"schema":{"type":"string"}},{"name":"effective_to","in":"query","description":"YYYY-MM-DD","required":false,"schema":{"type":"string"}},{"name":"cursor","in":"query","description":"next_cursor","required":false,"schema":{"type":"string"}},{"name":"limit","in":"query","description":"≤ 50","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/legal/{id}":{"get":{"tags":["Văn bản pháp luật"],"summary":"Một văn bản","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã văn bản","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/embed":{"post":{"tags":["Sync"],"summary":"Vector cho câu hỏi / đoạn chữ","description":"Body { texts: string[] (1–32 đoạn, ≤ 2.000 ký tự / đoạn), vector_format?: array | base64 }. Trả { model: @cf/baai/bge-m3, dims: 1024, metric: cosine, vectors } — CÙNG không gian với vector đồng bộ (/v1/sync/*?vectors=1) để doanh nghiệp tự tìm đoạn liên quan cho bot riêng. Khoá bí mật / quản trị.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/sync/legal/changes":{"get":{"tags":["Sync"],"summary":"Văn bản pháp luật — thêm / cập nhật / gỡ","description":"vectors=1 → chuẩn kh-emb-1: items[].embed_title + chunks[] { id, idx, text, embedding }. Văn bản của các mảng được cấp (settings.sync.legal), mức quan trọng ≥ 1, trường như GET /v1/legal + vertical_names. Ẩn / bỏ khỏi mảng → { id, code, status: removed }. Bỏ trống cursor = văn bản ban hành trong days ngày.","parameters":[{"name":"cursor","in":"query","description":"next_cursor lần trước","required":false,"schema":{"type":"string"}},{"name":"days","in":"query","description":"lần đầu: mặc định 365, ≤ 1095","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"≤ 100","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/content/legal":{"get":{"tags":["Account"],"summary":"Văn bản pháp luật xem được","description":"Như GET /v1/legal, theo mảng xem được của tài khoản (tin ∪ sự kiện ∪ kiến thức).","parameters":[{"name":"vertical","in":"query","description":"mã mảng","required":false,"schema":{"type":"string"}},{"name":"status","in":"query","description":"tình trạng hiệu lực","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"tìm","required":false,"schema":{"type":"string"}},{"name":"cursor","in":"query","description":"next_cursor","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/content/legal/{id}":{"get":{"tags":["Account"],"summary":"Một văn bản pháp luật","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã văn bản","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/lich/viec":{"get":{"tags":["Lịch"],"summary":"Các việc chọn ngày","description":"ky-coc · ky-hdmb · nhan-nha · nhap-trach · dong-tho · khai-truong · ky-ket · mua-xe · xuat-hanh","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/lich/ngay":{"get":{"tags":["Lịch"],"summary":"Thông tin một ngày","description":"Âm lịch, can chi, tiết khí, hoàng đạo / hắc đạo, trực, sao, ngày kỵ, giờ hoàng đạo; chấm Tốt / Khá / Trung bình / Tránh cho việc; xung / hợp tuổi khi gửi năm sinh.","parameters":[{"name":"date","in":"query","description":"dd/mm/yyyy hoặc yyyy-mm-dd (mặc định hôm nay)","required":false,"schema":{"type":"string"}},{"name":"viec","in":"query","description":"mã việc (GET /v1/lich/viec)","required":false,"schema":{"type":"string"}},{"name":"nam_sinh","in":"query","description":"năm sinh (1920–2030) — chỉ dùng để tính, không lưu","required":false,"schema":{"type":"string"}},{"name":"ngay_sinh","in":"query","description":"dd/mm/yyyy — thay nam_sinh khi sinh tháng 1–2 hoặc cần thần số học","required":false,"schema":{"type":"string"}},{"name":"gioi","in":"query","description":"nam | nu","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/lich/thang":{"get":{"tags":["Lịch"],"summary":"Lịch một tháng","description":"Mỗi ngày: âm lịch, can chi, tiết khí, hoàng đạo, trực, ngày kỵ, mức chung, giờ tốt. Cache 1 ngày.","parameters":[{"name":"month","in":"query","description":"yyyy-mm","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/lich/chon-ngay":{"get":{"tags":["Lịch"],"summary":"Gợi ý ngày tốt cho một việc","description":"Quét từ `tu` trong `so_ngay` ngày (7–120, mặc định 45), trả tối đa `n` ngày Tốt / Khá; loại ngày xung tuổi khi gửi năm sinh.","parameters":[{"name":"viec","in":"query","description":"mã việc","required":true,"schema":{"type":"string"}},{"name":"tu","in":"query","description":"dd/mm/yyyy","required":false,"schema":{"type":"string"}},{"name":"so_ngay","in":"query","description":"số ngày quét","required":false,"schema":{"type":"integer"}},{"name":"n","in":"query","description":"số ngày trả (1–20)","required":false,"schema":{"type":"integer"}},{"name":"nam_sinh","in":"query","description":"năm sinh (1920–2030) — chỉ dùng để tính, không lưu","required":false,"schema":{"type":"string"}},{"name":"ngay_sinh","in":"query","description":"dd/mm/yyyy — thay nam_sinh khi sinh tháng 1–2 hoặc cần thần số học","required":false,"schema":{"type":"string"}},{"name":"gioi","in":"query","description":"nam | nu","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/lich/menh":{"get":{"tags":["Lịch"],"summary":"Tuổi, mệnh, hướng nhà","description":"Can chi, con giáp, mệnh nạp âm, cung Bát trạch + 8 hướng tốt / xấu, hạn tuổi năm `nam` (Kim Lâu, Hoang Ốc, Tam Tai); có ngay_sinh: số chủ đạo, năm cá nhân, cung hoàng đạo.","parameters":[{"name":"nam_sinh","in":"query","description":"năm sinh (1920–2030) — chỉ dùng để tính, không lưu","required":false,"schema":{"type":"string"}},{"name":"ngay_sinh","in":"query","description":"dd/mm/yyyy — thay nam_sinh khi sinh tháng 1–2 hoặc cần thần số học","required":false,"schema":{"type":"string"}},{"name":"gioi","in":"query","description":"nam | nu","required":false,"schema":{"type":"string"}},{"name":"nam","in":"query","description":"năm xét hạn (mặc định năm nay)","required":false,"schema":{"type":"integer"}},{"name":"moc_nam","in":"query","description":"tet (mặc định) · lap-xuan · tet-hoa — mốc đầu năm âm","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/lich/so":{"get":{"tags":["Lịch"],"summary":"Rút gọn số (thần số học)","description":"Số nhà / số căn → một chữ số + ý nghĩa phổ biến (chỉ hiển thị).","parameters":[{"name":"so","in":"query","description":"vd T116-01","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/bot/chat":{"post":{"tags":["Bot"],"summary":"Hỏi trợ lý","description":"Trả lời dựa trên dữ liệu khachhang.app + kiến thức doanh nghiệp nạp. Gửi `session` (mã bí mật phiên 20–64 ký tự do app tự sinh, giữ kín) để hệ thống nhớ cuộc trò chuyện theo cài đặt lưu của doanh nghiệp; trả thêm `memory: {mode, days, saved}`.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ message, history?: [{ role, content }], vertical?, session? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/bot/session/forget":{"post":{"tags":["Bot"],"summary":"Xoá cuộc trò chuyện","description":"Xoá hẳn cuộc trò chuyện của mã phiên này trên hệ thống.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ session }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/bot/feedback":{"post":{"tags":["Bot"],"summary":"Đánh giá câu trả lời","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ session, turn, rating: up | down, note? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account":{"get":{"tags":["Account"],"summary":"Thông tin tài khoản + lượt dùng tháng","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"patch":{"tags":["Account"],"summary":"Sửa cài đặt","description":"origins, boosts, entities_url, site_url (khoá quản trị).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"cài đặt","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/keys":{"get":{"tags":["Account"],"summary":"Khoá API","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Account"],"summary":"Tạo khoá","description":"Trả khoá một lần.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ kind: public | secret | admin, name }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/keys/{id}":{"delete":{"tags":["Account"],"summary":"Thu hồi khoá","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã khoá","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/ai/run":{"post":{"tags":["AI"],"summary":"Chạy một việc AI, chờ kết quả","description":"Cần quản trị khachhang.app bật AI cho tài khoản. 200 { status: done, out, text, content?, tool_calls?, stop_reason?, cost_usd } hoặc 202 { status: pending, job_id } khi việc chạy quá `wait` giây — hỏi tiếp bằng GET /v1/ai/jobs/{id}. `skill` = tên skill (hoặc mảng ≤ 5 tên) ở kho skill: ghép quy tắc nền tảng → quy tắc doanh nghiệp → skill (+ phần bổ sung) trước `system`; kết quả có `skills: [{ name, version, scope }]`; tên không có → 404 skill_not_found.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ prompt | messages, skill?, system?, schema?, web?, images?: [{ media_type, data }], tools?, max_tokens?, model?: mã model khachhang.app cấp cho tài khoản (bỏ trống = mặc định), effort?, wait?: 5–600 }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/ai/jobs":{"post":{"tags":["AI"],"summary":"Xếp việc AI chạy nền","description":"202 { job_id } — hỏi kết quả bằng GET /v1/ai/jobs/{id}.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ prompt, skill?, system?, schema?, web?, model?, effort?, ref? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/skills":{"get":{"tags":["Account"],"summary":"Kho skill AI","description":"Skill riêng của doanh nghiệp (`mine`, đủ trường) + skill chung được dùng theo mảng (`common`), tiền tố tên skill riêng (`prefix` = `<slug>-`).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Account"],"summary":"Thêm skill riêng","description":"Khoá quản trị / bí mật. Tên bắt đầu bằng `<slug>-`; `kind` skill | rules (quy tắc tự ghép mọi lần gọi có skill); `extends` = tên skill chung để làm phần bổ sung; `status` active | draft | archived.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ name, title, body, use_when?, kind?, extends?, status? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/skills/{id}":{"get":{"tags":["Account"],"summary":"Một skill","description":"Theo mã hoặc tên; skill riêng kèm `versions`.","parameters":[{"name":"id","in":"path","required":true,"description":"sk_… hoặc tên","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"put":{"tags":["Account"],"summary":"Sửa skill riêng","description":"Sửa nội dung → lưu bản cũ, tăng `version`.","parameters":[{"name":"id","in":"path","required":true,"description":"sk_… hoặc tên","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ title?, body?, use_when?, kind?, extends?, status?, note? }","content":{"application/json":{"schema":{"type":"object"}}}}},"delete":{"tags":["Account"],"summary":"Xoá skill riêng","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"sk_… hoặc tên","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/skills/by-name/{name}":{"put":{"tags":["Account"],"summary":"Đồng bộ skill riêng theo tên","description":"Hệ thống của doanh nghiệp đẩy skill từ repo: có thì sửa (nội dung đổi mới tăng version), chưa có thì tạo.","parameters":[{"name":"name","in":"path","required":true,"description":"<slug>-…","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ title, body, use_when?, kind?, extends?, status?, note? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/skills/{id}/restore/{version}":{"post":{"tags":["Account"],"summary":"Quay về bản cũ","description":"Bản hiện tại được lưu lại.","parameters":[{"name":"id","in":"path","required":true,"description":"sk_…","schema":{"type":"string"}},{"name":"version","in":"path","required":true,"description":"số bản","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/skills/preview":{"post":{"tags":["Account"],"summary":"Xem trước bản ghép","description":"Đúng phần chỉ dẫn /v1/ai/run gửi AI khi gọi các skill này → { text, used, chars }.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ skill: tên | [tên…] }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/ai/jobs/{id}":{"get":{"tags":["AI"],"summary":"Trạng thái / kết quả một việc","description":"status: queued | running | done | failed | canceled; out (khi có schema) / text.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"delete":{"tags":["AI"],"summary":"Huỷ việc chưa chạy","description":"","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/ai/status":{"get":{"tags":["AI"],"summary":"Tình trạng dịch vụ AI, hàng việc, hạn mức ngày","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/webhooks":{"get":{"tags":["Account"],"summary":"Webhook","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Account"],"summary":"Thêm webhook","description":"Trả secret một lần. Chữ ký header x-khachhang-signature: t=<unix>,v1=HMAC-SHA256(secret, `${t}.${body}`) (tên cũ x-newsai-signature gửi kèm tới 24/05/2027).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ url, events?, verticals?, min_relevance? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/ai-keys/{provider}":{"put":{"tags":["Account"],"summary":"Khoá AI riêng (BYOK)","description":"Doanh nghiệp dùng khoá AI của chính mình cho việc riêng — gọi thử trước khi lưu, lưu mã hoá, chỉ hiện 4 ký tự cuối. Mã nhà cung cấp được hỗ trợ: GET /v1/account (ai_providers) hoặc trang quản trị tài khoản.","parameters":[{"name":"provider","in":"path","required":true,"description":"mã nhà cung cấp AI của khoá","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ key, model?, monthly_usd? }","content":{"application/json":{"schema":{"type":"object"}}}}},"delete":{"tags":["Account"],"summary":"Xoá khoá AI","description":"","parameters":[{"name":"provider","in":"path","required":true,"description":"nhà cung cấp","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/brandkit":{"get":{"tags":["Account"],"summary":"Brand kit của doanh nghiệp","description":"Màu (Sáng / Tối), font, logo, liên hệ, bo góc + bộ token đã suy ra (chữ trên màu theo tương phản WCAG).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"put":{"tags":["Account"],"summary":"Lưu brand kit","description":"Khoá quản trị. Áp cho widget trợ lý, link dùng thử, trang nhận tin, Connect. Chữ / nền thiếu tương phản (< 4,5 : 1) bị từ chối.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ name?, slogan?, colors: { primary, accent?, secondary?, bg?, surface?, text? }, dark?: {…}, fonts: { heading, body }, logo: { light?, dark?, icon? }, contact: { hotline?, zalo?, website?, email?, address? }, radius: vuong | mem | tron }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/brandkit/logo":{"post":{"tags":["Account"],"summary":"Tải logo","description":"Thân = tệp ảnh (PNG · JPG · WebP · SVG thuần hình, ≤ 1 MB); trả url để lưu vào brand kit.","parameters":[{"name":"kind","in":"query","description":"light · dark · icon","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/kb":{"get":{"tags":["Account"],"summary":"Kiến thức doanh nghiệp","description":"Tài liệu / link nạp cho trợ lý.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Account"],"summary":"Nạp kiến thức","description":"Văn bản hoặc URL (tự làm mới).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ title, text? | url? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/entities":{"get":{"tags":["Account"],"summary":"Thực thể","description":"Dự án, sản phẩm… để gắn tin.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"put":{"tags":["Account"],"summary":"Đẩy thực thể","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ entities: [{ type, slug, name, url?, aliases?, data? }], replace_types? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/usage":{"get":{"tags":["Account"],"summary":"Lượt gọi theo ngày (90 ngày)","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/usage/report":{"get":{"tags":["Account"],"summary":"Thống kê lượt gọi","description":"Tổng, chuỗi theo ngày / giờ và phân tách. Tham số: `days` = 1 | 7 | 30 | 90; `by` = route | vertical | status | key | kind | cache | country. Cập nhật 5 phút.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/audit":{"get":{"tags":["Account"],"summary":"Nhật ký thao tác","description":"Chỉ khoá quản trị. Mọi thao tác thay đổi của doanh nghiệp (khoá, webhook, bot, kiến thức…). Tham số: `days` (1–365), `kind` = fail | create | update | delete, `q`, `before` (id — trang tiếp). Giá trị khoá / mật khẩu luôn được che.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/content":{"get":{"tags":["Account"],"summary":"Phạm vi nội dung xem được","description":"news[{ slug, name }], knowledge[{ slug, name, groups[{ key, label }] }], events[{ slug, name }] — mảng tin / kiến thức của gói ∪ phạm vi đồng bộ được cấp.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/content/news":{"get":{"tags":["Account"],"summary":"Xem tin của mảng có quyền","description":"20 tin / trang, mới cập nhật trước; next_cursor.","parameters":[{"name":"vertical","in":"query","description":"mảng","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"tìm trong tiêu đề","required":false,"schema":{"type":"string"}},{"name":"cursor","in":"query","description":"next_cursor","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/content/news/{id}":{"get":{"tags":["Account"],"summary":"Một tin (đủ nội dung + nguồn)","description":"item như /v1/news/stories/{id}.","parameters":[{"name":"id","in":"path","required":true,"description":"id tin","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/content/knowledge":{"get":{"tags":["Account"],"summary":"Xem bài kiến thức có quyền","description":"50 bài / trang; group_label; next_offset.","parameters":[{"name":"vertical","in":"query","description":"mảng","required":false,"schema":{"type":"string"}},{"name":"group","in":"query","description":"nhóm","required":false,"schema":{"type":"string"}},{"name":"q","in":"query","description":"tìm","required":false,"schema":{"type":"string"}},{"name":"offset","in":"query","description":"phân trang","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/content/knowledge/{id}":{"get":{"tags":["Account"],"summary":"Một bài kiến thức đầy đủ","description":"body, faq, laws, facts, sources + vertical_name, group_label.","parameters":[{"name":"id","in":"path","required":true,"description":"id bài","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/events":{"get":{"tags":["Account"],"summary":"Xem sự kiện của mảng có quyền","description":"Chỉ xem (sự kiện tự thêm đã gỡ 27/11/2026). kinds, verticals[{ slug, name }], items (như /v1/events + vertical_name).","parameters":[{"name":"vertical","in":"query","description":"mảng","required":false,"schema":{"type":"string"}},{"name":"from","in":"query","description":"YYYY-MM-DD","required":false,"schema":{"type":"string"}},{"name":"to","in":"query","description":"YYYY-MM-DD","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/data":{"get":{"tags":["Account"],"summary":"Dữ liệu được khai thác","description":"Mọi khoá của doanh nghiệp. plan, mode (api = tự xây bot · bot = dùng bot khachhang.app), ai { enabled, api, doc }, news[{ slug, name, api }] (mảng tin đọc được), knowledge[{ slug, name, api }] (kiến thức chuyên ngành của gói), sync (phạm vi /v1/sync: knowledge kinds, news, events, ping_url có / không — null khi chưa cấp), features[{ key, label, group, desc, api, doc }] (tính năng dữ liệu / AI của gói), limits, docs.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/overview":{"get":{"tags":["Account"],"summary":"Tổng quan doanh nghiệp","description":"Lượt gọi + chi phí AI tháng, hạn mức đã dùng ≥ 80%, việc cần làm (tài liệu bot lỗi, đánh giá bot chưa tốt 7 ngày), các bước thiết lập đã xong. leads / tasks / kn_desk luôn null (CRM, Phòng biên tập đã gỡ 27/11/2026).","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/storage":{"get":{"tags":["Account"],"summary":"Dung lượng & chi phí AI","description":"Dung lượng (cơ sở dữ liệu, file, bản sao lưu, vector), chi phí AI tháng này / tháng trước (khoá khachhang.app + hạn mức, khoá riêng), 30 ngày.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/storage/refresh":{"post":{"tags":["Account"],"summary":"Tính lại dung lượng","description":"Khoá quản trị; chạy nền ~1 phút.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/backups":{"get":{"tags":["Account"],"summary":"Bản sao lưu","description":"Khoá quản trị. Danh sách sao lưu / phục hồi, `limit` theo gói, `restorable`.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Account"],"summary":"Sao lưu ngay","description":"Chạy nền; không gồm dữ liệu cá nhân người nhận thông báo.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ label? }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/backups/{id}":{"get":{"tags":["Account"],"summary":"Trạng thái sao lưu / phục hồi","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã việc","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"delete":{"tags":["Account"],"summary":"Xoá bản sao lưu","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã bản sao lưu","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/backups/{id}/download":{"get":{"tags":["Account"],"summary":"Tải bản sao lưu","description":"`.ndjson.gz` — mỗi dòng `{\"t\":\"<db>.<bảng>\",\"r\":{…}}`, dòng đầu `_manifest`.","parameters":[{"name":"id","in":"path","required":true,"description":"mã bản sao lưu","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/backups/{id}/link":{"post":{"tags":["Account"],"summary":"Link tải bản sao lưu","description":"Trả `{ url, expires_at }` — link ký ở `https://media.p2c.tech/p/backup/…`, hết hạn sau 15 phút; mở bằng trình duyệt / curl không cần khoá.","parameters":[{"name":"id","in":"path","required":true,"description":"mã bản sao lưu","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/kb/{id}/file-link":{"post":{"tags":["Account"],"summary":"Link tải tệp gốc kiến thức","description":"Tài liệu loại `file` tải lên từ 24/11/2026: `{ url, expires_at }` ở media.p2c.tech/p/kb/…, hết hạn 15 phút.","parameters":[{"name":"id","in":"path","required":true,"description":"mã tài liệu","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/notifications":{"get":{"tags":["Account"],"summary":"Hộp thông báo","description":"Thành viên đăng nhập email: `{ unread, items[{ id, at, kind, title, body, href, read_at }], next }`. GET `/count`, POST `/read` `{ ids | all }`, GET / PUT `/prefs` (nhận email theo loại).","parameters":[{"name":"unread","in":"query","description":"1 = chỉ chưa đọc","required":false,"schema":{"type":"string"}},{"name":"before","in":"query","description":"id","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/email":{"get":{"tags":["Account"],"summary":"Email — thiết lập, mẫu thư, nhật ký","description":"Tính năng `email`, quyền quản trị. Thứ tự gửi: SMTP riêng → (fallback_system) máy chủ gửi thư của khachhang.app → SMTP hệ thống. Nhật ký chỉ có địa chỉ đã che.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/email/settings":{"put":{"tags":["Account"],"summary":"Lưu thiết lập email / SMTP","description":"`{ from_name, reply_to, fallback_system, smtp: { enabled, host, port: 465|587|2525, secure: tls|starttls, user, password (null = xoá), from } }` — mật khẩu mã hoá, không trả lại.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/email/test":{"post":{"tags":["Account"],"summary":"Gửi thư thử","description":"`{ to, via?: auto|smtp, template? }` — tối đa 10 thư / giờ.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/email/templates/{key}":{"put":{"tags":["Account"],"summary":"Sửa mẫu thư","description":"`member_invite` · `password_reset` · `deletion_requested` · `deletion_canceled` — `{ subject, title, body, button, foot, enabled }`, biến `{{tên}}`. DELETE: về mẫu hệ thống.","parameters":[{"name":"key","in":"path","required":true,"description":"mã mẫu","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/email/templates/{key}/preview":{"post":{"tags":["Account"],"summary":"Xem trước mẫu thư","description":"Trả `{ subject, html, text }` với dữ liệu mẫu.","parameters":[{"name":"key","in":"path","required":true,"description":"mã mẫu","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/backups/{id}/restore":{"post":{"tags":["Account"],"summary":"Phục hồi từ bản sao lưu","description":"Thay dữ liệu hiện tại của các mục chọn; tự tạo bản an toàn trước. `confirm` = mã tài khoản (slug).","parameters":[{"name":"id","in":"path","required":true,"description":"mã bản sao lưu","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ tables?: string[], confirm }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/members":{"get":{"tags":["Account"],"summary":"Thành viên","description":"Danh sách thành viên đăng nhập email, vai trò, hạn mức.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Account"],"summary":"Mời thành viên","description":"Chủ / quản trị. Gửi email mời; chưa gửi được thì trả `url`.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ email, name?, role: owner | admin | manager | sale | viewer }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/account/members/{id}":{"patch":{"tags":["Account"],"summary":"Đổi thành viên","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã thành viên","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ role?, status?: active | disabled, name? }","content":{"application/json":{"schema":{"type":"object"}}}}},"delete":{"tags":["Account"],"summary":"Xoá thành viên","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã thành viên","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/members/{id}/resend":{"post":{"tags":["Account"],"summary":"Gửi lại lời mời / link đặt mật khẩu","description":"","parameters":[{"name":"id","in":"path","required":true,"description":"mã thành viên","schema":{"type":"string"}}],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/account/deletion":{"get":{"tags":["Account"],"summary":"Yêu cầu xoá tài khoản","description":"Yêu cầu hiện tại + lịch sử.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Account"],"summary":"Yêu cầu xoá tài khoản","description":"Ngừng phục vụ ngay, xoá hẳn sau 30 ngày (huỷ được trong thời gian chờ). `confirm` = slug.","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ reason?, confirm }","content":{"application/json":{"schema":{"type":"object"}}}}},"delete":{"tags":["Account"],"summary":"Huỷ yêu cầu xoá","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/notify/channels":{"get":{"tags":["Notify"],"summary":"Kênh thông báo","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Notify"],"summary":"Thêm kênh","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"{ kind, name, token | webhook_url | fcm_service_account | relay_url }","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/notify/rules":{"get":{"tags":["Notify"],"summary":"Quy tắc loại tin → kênh","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}},"post":{"tags":["Notify"],"summary":"Thêm / sửa quy tắc","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}},"requestBody":{"required":true,"description":"quy tắc","content":{"application/json":{"schema":{"type":"object"}}}}}},"/v1/notify/recipients":{"get":{"tags":["Notify"],"summary":"Người nhận tin cá nhân","description":"","parameters":[],"responses":{"200":{"description":"Thành công — { ok: true, … }"},"400":{"$ref":"#/components/responses/Bad"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}}}}