Create and manage posts

Create, read, update, delete, and archive posts with a scoped API key.

Updated

Open in ClaudeOpen in ChatGPT
On this page

Posts are the shared content records that humans and API keys edit through the same lifecycle. A key always creates a draft first; publication happens through the separate publish and schedule operations on Publications. All mutations here require an Idempotency-Key header and, when changing an existing post, the current expectedRevision (see API reference).

Create a post

POST /api/v1/posts

Creates a new local draft. The draft is always created with status draft, even when target accounts are selected; publishing or scheduling is a separate accepted action. Scopes: post:create. CLI: postkub posts create. MCP: posts_create.

Headers

NameTypeRequiredDescription
Idempotency-KeyUUIDYesClient mutation request identifier; repeat the same UUID after a lost response

Body parameters

NameTypeRequiredDescription
brandIdstringYesTarget Brand ID, 1-128 characters
textstringYesExact text, 1-5000 UTF-16 code units, not whitespace-only; stored without trimming or normalization
socialAccountIdsarray of stringNoDraft audience, 0-10 unique account IDs. API keys must select at least one account; a targetless draft is rejected with 403 TARGETLESS_DRAFT_OWNER_ONLY
mediaAssetIdsarray of stringNoOrdered verified media asset IDs from the session-authenticated Web UI media gateway (human sessions)
mediaUrlsarray of stringNoOrdered public HTTPS media stream URLs, max 10, unique, each max 2048 characters. Viewer and share pages, private hosts, and credential-bearing URLs are rejected. See Hosted Media
mediaKindstringNoimage or video. Defaults to image; required to declare video for hosted URLs (never inferred from a file extension) and must match verified asset kinds
videoCoverOffsetsarray of objectNoPer-target video frame offset in milliseconds (socialAccountId, offsetMs 0-2147483647) for Instagram Reels or TikTok; stored on the draft and capability-gated at publication acceptance
videoCoverImagesarray of objectNoPer-target verified image media asset (socialAccountId, mediaAssetId) for an Instagram Reel or YouTube video cover
firstCommentstringNoOptional base first-comment text, max 2200 characters, same validation as a reply; posted by the worker after the target publishes, capability-gated per account at acceptance
firstCommentOverridesarray of objectNoPer-target overrides (socialAccountId, text up to 2200); a target without an entry uses the base firstComment

A video post requires exactly one media item (asset or URL). The total of mediaAssetIds plus mediaUrls cannot exceed 35 items.

Request example

curl -sS -X POST https://postkub.com/api/v1/posts \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Idempotency-Key: 7f6c2f1e-8b4a-4c3d-9e2f-1a2b3c4d5e6f" \
  -H "Content-Type: application/json" \
  -d '{
    "brandId": "brand_example1",
    "text": "New post from our agent",
    "socialAccountIds": ["acc_example1"],
    "mediaUrls": ["https://cdn.example.com/clips/launch.mp4"],
    "mediaKind": "video",
    "firstComment": "Links in the first comment"
  }'

Response 201 Created

{
  "requestId": "7f6c2f1e-8b4a-4c3d-9e2f-1a2b3c4d5e6f",
  "post": {
    "id": "post_example123",
    "brandId": "brand_example1",
    "status": "draft",
    "revision": 1,
    "text": "New post from our agent",
    "socialAccountIds": ["acc_example1"],
    "mediaAssetIds": [],
    "mediaUrls": ["https://cdn.example.com/clips/launch.mp4"],
    "mediaKind": "video",
    "firstComment": "Links in the first comment",
    "firstCommentOverrides": [],
    "authorActorType": "user",
    "authorId": "user_example1",
    "sourcePrincipalType": "api_key",
    "sourcePrincipalId": "key_example1",
    "createdAt": "2026-12-03T09:00:00.000Z",
    "updatedAt": "2026-12-03T09:00:00.000Z",
    "targets": [
      { "socialAccountId": "acc_example1", "status": "pending" }
    ],
    "allowedActions": ["post:read", "post:update", "post:delete", "post:publish", "post:schedule"]
  },
  "url": "/api/v1/posts/post_example123"
}

An identical idempotent replay whose stored full body is no longer fully returnable answers with the original status and a sanitized receipt (requestId plus post.id and post.revision) instead.

StatusMeaning
201Draft created (always status draft)
400Validation error or unsupported media (see Errors)
401Authentication required
403Key lacks post:create, or a targetless draft was requested (TARGETLESS_DRAFT_OWNER_ONLY)
404Brand not found or outside the key's scope
409Idempotency conflict, target-brand conflict, or lock timeout

List posts

GET /api/v1/posts

Lists posts visible to the caller with filters. Each item is a full projection when the caller holds authority over the Brand and every target, or a partial projection (fewer fields, audience reduced to the authorized subset) otherwise. Scopes: post:read. CLI: postkub posts list. MCP: posts_list.

Query parameters

NameTypeRequiredDescription
brandIdstringNoRestrict to one Brand ID
accountIdstringNoRestrict to posts targeting this account ID
statusstringNoOne of draft, scheduled, publishing, published, failed, cancelled, needs_attention
fromstringNoInclusive range start, ISO date-time in UTC
tostringNoInclusive range end, ISO date-time in UTC; from must be before or equal to to
cursorstringNoOpaque cursor from nextCursor, 1-512 characters
limitintegerNoPage size, 1-100, default 50

Request example

curl -sS "https://postkub.com/api/v1/posts?status=draft&limit=50" \
  -H "Authorization: Bearer <API_KEY>"

Response 200 OK

{
  "items": [
    {
      "id": "post_example123",
      "brandId": "brand_example1",
      "status": "draft",
      "revision": 1,
      "text": "New post from our agent",
      "socialAccountIds": ["acc_example1"],
      "mediaAssetIds": [],
      "mediaUrls": ["https://cdn.example.com/clips/launch.mp4"],
      "mediaKind": "video",
      "firstComment": "Links in the first comment",
      "firstCommentOverrides": [],
      "authorActorType": "user",
      "authorId": "user_example1",
      "sourcePrincipalType": "api_key",
      "sourcePrincipalId": "key_example1",
      "createdAt": "2026-12-03T09:00:00.000Z",
      "updatedAt": "2026-12-03T09:00:00.000Z",
      "targets": [
        { "socialAccountId": "acc_example1", "status": "pending" }
      ],
      "allowedActions": ["post:read", "post:update", "post:delete", "post:publish", "post:schedule"]
    }
  ],
  "nextCursor": null
}

Partial-projection items omit brandId, mediaAssetIds, the author fields, and the timestamps, and socialAccountIds lists only the caller-authorized subset. See Pagination.

StatusMeaning
200Projections returned
400Invalid pagination or cursor (see Errors)
401Authentication required
403Key lacks post:read

Get a post

GET /api/v1/posts/{id}

Returns one post with the projection the caller is authorized for: the full shape when the caller holds authority over the Brand and every target, a partial shape otherwise. Scopes: post:read. CLI: postkub posts get. MCP: posts_get.

Parameters

NameInTypeRequiredDescription
idpathstringYesPost ID

Request example

curl -sS https://postkub.com/api/v1/posts/post_example123 \
  -H "Authorization: Bearer <API_KEY>"

Response 200 OK — same post projection shape as creating or listing. When a target has accepted publication work, its targets entry carries a publication object with the current per-target execution state (status, scheduleMode, fireAtUtc, allowedActions, and step states such as firstCommentState and coverState).

StatusMeaning
200Post projection returned
400Invalid post ID (see Errors)
401Authentication required
403Key lacks post:read
404Draft not found (uniform for invisible records, whether missing or out of scope)

Update a post

PATCH /api/v1/posts/{id}

Edits a draft in place. Only posts with status draft can be edited; anything else returns 409 UNSUPPORTED_STATE. The key needs authority over the union of the stored targets and the requested ones. Scopes: post:update. CLI: postkub posts update. MCP: posts_update.

Headers

NameTypeRequiredDescription
Idempotency-KeyUUIDYesClient mutation request identifier

Body parameters

NameTypeRequiredDescription
expectedRevisionintegerYesCurrent post revision; minimum 1. Missing value is rejected with 428 REVISION_REQUIRED
textstringNoReplacement text (same rules as create)
socialAccountIdsarray of stringNoReplacement audience, 0-10 unique IDs; an empty array clears the selection (owner sessions only)
mediaAssetIdsarray of stringNoReplacement verified media asset IDs
mediaUrlsarray of stringNoReplacement hosted URLs; omit to retain the stored list, send an empty array to remove it
mediaKindstringNoimage or video; omit to retain the stored kind when media is not being replaced
videoCoverOffsetsarray of objectNoReplacement offsets; omit to retain, empty array clears
videoCoverImagesarray of objectNoReplacement cover images; omit to retain, empty array clears
firstCommentstring or nullNoOmit to retain, null to clear, a non-empty string to replace
firstCommentOverridesarray of objectNoOmit to retain stored overrides, or send the full replacement set
brandIdstringNoImmutable in this slice; must match the stored brand

Request example

curl -sS -X PATCH https://postkub.com/api/v1/posts/post_example123 \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Idempotency-Key: 8a4b1f9e-2c3d-4e5f-8a9b-0c1d2e3f4a5b" \
  -H "Content-Type: application/json" \
  -d '{
    "expectedRevision": 1,
    "text": "Edited caption from our agent"
  }'

Response 200 OK — the updated post, always in the full projection shape (updaters hold full-union authority).

StatusMeaning
200Draft updated (or identical replay returned)
400Validation error or unsupported media (see Errors)
401Authentication required
403Key lacks post:update or lacks authority over every affected target
404Draft not found
409REVISION_CONFLICT (stale revision, with error.details.currentRevision), UNSUPPORTED_STATE (post is not a draft), or idempotency conflict
428REVISION_REQUIRED (missing expectedRevision)

Delete a draft

DELETE /api/v1/posts/{id}

Deletes an unaccepted local draft permanently. Posts with accepted publication work cannot be deleted; cancel the work and use Archive a post instead. Scopes: post:delete. CLI: postkub posts delete. MCP: posts_delete.

Headers

NameTypeRequiredDescription
Idempotency-KeyUUIDYesClient mutation request identifier

Body parameters

NameTypeRequiredDescription
expectedRevisionintegerYesCurrent post revision; minimum 1

Request example

curl -sS -X DELETE https://postkub.com/api/v1/posts/post_example123 \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Idempotency-Key: 9b5c2a0f-3d4e-4f6a-9b0c-1d2e3f4a5b6c" \
  -H "Content-Type: application/json" \
  -d '{ "expectedRevision": 2 }'

Response 200 OK

{
  "requestId": "9b5c2a0f-3d4e-4f6a-9b0c-1d2e3f4a5b6c",
  "deletedPost": {
    "id": "post_example123",
    "brandId": "brand_example1",
    "deletedRevision": 2,
    "status": "deleted",
    "socialAccountIds": ["acc_example1"]
  }
}
StatusMeaning
200Draft deleted, or an identical prior receipt replayed
400Validation error (see Errors)
401Authentication required
403Key lacks post:delete or lacks authority over every affected target
404Draft not found
409UNSUPPORTED_STATE (post is not an unaccepted local draft), REVISION_CONFLICT, or idempotency conflict
428REVISION_REQUIRED (missing expectedRevision)

Archive a post

POST /api/v1/posts/{id}/archive

Archives a finished post (published, failed, or cancelled, with no active publication work) so it no longer appears in active lists. Drafts and posts with active publications cannot be archived. Scopes: post:delete. Not available as a CLI command or MCP tool.

Headers

NameTypeRequiredDescription
Idempotency-KeyUUIDYesClient mutation request identifier

Body parameters

NameTypeRequiredDescription
expectedRevisionintegerYesCurrent post revision; minimum 1

Request example

curl -sS -X POST https://postkub.com/api/v1/posts/post_example123/archive \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Idempotency-Key: 0c6d3b1a-4e5f-4a7b-0c1d-2e3f4a5b6c7d" \
  -H "Content-Type: application/json" \
  -d '{ "expectedRevision": 3 }'

Response 200 OK

{
  "requestId": "0c6d3b1a-4e5f-4a7b-0c1d-2e3f4a5b6c7d",
  "archivedPost": {
    "id": "post_example123",
    "brandId": "brand_example1",
    "revision": 4,
    "archivedAt": "2026-12-03T10:00:00.000Z",
    "socialAccountIds": ["acc_example1"]
  }
}

Archiving increments the post revision, so the expectedRevision used here must match the revision before the archive.

StatusMeaning
200Post archived (or identical replay returned)
400Validation error (see Errors)
401Authentication required
403Key lacks post:delete or lacks authority over every affected target
404Post not found
409UNSUPPORTED_STATE (only finished posts without active publications can be archived), REVISION_CONFLICT, or idempotency conflict
428REVISION_REQUIRED (missing expectedRevision)