Skip to Content
🚀 Welcome to Humansoft Open API Documentation

List Chatroom

API สำหรับขอรายการห้อง HumanSoft Notify ของบริษัท เพื่อนำ chat_token ของห้องไปใช้ส่งข้อความผ่าน Send Message

Endpoint

GET /api/v1/open-apis/hms-notify/list-chatroom

สิทธิ์ที่ต้องการ: API Key ต้องมีสิทธิ์ การส่งข้อความ HumanSoft Notify (notify:send)

Request Parameters

ส่งเป็น query string เท่านั้น (ไม่รับ request body) — หากรหัสพนักงานมีอักขระพิเศษ ให้ URL-encode ก่อน

ParameterTypeRequiredDescriptionExample
employee_codestringYesรหัสพนักงานผู้ทำรายการ ต้องเป็นพนักงานของบริษัทที่ผูกกับ API Key และมีบัญชีผู้ใช้ในระบบ HumanSoftEMP001

employee_code ใช้ระบุผู้ทำรายการเท่านั้น — ใช้พนักงานคนใดก็ได้ที่มีบัญชีผู้ใช้ (ไม่จำเป็นต้องเป็น HR) และรายการห้องที่ได้คือห้อง HumanSoft Notify ทั้งหมดของบริษัท ไม่ได้กรองตามพนักงานที่ระบุ

Response Format

Success Response (HTTP 200)

{ "code": 200, "message": "Success", "payload": [ { "chat_id": "20251127D4573C421639", "chat_token": "20251127C4E8A2F6B1D3957E0A6C", "chat_image": null, "chat_display_name": "แจ้งเตือนฝ่ายบุคคล", "chat_member": "2", "created_name": "สมชาย", "created_surname": "ใจดี", "created": "2025-11-27 09:12:30", "member_list": [ { "chat_id": "20251127D4573C421639", "chat_user_id": "20251127A1B2C3D4E5F6", "role": "admin" }, { "chat_id": "20251127D4573C421639", "chat_user_id": "20251127F6E5D4C3B2A1", "role": "member" } ] } ] }

ถ้าบริษัทยังไม่มีห้อง HumanSoft Notify จะได้ HTTP 200 พร้อม payload เป็น array ว่าง ([])

Response Fields

FieldTypeNullableDescription
chat_idstringNoID ของห้อง (ค่า raw)
chat_tokenstringNotoken ของห้อง ใช้ระบุห้องใน Send Message — เป็นข้อมูลลับ ห้ามเปิดเผย
chat_imagestringYesรูปห้อง (อาจเป็น null หรือค่าว่าง)
chat_display_namestringYesชื่อห้อง
chat_memberstringNoจำนวนสมาชิกในห้อง ไม่นับบอท (ตัวเลขในรูปข้อความ เช่น "12")
created_namestringYesชื่อผู้สร้างห้อง
created_surnamestringYesนามสกุลผู้สร้างห้อง
createdstringYesวันเวลาที่สร้างห้อง รูปแบบ YYYY-MM-DD HH:mm:ss
member_listarrayYesสมาชิกในห้อง ไม่รวมบอท — เป็น null ถ้าห้องยังไม่มีสมาชิก

Member Fields (member_list[])

FieldTypeDescription
chat_idstringID ของห้อง (ค่า raw)
chat_user_idstringID ของสมาชิกในระบบแชท (ค่า raw)
rolestringบทบาทในห้อง เช่น admin, member

Error Response - Validation Failed (HTTP 400)

เกิดเมื่อส่ง employee_code เป็นค่าว่าง

{ "code": 400, "message": "Validation failed", "errors": ["'employee_code' query parameter is required"] }

Error Response - Missing employee_code (HTTP 404)

หากไม่ส่ง parameter employee_code มาเลย API Gateway จะตอบ HTTP 404 ก่อนถึงระบบ HumanSoft (รูปแบบ Response ต่างจากกรณีอื่น)

{ "statusCode": 404, "message": "Resource not found" }

Error Response - Employee Not Found (HTTP 400)

ไม่พบรหัสพนักงานนี้ในบริษัทที่ผูกกับ API Key

{ "code": 400, "message": "Employee not found with code: EMP001" }

Error Response - No User Account (HTTP 400)

พนักงานไม่มีบัญชีผู้ใช้ในระบบ HumanSoft — ใช้รหัสพนักงานที่มีบัญชีผู้ใช้ หรือสร้างบัญชีให้พนักงานก่อน

{ "code": 400, "message": "Employee EMP001 has no HumanSoft user account" }

Error Response - Could Not Load Chat Rooms (HTTP 400)

ดึงรายการห้องไม่สำเร็จ — API นี้ไม่เปลี่ยนแปลงข้อมูล จึงเรียกซ้ำได้ หากยังไม่สำเร็จให้ติดต่อ HumanSoft ตัวเลขในวงเล็บคือรหัสสถานะจากระบบต้นทาง ไม่ใช่ HTTP status ของ Response นี้ (ซึ่งเป็น 400 เสมอ)

{ "code": 400, "message": "Failed to load HumanSoft Notify chat rooms (HTTP 500)" }

หรือ "Could not connect to HumanSoft. Please try again" เมื่อเชื่อมต่อไม่ได้หรือการเชื่อมต่อหมดเวลา

HTTP StatusDescription
400employee_code เป็นค่าว่าง, ไม่พบพนักงาน, พนักงานไม่มีบัญชีผู้ใช้ หรือดึงรายการห้องไม่สำเร็จ
401API Key ไม่ถูกต้อง หรือไม่ได้ส่ง API Key
404ไม่ได้ส่ง parameter employee_code หรือเรียกด้วย method อื่นที่ไม่ใช่ GET
403API Key ไม่มีสิทธิ์ notify:send
500เกิดข้อผิดพลาดที่เซิร์ฟเวอร์ (message: Internal Server Error) — ติดต่อ HumanSoft

Validation Rules

ParameterValidationError Message
employee_codeต้องระบุใน query string และไม่เป็นค่าว่าง — หากไม่ส่ง parameter นี้เลยจะได้ HTTP 404 แทน'employee_code' query parameter is required
employee_codeต้องเป็นพนักงานของบริษัทที่ผูกกับ API Key (ระบบตัดช่องว่างหน้า-หลังให้)Employee not found with code: <employee_code>
employee_codeพนักงานต้องมีบัญชีผู้ใช้ในระบบ HumanSoftEmployee <employee_code> has no HumanSoft user account

Code Examples

curl -X GET "https://openapi.humansoft.co.th/api/v1/open-apis/hms-notify/list-chatroom?employee_code=EMP001" \ -H "Ocp-Apim-Subscription-Key: YOUR_API_KEY"

Notes

chat_token เป็นข้อมูลลับของห้อง: ผู้ที่มี chat_token ส่งข้อความเข้าห้องนั้นได้ เก็บรักษาเหมือน API Key — เก็บไว้ฝั่ง server เท่านั้น ห้ามแสดงหรือเก็บไว้ใน browser หรือแอป และห้ามบันทึกลง log

  • รายการเป็นชุดเดียวกับรายการห้องในเมนูตั้งค่า HumanSoft Notify ของระบบ HumanSoft
  • ห้องกลุ่มที่พนักงานสร้างเองในแอปไม่อยู่ในรายการนี้
  • คืนรายการทั้งหมดในครั้งเดียว ไม่แบ่งหน้า และไม่ได้เรียงลำดับตามเงื่อนไขใด
  • chat_id และ chat_user_id เป็นค่า raw — Send Message ใช้ chat_token เพื่อระบุห้อง ไม่ต้องใช้ค่าเหล่านี้

  • Send Message - ส่งข้อความเข้าห้องด้วย chat_token จาก API นี้
  • HumanSoft Notify Overview - ภาพรวมและขั้นตอนการใช้งาน
Last updated on