Skip to main content

Peep OA — Public API Documentation

Overview

Public API สำหรับให้ภายนอก (3rd-party) เชื่อมต่อกับระบบ Peep Official Account เพื่อส่งข้อความไปหาผู้ใช้ผ่าน OA

Base URL:

https://oa-api.peepshare.ai

Postman Collection: Download — Import เข้า Postman เพื่อทดสอบ API ได้ทันที


Table of Contents


Authentication

Public API ใช้ระบบ API Key + JWT Token

ขั้นตอน:

  1. ได้รับ api_key และ api_secret จากทีม admin
  2. เรียก POST /api/v2/public/auth/token เพื่อรับ access_token และ refresh_token
  3. ใส่ access_token ใน Header ทุก request:
    Authorization: Bearer <access_token>
  4. เมื่อ token หมดอายุ ใช้ POST /api/v2/public/auth/refresh-token เพื่อขอ token ใหม่

Rate Limiting

Endpoint GroupLimit
ทุก endpoint200 requests / นาที
/api/v2/public/upload20 requests / นาที

เมื่อเกิน rate limit จะได้ HTTP 429 Too Many Requests:

{
"statusCode": 429,
"data": "ThrottlerException: Too Many Requests",
"timestamp": "2026-07-22 17:23:30",
"path": "/api/v2/public/webhook/broadcast-greeting"
}

Response Format

Success Response

ทุก response สำเร็จจะถูก wrap ด้วย data field:

{
"data": { ... }
}

Error Response

เมื่อเกิด error จะมีรูปแบบ:

{
"statusCode": 404,
"data": {
"statusCode": 404,
"code": "NOT_FOUND",
"info": "not found account_provider in db"
},
"timestamp": "2026-07-22 15:46:10",
"path": "/api/v2/public/webhook/broadcast-greeting"
}
FieldTypeDescription
statusCodenumberHTTP status code
data.codestringError code (ดูตารางด้านล่าง)
data.infostringรายละเอียด error
timestampstringเวลาที่เกิด error
pathstringEndpoint ที่เรียก

Error Codes:

CodeHTTP Statusคำอธิบาย
UNAUTHORIZED401Token ไม่ถูกต้องหรือหมดอายุ
NOT_FOUND404ไม่พบข้อมูลที่ร้องขอ
BAD_REQUEST400ข้อมูลไม่ถูกต้อง
JOB_BUSY400มี broadcast job กำลังทำงานอยู่
INTERNAL_SERVER_ERROR500ข้อผิดพลาดภายในระบบ

Endpoints


1. Generate Token

สร้าง access token สำหรับเรียก API

POST /api/v2/public/auth/token

Authentication: ไม่ต้อง (ใช้ api_key + api_secret แทน)

Request Body:

FieldTypeRequiredDescription
api_keystringAPI Key ที่ได้รับ
api_secretstringAPI Secret ที่ได้รับ

Example Request:

curl -X POST https://<domain>/api/v2/public/auth/token \
-H "Content-Type: application/json" \
-d '{
"api_key": "pk_abc123...",
"api_secret": "sk_xyz789..."
}'

Example Response:

{
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"refresh_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "Bearer",
"expires_in": "1h"
}
}

2. Refresh Token

ขอ access token ใหม่เมื่อ token หมดอายุ

POST /api/v2/public/auth/refresh-token

Authentication: ไม่ต้อง

Request Body:

FieldTypeRequiredDescription
refresh_tokenstringRefresh token ที่ได้จาก Generate Token

Example Request:

curl -X POST https://<domain>/api/v2/public/auth/refresh-token \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "eyJhbGciOiJIUzI1NiIs..."
}'

Example Response:

{
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"refresh_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "Bearer",
"expires_in": "1h"
}
}

3. Broadcast Greeting

ส่ง greeting message (ข้อความต้อนรับที่ตั้งค่าไว้ใน OA) ไปหา user

POST /api/v2/public/webhook/broadcast-greeting

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
user_idstringUser ID ของผู้รับ

Example Request:

curl -X POST https://<domain>/api/v2/public/webhook/broadcast-greeting \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"user_id": "user_123456"
}'

Example Response:

{
"data": {
"id": "uuid-of-greeting",
"title": "Welcome Message",
"slug": "welcome-message",
"data": [
{
"type": "message",
"msg": "สวัสดีครับ ยินดีต้อนรับ!"
}
]
}
}

ส่งรูปภาพไปหา user โดย link ใส่หรือไม่ใส่ก็ได้ — ถ้าใส่จะฝัง link ลงไปในรูป (กดที่รูปแล้วเปิด URL) ถ้าไม่ใส่จะเป็นรูปภาพธรรมดา

POST /api/v2/public/webhook/broadcast-image-link

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
user_idstringUser ID ของผู้รับ
image_urlstringURL ของรูปภาพ
linkstringURL ที่ฝังในรูป (ถ้าใส่ = กดรูปแล้วเปิด link, ถ้าไม่ใส่ = รูปธรรมดา)

Example Request:

curl -X POST https://<domain>/api/v2/public/webhook/broadcast-image-link \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"user_id": "user_123456",
"image_url": "https://images.unsplash.com/photo-1564760290292-23341e4df6ec?q=80&w=1740&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
"link": "https://example.com/landing-page"
}'

Example Response:

{
"data": "success"
}

5. Broadcast Message (Single User)

ส่งข้อความ text ไปหา user คนเดียว

POST /api/v2/public/webhook/broadcast-message

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
user_idstringUser ID ของผู้รับ
msgstringเนื้อหาข้อความหลัก
descstringข้อความเล็กที่แสดงบน push notification

Example Request:

curl -X POST https://<domain>/api/v2/public/webhook/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"user_id": "user_123456",
"msg": "สวัสดีครับ คุณมีข้อความใหม่",
"desc": "แจ้งเตือน"
}'

Example Response:

{
"data": "success"
}

6. Broadcast Message (Mass)

Broadcast ข้อความไปหาผู้ใช้หลายคน หรือทุกคน

POST /api/v2/public/message/broadcast-message

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
targetstringประเภทการส่ง: all, selected, single
user_idsstring[]❌*รายการ User IDs (*จำเป็นเมื่อ target = selected หรือ single)
itemsarrayรายการข้อความ (สูงสุด 5 items)

Item Object:

FieldTypeRequiredDescription
typestringประเภทข้อความ (ดู Message Item Types)
msgstring | string[]เนื้อหาข้อความ
descstringคำอธิบาย (สูงสุด 170 ตัวอักษร)
linkstringURL link (สำหรับ type = oa_image_link)
audio_uuidstring❌*UUID ที่ได้จาก POST /upload/audio (*จำเป็นเมื่อ type = audio)
audio_sizenumber❌*ขนาดไฟล์เสียง หน่วย bytes (*จำเป็นเมื่อ type = audio)
audio_durationnumber❌*ความยาวเสียง หน่วยวินาที (*จำเป็นเมื่อ type = audio)

Example Request — type message (ข้อความ text):

curl -X POST https://<domain>/api/v2/public/message/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"target": "selected",
"user_ids": ["user_001", "user_002", "user_003"],
"items": [
{
"type": "message",
"msg": "สวัสดีครับ นี่คือข้อความ broadcast",
"desc": "ข้อความเล็กบน push notification"
}
]
}'

Example Request — type oa_image_link (รูปภาพพร้อม link):

curl -X POST https://<domain>/api/v2/public/message/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"target": "all",
"items": [
{
"type": "oa_image_link",
"msg": "https://images.unsplash.com/photo-1564760290292-23341e4df6ec?q=80&w=1740&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
"link": "https://example.com/promo",
"desc": "โปรโมชั่นพิเศษวันนี้"
}
]
}'

Example Request — type image (รูปภาพธรรมดา ไม่มี link):

curl -X POST https://<domain>/api/v2/public/message/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"target": "single",
"user_ids": ["user_001"],
"items": [
{
"type": "image",
"msg": "https://images.unsplash.com/photo-1564760290292-23341e4df6ec?q=80&w=1740&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}
]
}'

Example Request — type flex (flex message):

curl -X POST https://<domain>/api/v2/public/message/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"target": "selected",
"user_ids": ["user_001"],
"items": [
{
"type": "flex",
"msg": "{\"type\":\"bubble\",\"hero\":{\"type\":\"image\",\"url\":\"https://developers-resource.landpress.line.me/fx/img/01_1_cafe.png\",\"size\":\"full\",\"aspectRatio\":\"20:13\",\"aspectMode\":\"cover\",\"action\":{\"type\":\"uri\",\"uri\":\"https://line.me/\"}},\"body\":{\"type\":\"box\",\"layout\":\"vertical\",\"contents\":[{\"type\":\"text\",\"text\":\"Brown Cafe\",\"weight\":\"bold\",\"size\":\"xl\"},{\"type\":\"box\",\"layout\":\"vertical\",\"margin\":\"lg\",\"spacing\":\"sm\",\"contents\":[{\"type\":\"box\",\"layout\":\"baseline\",\"spacing\":\"sm\",\"contents\":[{\"type\":\"text\",\"text\":\"Place\",\"color\":\"#aaaaaa\",\"size\":\"sm\",\"flex\":1},{\"type\":\"text\",\"text\":\"Flex Tower, 7-7-4 Midori-ku, Tokyo\",\"wrap\":true,\"color\":\"#666666\",\"size\":\"sm\",\"flex\":5}]},{\"type\":\"box\",\"layout\":\"baseline\",\"spacing\":\"sm\",\"contents\":[{\"type\":\"text\",\"text\":\"Time\",\"color\":\"#aaaaaa\",\"size\":\"sm\",\"flex\":1},{\"type\":\"text\",\"text\":\"10:00 - 23:00\",\"wrap\":true,\"color\":\"#666666\",\"size\":\"sm\",\"flex\":5}]}]}]},\"footer\":{\"type\":\"box\",\"layout\":\"vertical\",\"spacing\":\"sm\",\"contents\":[{\"type\":\"button\",\"style\":\"link\",\"height\":\"sm\",\"action\":{\"type\":\"uri\",\"label\":\"CALL\",\"uri\":\"https://line.me/\"}},{\"type\":\"button\",\"style\":\"link\",\"height\":\"sm\",\"action\":{\"type\":\"uri\",\"label\":\"WEBSITE\",\"uri\":\"https://line.me/\"}},{\"type\":\"box\",\"layout\":\"vertical\",\"contents\":[],\"margin\":\"sm\"}],\"flex\":0}}",
"desc": "Brown Cafe"
}
]
}'

Example Request — type video:

ใช้ ticket_id ที่ได้จาก Upload Video เป็นค่า msg

curl -X POST https://<domain>/api/v2/public/message/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"target": "all",
"items": [
{
"type": "video",
"msg": "0e45c26c-cff3-45cb-b51d-876d55d40bea",
"desc": "New product clip"
}
]
}'

⚠️ ต้องรอให้ transcode เสร็จก่อน ถ้า ticket ยังแปลงไฟล์ไม่เสร็จ job broadcast จะทำงานล้มเหลว

Example Request — type audio:

ใช้ค่าที่ได้จาก Upload Audio: ใส่ audio_url ใน msg ส่วนอีก 3 ค่าใส่ใน item เดียวกัน

curl -X POST https://<domain>/api/v2/public/message/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"target": "selected",
"user_ids": ["user_001"],
"items": [
{
"type": "audio",
"msg": "https://example.cos.ap-bangkok.myqcloud.com/uploads/public/my-oa-slug/audios/2026/08/31/audio-1756612345678-123456789/a1b2c3d4e5f6.mp3",
"audio_uuid": "7f3a19b2-8c41-4d2e-9a05-1b6e4c7d8f90",
"audio_size": 241206,
"audio_duration": 15,
"desc": "Voice announcement"
}
]
}'

Example Response:

{
"data": {
"id": "broadcast-uuid",
"data": [
{
"type": "message",
"msg": "สวัสดีครับ นี่คือข้อความ broadcast"
}
],
"broadcast_at": "2025-07-22 10:30:00",
"created_at": "2025-07-22 10:30:00",
"estimate_time_detail": {
"total_job_time_minutes": 2
}
}
}

7. Broadcast Group Message

Broadcast ข้อความไปหาสมาชิกทั้งหมดในกลุ่ม

POST /api/v2/public/message/broadcast-group-message

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
account_provider_group_idstringUUID ของกลุ่มที่ต้องการส่ง
itemsarrayรายการข้อความ (สูงสุด 5 items, รูปแบบเดียวกับ Item Object)

รองรับ item type video และ audio ด้วย โดยใช้ field ชุดเดียวกับ Broadcast Message (Mass)

Example Request:

curl -X POST https://<domain>/api/v2/public/message/broadcast-group-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"account_provider_group_id": "group-uuid-abc123",
"items": [
{
"type": "message",
"msg": "ข้อความถึงสมาชิกในกลุ่ม"
},
{
"type": "oa_image_link",
"msg": "https://example.com/event.jpg",
"link": "https://example.com/event",
"desc": "งาน Event สุดพิเศษ"
}
]
}'

Example Response:

{
"data": {
"id": "broadcast-uuid",
"data": [...],
"broadcast_at": "2025-07-22 10:30:00",
"created_at": "2025-07-22 10:30:00",
"estimate_time_detail": {
"total_job_time_minutes": 1
}
}
}

8. Broadcast Member Session

Broadcast ข้อความไปหาสมาชิกใน member group broadcast session

POST /api/v2/public/message/broadcast-member-session

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
member_group_broadcast_idstringUUID ของ member group broadcast
itemsarrayรายการข้อความ (สูงสุด 5 items, รูปแบบเดียวกับ Item Object)

รองรับ item type video และ audio ด้วย โดยใช้ field ชุดเดียวกับ Broadcast Message (Mass)

Example Request:

curl -X POST https://<domain>/api/v2/public/message/broadcast-member-session \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"member_group_broadcast_id": "mgb-uuid-xyz789",
"items": [
{
"type": "message",
"msg": "ข้อความสำหรับ member session"
}
]
}'

Example Response:

{
"data": {
"id": "broadcast-uuid",
"data": [...],
"broadcast_at": "2025-07-22 10:30:00",
"created_at": "2025-07-22 10:30:00",
"estimate_time_detail": {
"total_job_time_minutes": 3
}
}
}

Upload

Endpoint สำหรับอัปโหลดไฟล์ media เพื่อเอา url / ticket ไปใช้ต่อกับ endpoint broadcast ด้านล่าง

  • ใช้ Content-Type: multipart/form-data
  • ต้องส่ง Authorization: Bearer <access_token> เหมือน endpoint อื่น
  • ไฟล์ถูกเก็บแยกตาม account provider ที่ผูกกับ token และทุกครั้งที่อัปจะถูกบันทึกว่า api key ไหน / slug ไหน / service อะไร / IP ใด เป็นคนอัป

⚠️ รูปที่อัปถูก serve เป็น static file แบบ public — ใครรู้ URL ก็เปิดดูได้ (ชื่อไฟล์เป็น random) อย่าอัปไฟล์ที่เป็นความลับ


9. Upload Image

อัปโหลดรูปภาพ แล้วได้ url ไปใช้ต่อกับ Broadcast Image Link หรือ message item ชนิด image / oa_image_link

POST /api/v2/public/upload/image

Authentication: Bearer Token Content-Type: multipart/form-data

Form Data:

FieldTypeRequiredDescription
filefileJPG / JPEG / PNG / WEBP — ขนาดไม่เกิน 5 MB

Example Request:

curl -X POST https://<domain>/api/v2/public/upload/image \
-H "Authorization: Bearer <access_token>" \
-F "file=@/path/to/image.jpg"

Example Response:

{
"data": {
"src_file": "uploads/public/my-oa-slug/images/2026/08/31/a1b2c3d4e5f6.jpg",
"url": "https://oa-api.peepshare.ai/uploads/public/my-oa-slug/images/2026/08/31/a1b2c3d4e5f6.jpg"
}
}

10. Upload Video

อัปโหลดวิดีโอ ระบบจะสร้าง transcode job แล้วคืน ticket_id เอาไปใช้กับ Broadcast Video

POST /api/v2/public/upload/video

Authentication: Bearer Token Content-Type: multipart/form-data

Form Data:

FieldTypeRequiredDescription
videofileMP4 / AVI / MKV / MOV / WEBM / OGG / 3GP / 3G2 — ไม่เกิน 100 MB

Example Request:

curl -X POST https://<domain>/api/v2/public/upload/video \
-H "Authorization: Bearer <access_token>" \
-F "video=@/path/to/clip.mp4"

Example Response:

{
"data": {
"ticket_id": "0e45c26c-cff3-45cb-b51d-876d55d40bea"
}
}

การแปลงไฟล์ทำแบบ async — รอ transcode เสร็จก่อนค่อยเรียก broadcast-video ด้วย ticket_id นี้


11. Upload Audio

อัปโหลดไฟล์เสียงขึ้น Tencent COS แล้วได้ค่าครบสำหรับ Broadcast Audio

POST /api/v2/public/upload/audio

Authentication: Bearer Token Content-Type: multipart/form-data

Form Data:

FieldTypeRequiredDescription
audiofileMP3 / WAV / OGG / M4A / AAC — ไม่เกิน 100 MB

Example Request:

curl -X POST https://<domain>/api/v2/public/upload/audio \
-H "Authorization: Bearer <access_token>" \
-F "audio=@/path/to/voice.mp3"

Example Response:

{
"data": {
"audio_url": "https://example.cos.ap-bangkok.myqcloud.com/uploads/public/my-oa-slug/audios/2026/08/31/audio-1756612345678-123456789/a1b2c3d4e5f6.mp3",
"audio_uuid": "0e45c26c-cff3-45cb-b51d-876d55d40bea",
"audio_size": 241206,
"audio_duration": 15
}
}

ส่งทั้ง 4 ค่า (audio_url, audio_uuid, audio_size, audio_duration) ต่อให้ broadcast-audio ตรงๆ

Error Response (ไฟล์ไม่รองรับ):

{
"statusCode": 400,
"code": "BAD_REQUEST",
"info": "Invalid audio file type: application/pdf"
}

12. Broadcast Video

ส่งวิดีโอไปหา user คนเดียว โดยใช้ ticket_id จาก Upload Video

POST /api/v2/public/webhook/broadcast-video

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
user_idstringUser ID ของผู้รับ
ticket_idstringticket ที่ได้จาก POST /upload/video

Example Request:

curl -X POST https://<domain>/api/v2/public/webhook/broadcast-video \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"user_id": "user_123456",
"ticket_id": "0e45c26c-cff3-45cb-b51d-876d55d40bea"
}'

Example Response:

{
"data": "success"
}

Error Response (transcode ยังไม่เสร็จ):

{
"statusCode": 400,
"code": "BAD_REQUEST",
"info": "video is process convert status"
}

13. Broadcast Audio

ส่งไฟล์เสียงไปหา user คนเดียว โดยใช้ค่าจาก Upload Audio

POST /api/v2/public/webhook/broadcast-audio

Authentication: Bearer Token

Request Body:

FieldTypeRequiredDescription
user_idstringUser ID ของผู้รับ
audio_urlstringURL ที่ได้จาก POST /upload/audio
audio_uuidstringUUID ที่ได้จาก upload
audio_sizenumberขนาดไฟล์ (byte)
audio_durationnumberความยาว (วินาที)

Example Request:

curl -X POST https://<domain>/api/v2/public/webhook/broadcast-audio \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"user_id": "user_123456",
"audio_url": "https://example.cos.ap-bangkok.myqcloud.com/uploads/public/my-oa-slug/audios/2026/08/31/audio-1756612345678-123456789/a1b2c3d4e5f6.mp3",
"audio_uuid": "0e45c26c-cff3-45cb-b51d-876d55d40bea",
"audio_size": 241206,
"audio_duration": 15
}'

Example Response:

{
"data": "success"
}

Message Item Types

TypeDescriptionmsg Formatต้องมี link?
messageข้อความ text ธรรมดาstring
oa_image_linkรูปภาพที่กดแล้วเปิด linkstring (URL รูป)
imageรูปภาพธรรมดา (ไม่มี link)string (URL รูป)
flexFlex messagestring (JSON format)
videoวิดีโอstring (ticket_id จาก Upload Video)
audioไฟล์เสียงstring (audio_url จาก Upload Audio)
  • item type audio ต้องส่ง audio_uuid, audio_size และ audio_duration ใน item เดียวกัน — ใช้ค่าที่ได้จาก POST /upload/audio โดยตรง
  • item type video ส่งเฉพาะ ticket_id โดยต้อง transcode เสร็จก่อนจึง broadcast ได้
  • video และ audio ใช้ได้ทั้ง broadcast-message, broadcast-group-message และ broadcast-member-session

Webhook Events

เมื่อ Peep OA ได้รับ event จาก client ระบบจะส่งต่อ event ไปยัง webhook_url ที่ตั้งค่าไว้สำหรับบัญชี OA โดย request body จะมี event payload ตามรายละเอียดด้านล่าง

Message Event

ระบบจะส่ง event ประเภท message เมื่อ client ส่งข้อความมายังบัญชี OA

ตัวอย่าง Payload:

{
"event_type": "message",
"username": "example-oa",
"data": {
"MsgVersion": 0,
"MsgBody": [{}],
"CallbackCommand": "C2C.CallbackAfterSendMsg",
"InstanceId": 108534120,
"From_Account": "example-user",
"To_Account": "example-oa",
"MsgRandom": 3243647983,
"MsgSeq": 2384864640,
"MsgTime": 1787725633,
"SupportMessageExtension": 0,
"MsgKey": "2384864640_3243647983_1787725633",
"MsgId": "144115266418381458-1787725634-3243647983",
"OnlineOnlyFlag": 0,
"SendMsgResult": 0,
"ErrorInfo": "send msg succeed",
"UnreadMsgNum": 4,
"EventTime": 1787725633786,
"OfflinePushInfo": {
"PushFlag": 0,
"Desc": "hi",
"Ext": "{\"userId\":\"example-user\",\"groupId\":null,\"senderName\":\"Example User\",\"Title\":\"Example User\"}"
}
},
"timestamp": "2026-08-26T06:27:15.227Z"
}
FieldTypeDescription
event_typestringประเภทของ event โดย message หมายถึง event ข้อความ
usernamestringusername ของบัญชี OA ที่ได้รับ event
dataobjectข้อมูล message event ต้นฉบับที่ได้รับจาก client
timestampstringเวลาที่สร้าง webhook payload ในรูปแบบ ISO 8601 เวลา UTC

field ภายใน data มาจาก message event ของ client และอาจแตกต่างกันตามประเภทข้อความ ระบบปลายทางควรรองรับ field ที่ไม่รู้จักและตรวจสอบ optional field ก่อนใช้งาน

ประเภทของ Message Body

array data.MsgBody ประกอบด้วย message element ตั้งแต่หนึ่งรายการขึ้นไป แต่ละรายการมี MsgType และ object MsgContent ที่สอดคล้องกัน

รูปภาพ (TIMImageElem)

ImageInfoArray เก็บรูปภาพแต่ละขนาดที่ client ส่งมา โดย Type ใช้ระบุประเภทของรูป เช่น รูปต้นฉบับ รูปขนาดใหญ่ หรือ thumbnail

[
{
"MsgType": "TIMImageElem",
"MsgContent": {
"UUID": "20008744_144115266418381458_4f6b4d0a394f144dc3879d41fa6df54b.heic",
"ImageFormat": 255,
"ImageInfoArray": [
{
"Type": 1,
"Size": 991921,
"Width": 2268,
"Height": 4032,
"URL": "https://sgp.rich.my-imcloud.com/download/4f6b4d0a394f144dc3879d41fa6df54b.heic?<signed-query>"
},
{
"Type": 2,
"Size": 0,
"Width": 720,
"Height": 1280,
"URL": "https://sgp.rich.my-imcloud.com/download/4f6b4d0a394f144dc3879d41fa6df54b.heic?<signed-query>"
},
{
"Type": 3,
"Size": 0,
"Width": 198,
"Height": 352,
"URL": "https://sgp.rich.my-imcloud.com/download/4f6b4d0a394f144dc3879d41fa6df54b.heic?<signed-query>"
}
]
}
}
]
วิดีโอ (TIMVideoFileElem)
[
{
"MsgType": "TIMVideoFileElem",
"MsgContent": {
"VideoSize": 13268689,
"VideoSecond": 20,
"VideoFormat": "",
"ThumbSize": 86043,
"ThumbWidth": 360,
"ThumbHeight": 640,
"ThumbFormat": "",
"VideoDownloadFlag": 2,
"VideoUUID": "20008744_144115266418381458_23a1703fdea76870a2bafc8cd3cc8459.mp4",
"VideoUrl": "https://sgp.rich.my-imcloud.com/download/23a1703fdea76870a2bafc8cd3cc8459.mp4?<signed-query>",
"ThumbDownloadFlag": 2,
"ThumbUUID": "20008744_144115266418381458_1793dac254d4219958da85e26f6f90ad.jpg",
"ThumbUrl": "https://sgp.rich.my-imcloud.com/download/1793dac254d4219958da85e26f6f90ad.jpg?<signed-query>"
}
}
]
เสียง (TIMSoundElem)
[
{
"MsgType": "TIMSoundElem",
"MsgContent": {
"Size": 108883,
"Second": 3,
"Download_Flag": 2,
"UUID": "20008744_144115266418381458_af2c32622a92b0ce83e916b43c0de65f.m4a",
"Url": "https://sgp.rich.my-imcloud.com/download/af2c32622a92b0ce83e916b43c0de65f.m4a?<signed-query>"
}
}
]

URL สำหรับดาวน์โหลดมี signed query parameters แบบชั่วคราว ระบบปลายทางควรใช้ URL แบบเต็มที่ได้รับจาก webhook payload และไม่ควรบันทึกหรือ hard-code URL จากตัวอย่าง


Quick Start

# 1. ขอ token
TOKEN=$(curl -s -X POST https://<domain>/api/v2/public/auth/token \
-H "Content-Type: application/json" \
-d '{"api_key":"pk_...","api_secret":"sk_..."}' | jq -r '.data.access_token')

# 2. ส่งข้อความไปหา user
curl -X POST https://<domain>/api/v2/public/webhook/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"user_id": "target_user_id",
"msg": "Hello from API!"
}'

# 3. Broadcast ไปหาทุกคน
curl -X POST https://<domain>/api/v2/public/message/broadcast-message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{
"target": "all",
"items": [{"type": "message", "msg": "📢 ประกาศสำคัญ!"}]
}'