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
ขั้นตอน:
- ได้รับ
api_keyและapi_secretจากทีม admin - เรียก
POST /api/v2/public/auth/tokenเพื่อรับaccess_tokenและrefresh_token - ใส่
access_tokenใน Header ทุก request:Authorization: Bearer <access_token> - เมื่อ token หมดอายุ ใช้
POST /api/v2/public/auth/refresh-tokenเพื่อขอ token ใหม่
Rate Limiting
| Endpoint Group | Limit |
|---|---|
| ทุก endpoint | 200 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"
}
| Field | Type | Description |
|---|---|---|
statusCode | number | HTTP status code |
data.code | string | Error code (ดูตารางด้านล่าง) |
data.info | string | รายละเอียด error |
timestamp | string | เวลาท ี่เกิด error |
path | string | Endpoint ที่เรียก |
Error Codes:
| Code | HTTP Status | คำอธิบาย |
|---|---|---|
UNAUTHORIZED | 401 | Token ไม่ถูกต้องหรือหมดอายุ |
NOT_FOUND | 404 | ไม่พบข้อมูลที่ร้องขอ |
BAD_REQUEST | 400 | ข้อมูลไม่ถูกต้อง |
JOB_BUSY | 400 | มี broadcast job กำลังทำงานอยู่ |
INTERNAL_SERVER_ERROR | 500 | ข้อผิดพลาดภายในระบบ |
Endpoints
1. Generate Token
สร้าง access token สำหรับเรียก API
POST /api/v2/public/auth/token
Authentication: ไม่ต้อง (ใช้ api_key + api_secret แทน)
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
api_key | string | ✅ | API Key ที่ได้รับ |
api_secret | string | ✅ | API 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:
| Field | Type | Required | Description |
|---|---|---|---|
refresh_token | string | ✅ | Refresh 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:
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | ✅ | User 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": "สวัสดีครับ ยินดีต้อนรับ!"
}
]
}
}
4. Broadcast Image Link
ส่งรูปภาพไปหา user โดย link ใส่หรือไม่ใส่ก็ได้ — ถ้าใส่จะฝัง link ลงไปในรูป (กดที่รูปแล้วเปิด URL) ถ้าไม่ใส่จะเป็นรูปภาพธรรมดา
POST /api/v2/public/webhook/broadcast-image-link
Authentication: Bearer Token
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | ✅ | User ID ของผู้รับ |
image_url | string | ✅ | URL ของรูปภาพ |
link | string | ❌ | URL ที่ฝังในรูป (ถ้าใส่ = กดรูปแล้วเปิด 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:
| Field | Type | Required | Description |
|---|---|---|---|
user_id | string | ✅ | User ID ของผู้รับ |
msg | string | ✅ | เนื้อหาข้อความหลัก |
desc | string | ❌ | ข้อความเล็กที่แสดงบน 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:
| Field | Type | Required | Description |
|---|---|---|---|
target | string | ✅ | ประเภทการส่ง: all, selected, single |
user_ids | string[] | ❌* | รายการ User IDs (*จำเป็นเมื่อ target = selected หรือ single) |
items | array | ✅ | รายการข้อความ (สูงสุด 5 items) |
Item Object:
| Field | Type | Required | Description |
|---|---|---|---|
type | string | ✅ | ประเภทข้อความ (ดู Message Item Types) |
msg | string | string[] | ✅ | เนื้อหาข้อความ |
desc | string | ❌ | คำอธิบาย (สูงสุด 170 ตัวอักษร) |
link | string | ❌ | URL link (สำหรับ type = oa_image_link) |
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 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:
| Field | Type | Required | Description |
|---|---|---|---|
account_provider_group_id | string | ✅ | UUID ของกลุ่มที่ต้องการส่ง |
items | array | ✅ | รายการข้อความ (สูงสุด 5 items, รูปแบบเดียวกับ Item Object) |
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:
| Field | Type | Required | Description |
|---|---|---|---|
member_group_broadcast_id | string | ✅ | UUID ของ member group broadcast |
items | array | ✅ | รายการข้อความ (สูงสุด 5 items, รูปแบบเดียวกับ Item Object) |
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
}
}
}
Message Item Types
| Type | Description | msg Format | ต้องมี link? |
|---|---|---|---|
message | ข้อความ text ธรรมดา | string | ❌ |
oa_image_link | รูปภาพที่กดแล้วเปิด link | string (URL รูป) | ✅ |
image | รูปภาพธรรมดา (ไม่มี link) | string (URL รูป) | ❌ |
flex | Flex message | string (JSON format) | ❌ |
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": "📢 ประกาศสำคัญ!"}]
}'