Inbox, comments และ replies
อ่าน thread และ comment, ตอบ comment, like และจัดการสถานะ inbox ด้วย scoped API key
อัปเดตล่าสุด
เนื้อหาในหน้านี้
- ดูรายการ thread ใน inbox (List inbox threads)
- สรุป inbox ต่อโพสต์ (Summarize the inbox by post)
- อ่าน thread หนึ่งรายการ (Read one thread)
- อัปเดตสถานะ thread (Update thread state)
- ดูรายการ comment (List comments)
- ตอบคอมเมนต์ (Reply to a comment)
- ตรวจสอบสถานะ reply (Check reply status)
- Like หรือ unlike คอมเมนต์ (Like or unlike a comment)
Endpoint กลุ่ม inbox ช่วยให้ key ของคุณอ่านบทสนทนาคอมเมนต์ (thread) บน account ที่อยู่ใน scope, ส่ง reply แบบ durable ในนาม account ที่เชื่อมต่อ และอัปเดตสถานะ inbox ฝั่ง Postkub การอ่านต้องมี comment:read การตอบ comment ต้องมี comment:reply การ mark thread ว่า handled ต้องมี thread:resolve และการเปลี่ยนสถานะ unread ต้องมี thread:update ดูโมเดล scope ทั้งหมดได้ใน Authentication
พฤติกรรมที่ใช้กับทุก endpoint ในหน้านี้มีสองข้อ ข้อแรก key แบบ scoped จะเห็นเฉพาะ thread และ comment ใน Brand และ account ที่เลือกไว้เท่านั้น หากกรองด้วยค่าที่อยู่นอก scope จะได้ผลลัพธ์ว่างกลับมา ไม่ใช่ error เพื่อไม่ให้ response เปิดเผยข้อมูลว่ามีอะไรอยู่บ้าง ข้อสอง response ของการอ่านจะมี field requestId สำหรับเชื่อมโยงคำขอ (จะเป็น null หากคำขอไม่ได้ส่ง UUID ใน Idempotency-Key หรือ X-Request-ID)
ดูรายการ thread ใน inbox (List inbox threads)
GET /api/v1/threads
แสดงรายการ thread ที่ผู้เรียกมองเห็นได้ เรียงจาก activity ล่าสุดก่อน thread หนึ่งคือบทสนทนาคอมเมนต์หนึ่งชุดบน account ที่เชื่อมต่อ โดยจะโยงกับ post target ของ Postkub ที่เกี่ยวข้องเมื่อระบบทราบ Scopes: comment:read CLI: postkub threads list (alias postkub inbox list) MCP: threads_list
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | No | ขนาดหน้า, 1-100, ค่าเริ่มต้น 50 |
| cursor | string | No | Opaque cursor จาก nextCursor, ยาวได้สูงสุด 512 ตัวอักษร |
| handled | string | No | true สำหรับ thread ที่ handled แล้ว, false สำหรับ thread ที่ยังเปิด |
| accountId | string | No | ตัวกรอง account แบบทำซ้ำได้ ส่งพารามิเตอร์นี้หนึ่งครั้งต่อ account ID หนึ่งตัว |
| postTargetId | string | No | เฉพาะ thread ที่โยงกับ post target นี้ ค่า literal none จะเลือกเฉพาะ thread ที่ไม่มี post โยง |
| socialPostId | string | No | เฉพาะ thread ที่โยงกับ discovered post นี้ ค่า literal none จะเลือกเฉพาะ thread ที่ไม่มีการโยง |
Request example
curl -sS "https://postkub.com/api/v1/threads?handled=false&limit=50" \
-H "Authorization: Bearer <API_KEY>"
Response 200 OK
{
"requestId": null,
"items": [
{
"id": "thread_example123",
"socialAccountId": "acc_example1",
"brandId": "brand_example1",
"provider": "meta",
"platform": "facebook",
"providerThreadId": "17841400000000001",
"postTargetId": "target_example123",
"status": "open",
"revision": 3,
"lastCommentAt": "2026-12-04T07:20:00.000Z",
"unreadCount": 2,
"createdAt": "2026-12-01T10:05:00.000Z"
}
],
"nextCursor": null
}
status มีค่า open หรือ handled ส่วน revision คือเวอร์ชันสำหรับ optimistic concurrency ที่คุณต้องส่งกลับมาเมื่อจะอัปเดตสถานะ ดูกฎการใช้ cursor ที่ Pagination
| Status | Meaning |
|---|---|
| 200 | ได้รับหน้ารายการ thread |
| 400 | Query ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี comment:read |
สรุป inbox ต่อโพสต์ (Summarize the inbox by post)
GET /api/v1/inbox/posts
รวม thread ที่มองเห็นได้ให้เหลือหนึ่ง bucket ต่อโพสต์ที่โยงกัน เพื่อให้ agent แสดงมุมมอง inbox แบบ per-post สไตล์ Buffer ได้ thread ที่ไม่รู้จักโพสต์ที่โยงจะถูกจัดไปอยู่ bucket ที่ postTargetId เป็น null และโพสต์ที่ยังไม่มีคอมเมนต์ก็จะแสดงเช่นกัน เพื่อไม่ให้สิ่งใดใน inbox มองไม่เห็น ไม่มีคำสั่ง CLI หรือ MCP tool สำหรับ endpoint นี้ Scopes: comment:read
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| handled | string | No | true นับเฉพาะ thread ที่ handled แล้ว, false นับเฉพาะ thread ที่ยังเปิด |
| accountId | string | No | ตัวกรอง account แบบทำซ้ำได้ ส่งพารามิเตอร์นี้หนึ่งครั้งต่อ account ID หนึ่งตัว |
Request example
curl -sS "https://postkub.com/api/v1/inbox/posts" \
-H "Authorization: Bearer <API_KEY>"
Response 200 OK
{
"requestId": null,
"items": [
{
"postTargetId": "target_example123",
"postId": "post_example123",
"accountId": "acc_example1",
"caption": "New menu launched this week",
"mediaUrl": "https://cdn.example.com/media/abc.jpg",
"permalink": "https://www.facebook.com/acme/posts/123",
"commentCount": 12,
"unreadCommentCount": 3,
"openThreadCount": 5,
"handledThreadCount": 7,
"lastCommentAt": "2026-12-04T07:20:00.000Z"
}
],
"nextCursor": null
}
postTargetId จะเป็น null สำหรับ thread ที่ไม่รู้จักโพสต์ที่โยง ซึ่งคุณส่งค่า literal none เป็นตัวกรอง postTargetId บน GET /api/v1/threads เพื่อดูเฉพาะ bucket นี้ได้ openThreadCount นับ thread ที่ยังไม่ได้ตอบ ส่วน nextCursor วันนี้เป็น null เสมอ เพราะระบบส่งชุดข้อมูลที่ตรงเงื่อนไขทั้งหมดกลับมา และ pagination จะเพิ่มเมื่อปริมาณข้อมูลต่อ tenant ต้องการเท่านั้น
| Status | Meaning |
|---|---|
| 200 | ได้รับสรุป per-post |
| 400 | Query ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี comment:read |
อ่าน thread หนึ่งรายการ (Read one thread)
GET /api/v1/threads/{id}
คืน thread หนึ่งรายการพร้อม comment ทั้งหมด เรียงจากเก่าไปใหม่ สูงสุด 200 comment Scopes: comment:read CLI: postkub threads get MCP: threads_get
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Thread ID |
Request example
curl -sS https://postkub.com/api/v1/threads/thread_example123 \
-H "Authorization: Bearer <API_KEY>"
Response 200 OK
{
"requestId": null,
"thread": {
"id": "thread_example123",
"socialAccountId": "acc_example1",
"brandId": "brand_example1",
"provider": "meta",
"platform": "facebook",
"providerThreadId": "17841400000000001",
"postTargetId": "target_example123",
"status": "open",
"revision": 3,
"lastCommentAt": "2026-12-04T07:20:00.000Z",
"unreadCount": 2,
"createdAt": "2026-12-01T10:05:00.000Z"
},
"comments": [
{
"id": "comment_example123",
"threadId": "thread_example123",
"parentCommentId": null,
"provider": "meta",
"providerCommentId": "17841400000000002",
"authorProviderId": "user_98765",
"authorName": "Somchai J.",
"authorHandle": "@somchai",
"text": "When does this restock?",
"unread": true,
"ownerLikedAt": null,
"providerCreatedAt": "2026-12-04T07:19:30.000Z",
"createdAt": "2026-12-04T07:19:31.000Z"
}
]
}
ownerLikedAt คือเวลาที่ account ที่เชื่อมต่อกด like comment นั้น หรือเป็น null ถ้ายังไม่ได้กด thread ที่อยู่นอก scope ของ key จะตอบ 404 เหมือน thread ที่ไม่มีอยู่จริงทุกประการ
| Status | Meaning |
|---|---|
| 200 | ได้รับ thread พร้อม comment |
| 400 | Thread ID ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี comment:read |
| 404 | ไม่พบ thread หรืออยู่นอก scope ของ key |
อัปเดตสถานะ thread (Update thread state)
PATCH /api/v1/threads/{id}
Mark thread ว่า handled หรือปิดการ handled และ/หรือ mark comment ใน thread ว่า read หรือ unread เป็น mutation แบบ guarded คือต้องส่ง header Idempotency-Key และ revision ปัจจุบันของ thread Scopes: thread:resolve สำหรับ handled thread:update สำหรับ unread CLI: postkub threads update (alias postkub threads resolve สำหรับ mark handled เท่านั้น) MCP: threads_update หรือ threads_resolve สำหรับ mark handled เท่านั้น
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Thread ID |
| Idempotency-Key | header | UUID | Yes | UUID ที่ client กำหนดและคงที่ หาก response หายให้ส่ง UUID เดิมซ้ำ |
| expectedRevision | body | integer | Yes | revision ปัจจุบันของ thread อย่างน้อย 1 |
| handled | body | boolean | คู่กับ unread | true mark ว่า handled, false เปิด thread คืน |
| unread | body | boolean | คู่กับ handled | true mark comment ของ thread ว่า unread, false mark ว่า read |
ต้องส่ง handled หรือ unread อย่างน้อยหนึ่งค่า และส่งทั้งสองค่าพร้อมกันได้
Request example
curl -sS -X PATCH https://postkub.com/api/v1/threads/thread_example123 \
-H "Authorization: Bearer <API_KEY>" \
-H "Idempotency-Key: 3f9d1c2e-5a47-4b08-9c1d-2e3f4a5b6c7d" \
-H "Content-Type: application/json" \
-d '{"expectedRevision": 3, "handled": true}'
Response 200 OK
{
"requestId": "3f9d1c2e-5a47-4b08-9c1d-2e3f4a5b6c7d",
"threadId": "thread_example123",
"revision": 4,
"status": "handled",
"unreadCount": 0,
"handledAt": "2026-12-04T08:00:00.000Z",
"replayed": false
}
การส่ง handled เป็น false จะรีเซ็ต handledAt กลับเป็น null ส่วน flag unread จะมีผลกับ comment ทุกตัวใน thread พร้อมกัน การ replay ด้วยคำขอเดิมจะได้ receipt ที่บันทึกไว้กลับมาพร้อม replayed: true ดูรายละเอียดที่ Idempotency
| Status | Meaning |
|---|---|
| 200 | อัปเดตสถานะสำเร็จ (หรือได้ผลลัพธ์ replay เดิม) |
| 400 | Validation error หรือ header ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี thread:resolve หรือ thread:update สำหรับการเปลี่ยนแปลงที่ขอ |
| 404 | ไม่พบ thread หรืออยู่นอก scope ของ key |
| 409 | REVISION_CONFLICT (expectedRevision เก่า โดยมี error.details.currentRevision), IDEMPOTENCY_CONFLICT หรือ LOCK_TIMEOUT |
ดูรายการ comment (List comments)
GET /api/v1/comments
แสดงรายการ comment จากใหม่ไปเก่า พร้อมตัวกรอง account, thread และ unread แบบเลือกใช้ได้ Scopes: comment:read CLI: postkub comments list MCP: comments_list
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | No | ขนาดหน้า, 1-100, ค่าเริ่มต้น 50 |
| cursor | string | No | Opaque cursor จาก nextCursor, ยาวได้สูงสุด 512 ตัวอักษร |
| unread | string | No | true เฉพาะ comment ที่ยังไม่อ่าน, false เฉพาะที่อ่านแล้ว |
| threadId | string | No | เฉพาะ comment ใน thread นี้ |
| accountId | string | No | ตัวกรอง account ID หนึ่งตัว |
Request example
curl -sS "https://postkub.com/api/v1/comments?unread=true&limit=50" \
-H "Authorization: Bearer <API_KEY>"
Response 200 OK
{
"requestId": null,
"items": [
{
"id": "comment_example123",
"threadId": "thread_example123",
"parentCommentId": null,
"provider": "meta",
"providerCommentId": "17841400000000002",
"authorProviderId": "user_98765",
"authorName": "Somchai J.",
"authorHandle": "@somchai",
"text": "When does this restock?",
"unread": true,
"ownerLikedAt": null,
"providerCreatedAt": "2026-12-04T07:19:30.000Z",
"createdAt": "2026-12-04T07:19:31.000Z"
}
],
"nextCursor": null
}
threadId ที่ไม่มีอยู่จริงหรืออยู่นอก scope ของ key จะคืนหน้าว่าง ไม่ใช่ error
| Status | Meaning |
|---|---|
| 200 | ได้รับหน้ารายการ comment |
| 400 | Query ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี comment:read |
ตอบคอมเมนต์ (Reply to a comment)
POST /api/v1/comments/{id}/replies
รับ reply แบบ durable เข้าสู่ระบบเพื่อให้ worker เผยแพร่ในนาม account ที่เชื่อมต่อ 202 Accepted หมายถึงคำขอถูกยอมรับเป็นงาน asynchronous ไม่ใช่การยืนยันว่า provider สำเร็จแล้ว ผลลัพธ์จริงจะตามมาทาง status URL Scopes: comment:reply CLI: postkub comments reply MCP: comments_reply
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Comment ID ที่จะตอบ |
| Idempotency-Key | header | UUID | Yes | UUID ที่ client กำหนดและคงที่ หาก response หายให้ส่ง UUID เดิมซ้ำ |
| message | body | string | Yes | ข้อความ reply, 1-2200 ตัวอักษรหลัง trim |
Request example
curl -sS -X POST https://postkub.com/api/v1/comments/comment_example123/replies \
-H "Authorization: Bearer <API_KEY>" \
-H "Idempotency-Key: 5c2e8f90-1a34-4e67-b2a9-0d8c7b6a5f4e" \
-H "Content-Type: application/json" \
-d '{"message": "It restocks next Monday - thank you for asking!"}'
Response 202 Accepted
{
"requestId": "5c2e8f90-1a34-4e67-b2a9-0d8c7b6a5f4e",
"replyId": "reply_example123",
"commentId": "comment_example123",
"threadId": "thread_example123",
"socialAccountId": "acc_example1",
"revision": 1,
"state": "pending",
"statusUrl": "/api/v1/replies/reply_example123",
"replayed": false
}
reply ผ่าน capability gate ราย account หาก provider หรือ platform ไม่มี capability การตอบ comment ที่ผ่านการรับรอง ระบบจะปฏิเสธแบบ fail closed ด้วย 422 ก่อนที่จะมีการส่งอะไรออกไป ให้ poll statusUrl เพื่อติดตามการทำงาน โดย worker จะ retry ความล้มเหลวชั่วคราวภายในงบ 5 attempts และเงื่อนไขเวลาประมวลผล 24 ชั่วโมง
| Status | Meaning |
|---|---|
| 202 | ยอมรับ reply เป็นงาน async ให้ poll ที่ status URL |
| 400 | Validation error หรือ header ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี comment:reply |
| 404 | ไม่พบ comment หรืออยู่นอก scope ของ key |
| 409 | IDEMPOTENCY_CONFLICT (UUID เดิมถูกใช้กับ payload ต่างกัน) |
| 422 | ACCOUNT_NOT_ACTIVE, PROVIDER_CAPABILITY_UNAVAILABLE หรือ PLATFORM_NOT_SUPPORTED - ไม่มีการส่งอะไรออกไป |
ตรวจสอบสถานะ reply (Check reply status)
GET /api/v1/replies/{id}
คืนสถานะการทำงานของ reply และประวัติ attempt ทั้งหมด Scopes: comment:read CLI: postkub replies get MCP: replies_get
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Reply ID จาก response ตอนรับคำขอ |
Request example
curl -sS https://postkub.com/api/v1/replies/reply_example123 \
-H "Authorization: Bearer <API_KEY>"
Response 200 OK
{
"requestId": "5c2e8f90-1a34-4e67-b2a9-0d8c7b6a5f4e",
"replyId": "reply_example123",
"commentId": "comment_example123",
"threadId": "thread_example123",
"socialAccountId": "acc_example1",
"revision": 2,
"state": "sent",
"text": "It restocks next Monday - thank you for asking!",
"providerReplyId": "17841400000000099",
"attemptCount": 1,
"attemptBudget": 5,
"nextAttemptAt": null,
"lastErrorCode": null,
"lastErrorMessage": null,
"sentAt": "2026-12-04T08:00:10.000Z",
"attempts": [
{
"attemptNumber": 1,
"state": "succeeded",
"requestStartedAt": "2026-12-04T08:00:09.000Z",
"finishedAt": "2026-12-04T08:00:10.000Z",
"providerReplyId": "17841400000000099",
"errorCode": null,
"errorMessage": null,
"outcomeSource": null
}
]
}
state มีค่าเป็น pending, queued, processing, outcome_unknown, needs_review, blocked, sent หรือ failed ให้ถือว่า outcome_unknown และ needs_review เป็นสถานะที่ต้องให้มนุษย์ดำเนินการต่อ และอย่าส่ง reply ใหม่ด้วย idempotency key ใหม่ทับผลลัพธ์ที่ยังไม่ชัด (ดู Idempotency) ระบบคืน attempt ล่าสุดสูงสุด 20 รายการ
| Status | Meaning |
|---|---|
| 200 | ได้รับสถานะ reply และประวัติ attempt |
| 400 | Reply ID ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี comment:read |
| 404 | ไม่พบ reply หรืออยู่นอก scope ของ key |
Like หรือ unlike คอมเมนต์ (Like or unlike a comment)
POST /api/v1/comments/{id}/like
DELETE /api/v1/comments/{id}/like
เพิ่มหรือเอา like ของ account ที่เชื่อมต่อออกจาก comment โดยตรงบน provider ฟีเจอร์นี้เป็น action ของ web dashboard session เท่านั้น หากใช้ API key จะถูกปฏิเสธด้วย 403 และไม่มีคำสั่ง CLI หรือ MCP tool Scopes: web session ที่ยืนยันตัวตนแล้วทุก session ไม่มี action ของ API key สำหรับการ like
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Comment ID |
Request example
# Session-cookie action: sign in through the web dashboard, not an API key.
curl -sS -X POST https://postkub.com/api/v1/comments/comment_example123/like \
-b session.txt
Response 200 OK
{
"requestId": null,
"commentId": "comment_example123",
"liked": true
}
reaction นี้เป็นแบบ one-way คือปรากฏบน provider ทันที และสถานะ reaction ฝั่ง provider จะไม่ถูก sync กลับมา การเรียกซ้ำในทิศทางเดียวกันเป็น no-op ซึ่งทำให้การ retry หลังเกิด timeout ที่ผลลัพธ์ยังไม่ชัดปลอดภัย การ like ใช้ capability gate เดียวกับการตอบ comment บวกกับ capability การ like ราย provider เพิ่มเติม
| Status | Meaning |
|---|---|
| 200 | Like หรือ unlike สำเร็จ (การเรียกซ้ำทิศทางเดิมเป็น no-op) |
| 400 | Comment ID ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | API key ไม่รองรับ action นี้ (ACTION_NOT_AVAILABLE_FOR_KEYS) ให้ใช้ web session |
| 404 | ไม่พบ comment หรืออยู่นอก scope ของผู้เรียก |
| 409 | CREDENTIAL_UNAVAILABLE, CREDENTIAL_EXPIRED หรือ ACCESS_TOKEN_EXPIRED - ต้อง reconnect channel |
| 422 | ACCOUNT_NOT_ACTIVE, PROVIDER_CAPABILITY_UNAVAILABLE, PLATFORM_NOT_SUPPORTED หรือ LIKE_CAPABILITY_UNAVAILABLE |
| 500 | CREDENTIAL_UNREADABLE |
| 502 | PROVIDER_REQUEST_FAILED - provider ปฏิเสธคำขอ |
| 504 | PROVIDER_TIMEOUT - ผลลัพธ์ยังไม่ชัด การ retry like เดิมปลอดภัย |
