Requests และ activity
เรียกดู receipt ของ mutation ที่เก็บถาวรด้วย request ID และอ่าน activity feed ที่อยู่ใน scope
อัปเดตล่าสุด
เนื้อหาในหน้านี้
Endpoint สองตัวนี้ตอบคำถามว่าเกิดอะไรขึ้นและใครเป็นผู้ทำ GET /api/v1/requests/{requestId} เรียกดู receipt ที่บันทึกไว้ของ mutation ที่คุณส่งไปแล้ว ซึ่งเป็นวิธีที่ปลอดภัยในการปิดความไม่ชัดเจนเมื่อ response หายหรือผลลัพธ์ยังไม่ชัด ส่วน GET /api/v1/activity แสดง activity feed ของสิ่งที่อยู่ใน scope ของคุณ รวมถึงรหัสความล้มเหลวที่ผ่านการ sanitize กฎการ lookup receipt (เมื่อไรควรใช้ key เดิมซ้ำ และ 404 หมายถึงอะไร) อยู่ใน Idempotency หน้านี้จะอธิบายรูปแบบข้อมูลบน wire เท่านั้น
เรียกดู request receipt (Look up a request receipt)
GET /api/v1/requests/{requestId}
เรียกดู durable receipt ของ mutation ที่ถูกยอมรับแล้วสำหรับ principal ที่ยืนยันตัวตน mutation ทุกรายการที่ยอมรับผ่าน durable boundary จะบันทึก receipt ไว้ ได้แก่ post create/update/delete, publish/schedule/cancel/retry/cover-retry, schedule-settings update, media mutation, การอัปเดตสถานะ thread และการยอมรับ reply ของ comment Scopes: key หรือ session ที่ยืนยันตัวตนแล้วทุกตัว หาก key ไม่มี action ด้าน draft, publishing, schedule หรือ media เลยจะถูกปฏิเสธด้วย 403 ก่อนที่ receipt ใดจะถูกอ่าน CLI: postkub requests get MCP: requests_get
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| requestId | path | string | Yes | UUID request identifier (ค่าที่คุณส่งเป็น Idempotency-Key) |
Request example
curl -sS https://postkub.com/api/v1/requests/5c2e8f90-1a34-4e67-b2a9-0d8c7b6a5f4e \
-H "Authorization: Bearer <API_KEY>"
Response 200 OK
{
"requestId": "5c2e8f90-1a34-4e67-b2a9-0d8c7b6a5f4e",
"status": "accepted",
"statusCode": 202,
"operation": "v1:comments:replies:create",
"path": "/api/v1/comments/:id/replies",
"createdAt": "2026-12-04T08:00:08.000Z",
"result": {
"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
}
}
Field ของ envelope:
| Name | Type | Description |
|---|---|---|
| requestId | string | UUID ที่คุณใช้ lookup |
| status | string | เป็น accepted เสมอ เพราะมีเพียง mutation ที่ถูกยอมรับเท่านั้นที่บันทึก receipt |
| statusCode | integer | รหัส HTTP status ของ response ครั้งแรก |
| operation | string | ชื่อ operation ภายใน เช่น v1:posts:publish หรือ v1:comments:replies:create |
| path | string | route template ที่ mutation ทำงานอยู่ |
| createdAt | string | เวลาที่ mutation ถูกยอมรับ (UTC) |
| result | object | response body ที่บันทึกไว้ของ operation เดิม |
result จะสะท้อน response body ของ operation เดิม โดยมีผลลัพธ์ที่เป็นไปได้ทางเดียวจากสามทาง และจะถูกฉายใหม่ผ่าน authority ปัจจุบันของคุณก่อนส่งกลับเสมอ:
- Envelope เดิมฉบับเต็ม เมื่อคุณยังคงมี authority เต็มรูปแบบเหนือ Brand และ account ใน snapshot ที่บันทึกไว้ (post create/update envelope, publication receipt, thread และ reply receipt, schedule-settings receipt, media receipt และ receipt ของ key และ connection)
- Sanitized draft receipt
{ "requestId": ..., "post": { "id": ..., "revision": ... } }เมื่อเหลือ authority บางส่วน 404เมื่อผลลัพธ์ที่บันทึกไว้อยู่นอก authority ด้าน resource หรือ action ปัจจุบันของคุณ
receipt ถูกแบ่ง namespace ตาม principal คือ key หนึ่งจะไม่มีทางเห็น receipt ของ key อื่นหรือของ owner session และก็จะไม่ได้รับ receipt ใดกลับมาหาก key ถูก revoke หรือหมดอายุไปแล้ว
| Status | Meaning |
|---|---|
| 200 | ได้รับ receipt ที่ฉายใหม่ผ่าน authority ปัจจุบันแล้ว |
| 400 | requestId ไม่ใช่ UUID ที่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน หรือ key ถูก revoke หรือหมดอายุหลังจาก mutation |
| 403 | Key ไม่มี action ด้าน draft, publishing, schedule หรือ media เลย |
| 404 | ไม่มี receipt สำหรับ principal และ request ID นี้ หรือผลลัพธ์ที่บันทึกไว้อยู่นอก authority ปัจจุบันของคุณ |
ดูรายการ activity (List activity)
GET /api/v1/activity
แสดง activity feed ที่อยู่ใน scope จากใหม่ไปเก่า ครอบคลุม event ของ publication lifecycle, การอัปเดตสถานะ thread, ผลลัพธ์ของ comment reply, media action และรหัสความล้มเหลวที่ผ่านการ sanitize Scopes: activity:read CLI: postkub activity list MCP: activity_list
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | No | ขนาดหน้า, 1-100, ค่าเริ่มต้น 50 |
| cursor | string | No | Opaque cursor จาก nextCursor, ยาวได้สูงสุด 512 ตัวอักษร |
| brandId | string | No | จำกัดเฉพาะ Brand ID หนึ่งตัว |
| accountId | string | No | จำกัดเฉพาะรายการที่เกี่ยวกับ social account หนึ่งตัว |
| postId | string | No | จำกัดเฉพาะรายการที่เกี่ยวกับ post หนึ่งโพสต์ |
| from | string | No | ISO instant, จุดเริ่มหน้าต่างช่วง |
| to | string | No | ISO instant, จุดสิ้นสุดหน้าต่างช่วง |
from ต้องไม่อยู่หลัง to ดูกฎการใช้ cursor ที่ Pagination
Request example
curl -sS "https://postkub.com/api/v1/activity?brandId=brand_example1&limit=50" \
-H "Authorization: Bearer <API_KEY>"
Response 200 OK
{
"items": [
{
"id": "audit_example123",
"action": "post:publish",
"actorType": "agent",
"targetType": "post",
"targetId": "post_example123",
"brandId": "brand_example1",
"socialAccountIds": ["acc_example1"],
"postId": "post_example123",
"publicationId": "pub_example123",
"revision": 2,
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"sourceKeyId": "key_example1",
"code": null,
"createdAt": "2026-12-04T09:00:00.000Z"
}
],
"nextCursor": null
}
Field ของแต่ละรายการ:
| Name | Type | Description |
|---|---|---|
| id | string | Audit record ID |
| action | string | สิ่งที่เกิดขึ้น เช่น post:publish, post:publication_blocked, thread.update, comment.reply.sent หรือ media:ready |
| actorType | string | user, agent หรือ system |
| targetType | string | ประเภท record ที่ถูกกระทำ เช่น post หรือ publication เป็น null เมื่อไม่มี |
| targetId | string | ID ของ record ที่ถูกกระทำ เป็น null เมื่อไม่มี |
| brandId | string | Brand ที่รายการนี้สังกัด เป็น null เมื่อไม่ทราบ |
| socialAccountIds | array | account ID ที่เกี่ยวข้อง เรียงลำดับแล้ว |
| postId | string | post ที่เกี่ยวข้อง เป็น null เมื่อไม่มี |
| publicationId | string | publication ที่เกี่ยวข้อง เป็น null เมื่อไม่มี |
| revision | integer | หมายเลข revision ที่เกี่ยวข้อง เป็น null เมื่อไม่มี |
| requestId | string | request ID ของ mutation เมื่อรายการมาจาก mutation ผ่าน API |
| sourceKeyId | string | API key ที่ก่อให้เกิดรายการนี้ โดย key จะเห็นค่านี้เฉพาะ action ของตัวเอง ส่วน session จะเห็น ID ของ key ต้นทาง |
| code | string | รหัสความล้มเหลวที่ผ่านการ sanitize เช่น PROVIDER_RATE_LIMITED เป็น null เมื่อรายการนั้นไม่ใช่ความล้มเหลว |
| createdAt | string | เวลาที่เกิดรายการ (UTC) |
feed ครอบคลุม post lifecycle และ action การ reconcile (ตั้งแต่ post:create ถึง post:publication_recovery_required), account:schedule, thread.update, กลุ่มผลลัพธ์ comment.reply.*, insights.sync.failed และกลุ่ม action media:*
สำหรับ key แบบ scoped จะได้เฉพาะรายการที่อยู่ใน Brand และ account ของตัวเอง การกรองด้วย brandId หรือ accountId ที่อยู่นอก scope จะได้หน้าว่าง และ socialAccountIds จะถูกตัดให้เหลือเฉพาะ account ที่ key มองเห็น รายการที่มาจาก key อื่นจะมี sourceKeyId: null
| Status | Meaning |
|---|---|
| 200 | ได้รับหน้ารายการ activity |
| 400 | Query ไม่ถูกต้อง (ดู Errors) |
| 401 | ต้องยืนยันตัวตน |
| 403 | Key ไม่มี activity:read |
