Requests และ activity

เรียกดู receipt ของ mutation ที่เก็บถาวรด้วย request ID และอ่าน activity feed ที่อยู่ใน scope

อัปเดตล่าสุด

เปิดใน Claudeเปิดใน ChatGPT
เนื้อหาในหน้านี้

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

NameInTypeRequiredDescription
requestIdpathstringYesUUID 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:

NameTypeDescription
requestIdstringUUID ที่คุณใช้ lookup
statusstringเป็น accepted เสมอ เพราะมีเพียง mutation ที่ถูกยอมรับเท่านั้นที่บันทึก receipt
statusCodeintegerรหัส HTTP status ของ response ครั้งแรก
operationstringชื่อ operation ภายใน เช่น v1:posts:publish หรือ v1:comments:replies:create
pathstringroute template ที่ mutation ทำงานอยู่
createdAtstringเวลาที่ mutation ถูกยอมรับ (UTC)
resultobjectresponse 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 หรือหมดอายุไปแล้ว

StatusMeaning
200ได้รับ receipt ที่ฉายใหม่ผ่าน authority ปัจจุบันแล้ว
400requestId ไม่ใช่ UUID ที่ถูกต้อง (ดู Errors)
401ต้องยืนยันตัวตน หรือ key ถูก revoke หรือหมดอายุหลังจาก mutation
403Key ไม่มี 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

NameTypeRequiredDescription
limitintegerNoขนาดหน้า, 1-100, ค่าเริ่มต้น 50
cursorstringNoOpaque cursor จาก nextCursor, ยาวได้สูงสุด 512 ตัวอักษร
brandIdstringNoจำกัดเฉพาะ Brand ID หนึ่งตัว
accountIdstringNoจำกัดเฉพาะรายการที่เกี่ยวกับ social account หนึ่งตัว
postIdstringNoจำกัดเฉพาะรายการที่เกี่ยวกับ post หนึ่งโพสต์
fromstringNoISO instant, จุดเริ่มหน้าต่างช่วง
tostringNoISO 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 ของแต่ละรายการ:

NameTypeDescription
idstringAudit record ID
actionstringสิ่งที่เกิดขึ้น เช่น post:publish, post:publication_blocked, thread.update, comment.reply.sent หรือ media:ready
actorTypestringuser, agent หรือ system
targetTypestringประเภท record ที่ถูกกระทำ เช่น post หรือ publication เป็น null เมื่อไม่มี
targetIdstringID ของ record ที่ถูกกระทำ เป็น null เมื่อไม่มี
brandIdstringBrand ที่รายการนี้สังกัด เป็น null เมื่อไม่ทราบ
socialAccountIdsarrayaccount ID ที่เกี่ยวข้อง เรียงลำดับแล้ว
postIdstringpost ที่เกี่ยวข้อง เป็น null เมื่อไม่มี
publicationIdstringpublication ที่เกี่ยวข้อง เป็น null เมื่อไม่มี
revisionintegerหมายเลข revision ที่เกี่ยวข้อง เป็น null เมื่อไม่มี
requestIdstringrequest ID ของ mutation เมื่อรายการมาจาก mutation ผ่าน API
sourceKeyIdstringAPI key ที่ก่อให้เกิดรายการนี้ โดย key จะเห็นค่านี้เฉพาะ action ของตัวเอง ส่วน session จะเห็น ID ของ key ต้นทาง
codestringรหัสความล้มเหลวที่ผ่านการ sanitize เช่น PROVIDER_RATE_LIMITED เป็น null เมื่อรายการนั้นไม่ใช่ความล้มเหลว
createdAtstringเวลาที่เกิดรายการ (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

StatusMeaning
200ได้รับหน้ารายการ activity
400Query ไม่ถูกต้อง (ดู Errors)
401ต้องยืนยันตัวตน
403Key ไม่มี activity:read