{"openapi":"3.1.0","info":{"title":"TailAdmin Agent & Member System API","version":"2.4.0","description":"ระบบ API เต็มรูปแบบที่เชื่อมต่อกับไฟล์ข้อมูลในเครื่อง (`backend/data/system-store.json`) และฐานข้อมูล PostgreSQL พร้อมเชื่อมกับหน้าเว็บ HTML ทุกหน้าในโปรเจกต์"},"servers":[{"url":"http://localhost:3000","description":"Frontend Dev Server (Webpack Proxy -> Backend :3001)"},{"url":"http://localhost:3001","description":"Next.js Backend API Server"}],"tags":[{"name":"System & Health","description":"สถานะระบบ บัญชีหลัก แจ้งเตือนปิดปรับปรุง และโดเมนทางเข้า"},{"name":"Authentication","description":"เข้าสู่ระบบ ออกจากระบบ เปลี่ยนรหัสผ่าน และสร้างพนักงาน"},{"name":"Members & Credit","description":"จัดการสมาชิก เพิ่มสมาชิก ปรับลด/เพิ่มเครดิต และตั้งค่าสถานะ"},{"name":"Product Settings","description":"ตั้งค่าเกม คาสิโน กีฬา หวย และส่วนแบ่งหุ้น (%keep / commission)"},{"name":"Finance & Billing","description":"รายงานฝาก-ถอน โอนเงินตามรอบบิล และบันทึกธุรกรรม"},{"name":"Reports & Football","description":"รายงานแพ้-ชนะ (Win/Lose) แยกตามสมาชิก ประเภทเกม และฟุตบอล"},{"name":"AMBSuperAPI Integration","description":"เชื่อมต่อ AMBSuperAPI (Transfer Wallet, Seamless Wallet, Game Launcher & Product Callbacks จาก doc.ambsuperapi.com)"},{"name":"Local Files","description":"จัดการอ่าน/เขียนไฟล์ในเครื่อง (Workspace & JSON Data Store)"}],"paths":{"/api/amb":{"get":{"tags":["AMBSuperAPI Integration"],"summary":"AMBSuperAPI GET Endpoints (getProducts, listGames, getBalance, getAgentCredit, checkPlayerStatus, getBetLimits, queryBetRecords)","parameters":[{"name":"action","in":"query","schema":{"type":"string","enum":["status","getProducts","listGames","getBalance","getAgentCredit","checkPlayerStatus","getBetLimits","queryBetRecords"]}},{"name":"productId","in":"query","schema":{"type":"string"},"example":"SEXY"},{"name":"username","in":"query","schema":{"type":"string"},"example":"RA022"}],"responses":{"200":{"description":"ข้อมูลจาก AMBSuperAPI Bridge"}}},"post":{"tags":["AMBSuperAPI Integration"],"summary":"AMBSuperAPI POST & Seamless Callbacks (createMember, deposit, withdraw, verifyDepositWithdraw, login, checkBalance, placeBets, settleBets)","requestBody":{"required":true,"content":{"application/json":{"example":{"action":"placeBets","id":"6849b62b-2b52-472a-88a4-c26c3371a62a","productId":"PGSOFT","username":"RA022","currency":"THB","txns":[{"id":"T-001","gameCode":"pgsoft_mahjongways2","status":"OPEN","roundId":"R-0001","betAmount":1000,"playInfo":"Mahjong Ways 2"}]}}}},"responses":{"200":{"description":"ดำเนินการและอัปเดตยอดเครดิตสมาชิกในไฟล์ระบบสำเร็จ"}}}},"/api/health":{"get":{"tags":["System & Health"],"summary":"ตรวจสอบสถานะการเชื่อมต่อ API, PostgreSQL และไฟล์ข้อมูลในเครื่อง","responses":{"200":{"description":"สถานะระบบปกติ พร้อมจำนวนข้อมูลใน Store"}}}},"/api/system":{"get":{"tags":["System & Health"],"summary":"ดึงข้อมูลภาพรวมบัญชี (My Account), รายการแจ้งเตือนซ่อมบำรุง (Main Menu) และโดเมนเว็บไซต์","responses":{"200":{"description":"ข้อมูลภาพรวมระบบทั้งหมด"}}},"post":{"tags":["System & Health"],"summary":"เพิ่มรายการแจ้งเตือนปิดปรับปรุง (maintenance), เพิ่มโดเมนทางเข้า (domain) หรืออัปเดตยอดบัญชีหลัก (account)","requestBody":{"required":true,"content":{"application/json":{"example":{"type":"maintenance","product":"Lotto Thai VIP","message":"อัปเกรดระบบ API เชื่อมต่อไฟล์ในเครื่อง","from":"19/11/2026 02:00","to":"19/11/2026 04:00","status":"active","severity":"success"}}}},"responses":{"201":{"description":"สร้างรายการสำเร็จ"}}}},"/api/auth/login":{"post":{"tags":["Authentication"],"summary":"เข้าสู่ระบบ (ค่าเริ่มต้น: admin / admin12345678 หรือ ra02 / ra0212345678)","requestBody":{"required":true,"content":{"application/json":{"example":{"username":"ra02","password":"ra0212345678"}}}},"responses":{"200":{"description":"เข้าสู่ระบบสำเร็จ พร้อมตั้งค่า HttpOnly Cookie"}}}},"/api/auth/me":{"get":{"tags":["Authentication"],"summary":"ตรวจสอบข้อมูลผู้ใช้ที่ล็อกอินอยู่ในปัจจุบัน","responses":{"200":{"description":"ข้อมูลผู้ใช้และสรุปยอดบัญชี"}}}},"/api/auth/change-password":{"post":{"tags":["Authentication"],"summary":"เปลี่ยนรหัสผ่านบัญชีผู้ใช้ (เชื่อมกับหน้า change-password.html)","requestBody":{"required":true,"content":{"application/json":{"example":{"username":"ra02","currentPassword":"ra0212345678","newPassword":"ra0212345678"}}}},"responses":{"200":{"description":"เปลี่ยนรหัสผ่านสำเร็จ"}}}},"/api/auth/logout":{"post":{"tags":["Authentication"],"summary":"ออกจากระบบและล้าง Session","responses":{"200":{"description":"ออกจากระบบสำเร็จ"}}}},"/api/members":{"get":{"tags":["Members & Credit"],"summary":"ดึงรายชื่อสมาชิกทั้งหมด รองรับการค้นหาตาม username, name, level","parameters":[{"name":"username","in":"query","schema":{"type":"string"},"description":"ค้นหาตาม Username เช่น RA022"},{"name":"name","in":"query","schema":{"type":"string"},"description":"ค้นหาตามชื่อสมาชิก"}],"responses":{"200":{"description":"รายการสมาชิกพร้อมยอดเครดิตคงเหลือ"}}},"post":{"tags":["Members & Credit"],"summary":"สร้างสมาชิกใหม่ (เชื่อมกับหน้า create-member.html และซิงค์ทุกหน้าตารางสมาชิก)","requestBody":{"required":true,"content":{"application/json":{"example":{"username":"RA035","name":"คุณกิตติ","tel":"081-999-8877","level":"Member","openingCredit":500000,"remainingBalance":500000,"enable":true,"internetBetting":true}}}},"responses":{"201":{"description":"สร้างสมาชิกใหม่สำเร็จ"}}},"patch":{"tags":["Members & Credit"],"summary":"แก้ไขข้อมูลสมาชิก เปิด/ปิดการใช้งาน หรือเติม/ตัดเครดิต (creditDelta)","requestBody":{"required":true,"content":{"application/json":{"example":{"username":"RA022","creditDelta":25000,"enable":true,"internetBetting":true}}}},"responses":{"200":{"description":"อัปเดตข้อมูลสมาชิกและบันทึกประวัติการเงินสำเร็จ"}}},"delete":{"tags":["Members & Credit"],"summary":"ลบสมาชิกออกจากระบบตาม username","parameters":[{"name":"username","in":"query","required":true,"schema":{"type":"string"},"example":"RA035"}],"responses":{"200":{"description":"ลบสมาชิกสำเร็จ"}}}},"/api/settings":{"get":{"tags":["Product Settings"],"summary":"ดึงข้อมูลการตั้งค่าเกม/คาสิโน/กีฬา/หวย (sportLSM, sport, casino, game, lotto, myLotto99)","parameters":[{"name":"category","in":"query","schema":{"type":"string","enum":["sportLSM","sport","casino","game","lotto","myLotto99"]}}],"responses":{"200":{"description":"ข้อมูลการตั้งค่าผลิตภัณฑ์"}}},"put":{"tags":["Product Settings"],"summary":"บันทึก/แก้ไขการตั้งค่าผลิตภัณฑ์หรือค่า %keep / commission รายสมาชิก","requestBody":{"required":true,"content":{"application/json":{"example":{"category":"casino","username":"RA022","updates":{"maxWin":"250,000","commission":"0.75","keep":"75.00","open":true}}}}},"responses":{"200":{"description":"บันทึกการตั้งค่าสำเร็จ"}}}},"/api/finance":{"get":{"tags":["Finance & Billing"],"summary":"ดึงรายการธุรกรรมฝาก-ถอน (Financial Report) และข้อมูลโอนตามรอบบิล (Transfer by Billing Cycle)","parameters":[{"name":"username","in":"query","schema":{"type":"string"}},{"name":"action","in":"query","schema":{"type":"string","enum":["All","Deposit","Withdraw"]}}],"responses":{"200":{"description":"รายการธุรกรรมและรอบบิล"}}},"post":{"tags":["Finance & Billing"],"summary":"ทำรายการฝากเงิน (Deposit) หรือถอนเงิน (Withdraw) ให้สมาชิก พร้อมปรับยอดเครดิตอัตโนมัติ","requestBody":{"required":true,"content":{"application/json":{"example":{"username":"RA022","product":"Sports","action":"Deposit","amount":50000,"note":"เติมเครดิตรอบดึก"}}}},"responses":{"201":{"description":"ทำรายการฝาก/ถอนสำเร็จ"}}}},"/api/reports":{"get":{"tags":["Reports & Football"],"summary":"ดึงข้อมูลรายงาน Win/Lose แยกตามสมาชิก, ประเภทสินค้า, บิลรอผล และตารางฟุตบอล","parameters":[{"name":"type","in":"query","schema":{"type":"string","enum":["by-member","by-product","football-events","football-members","football-winlose"]}}],"responses":{"200":{"description":"ข้อมูลรายงาน"}}}},"/api/files":{"get":{"tags":["Local Files"],"summary":"ดูรายการไฟล์ในเครื่อง (Workspace) หรืออ่านเนื้อหาไฟล์ (เช่น backend/data/system-store.json)","parameters":[{"name":"dir","in":"query","schema":{"type":"string"},"description":"โฟลเดอร์ย่อย เช่น src หรือ backend/data"},{"name":"file","in":"query","schema":{"type":"string"},"description":"พาธของไฟล์ที่ต้องการอ่าน เช่น backend/data/system-store.json"}],"responses":{"200":{"description":"รายการไฟล์หรือเนื้อหาไฟล์"}}},"post":{"tags":["Local Files"],"summary":"เขียนหรืออัปเดตไฟล์ในเครื่องโดยตรงผ่าน API","requestBody":{"required":true,"content":{"application/json":{"example":{"file":"backend/data/custom-note.json","content":"{\n  \"hello\": \"บันทึกไฟล์ลงเครื่องผ่าน API สำเร็จ\"\n}"}}}},"responses":{"200":{"description":"บันทึกไฟล์สำเร็จ"}}}}}}