Create and manage posts
Create, read, update, delete, and archive posts with a scoped API key.
Updated
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
| Name | Type | Required | Description |
|---|---|---|---|
| Idempotency-Key | UUID | Yes | Client mutation request identifier; repeat the same UUID after a lost response |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
| brandId | string | Yes | Target Brand ID, 1-128 characters |
| text | string | Yes | Exact text, 1-5000 UTF-16 code units, not whitespace-only; stored without trimming or normalization |
| socialAccountIds | array of string | No | Draft 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 |
| mediaAssetIds | array of string | No | Ordered verified media asset IDs from the session-authenticated Web UI media gateway (human sessions) |
| mediaUrls | array of string | No | Ordered 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 |
| mediaKind | string | No | image or video. Defaults to image; required to declare video for hosted URLs (never inferred from a file extension) and must match verified asset kinds |
| videoCoverOffsets | array of object | No | Per-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 |
| videoCoverImages | array of object | No | Per-target verified image media asset (socialAccountId, mediaAssetId) for an Instagram Reel or YouTube video cover |
| firstComment | string | No | Optional 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 |
| firstCommentOverrides | array of object | No | Per-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.
| Status | Meaning |
|---|---|
| 201 | Draft created (always status draft) |
| 400 | Validation error or unsupported media (see Errors) |
| 401 | Authentication required |
| 403 | Key lacks post:create, or a targetless draft was requested (TARGETLESS_DRAFT_OWNER_ONLY) |
| 404 | Brand not found or outside the key's scope |
| 409 | Idempotency 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
| Name | Type | Required | Description |
|---|---|---|---|
| brandId | string | No | Restrict to one Brand ID |
| accountId | string | No | Restrict to posts targeting this account ID |
| status | string | No | One of draft, scheduled, publishing, published, failed, cancelled, needs_attention |
| from | string | No | Inclusive range start, ISO date-time in UTC |
| to | string | No | Inclusive range end, ISO date-time in UTC; from must be before or equal to to |
| cursor | string | No | Opaque cursor from nextCursor, 1-512 characters |
| limit | integer | No | Page 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.
| Status | Meaning |
|---|---|
| 200 | Projections returned |
| 400 | Invalid pagination or cursor (see Errors) |
| 401 | Authentication required |
| 403 | Key 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
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Post 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).
| Status | Meaning |
|---|---|
| 200 | Post projection returned |
| 400 | Invalid post ID (see Errors) |
| 401 | Authentication required |
| 403 | Key lacks post:read |
| 404 | Draft 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
| Name | Type | Required | Description |
|---|---|---|---|
| Idempotency-Key | UUID | Yes | Client mutation request identifier |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expectedRevision | integer | Yes | Current post revision; minimum 1. Missing value is rejected with 428 REVISION_REQUIRED |
| text | string | No | Replacement text (same rules as create) |
| socialAccountIds | array of string | No | Replacement audience, 0-10 unique IDs; an empty array clears the selection (owner sessions only) |
| mediaAssetIds | array of string | No | Replacement verified media asset IDs |
| mediaUrls | array of string | No | Replacement hosted URLs; omit to retain the stored list, send an empty array to remove it |
| mediaKind | string | No | image or video; omit to retain the stored kind when media is not being replaced |
| videoCoverOffsets | array of object | No | Replacement offsets; omit to retain, empty array clears |
| videoCoverImages | array of object | No | Replacement cover images; omit to retain, empty array clears |
| firstComment | string or null | No | Omit to retain, null to clear, a non-empty string to replace |
| firstCommentOverrides | array of object | No | Omit to retain stored overrides, or send the full replacement set |
| brandId | string | No | Immutable 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).
| Status | Meaning |
|---|---|
| 200 | Draft updated (or identical replay returned) |
| 400 | Validation error or unsupported media (see Errors) |
| 401 | Authentication required |
| 403 | Key lacks post:update or lacks authority over every affected target |
| 404 | Draft not found |
| 409 | REVISION_CONFLICT (stale revision, with error.details.currentRevision), UNSUPPORTED_STATE (post is not a draft), or idempotency conflict |
| 428 | REVISION_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
| Name | Type | Required | Description |
|---|---|---|---|
| Idempotency-Key | UUID | Yes | Client mutation request identifier |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expectedRevision | integer | Yes | Current 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"]
}
}
| Status | Meaning |
|---|---|
| 200 | Draft deleted, or an identical prior receipt replayed |
| 400 | Validation error (see Errors) |
| 401 | Authentication required |
| 403 | Key lacks post:delete or lacks authority over every affected target |
| 404 | Draft not found |
| 409 | UNSUPPORTED_STATE (post is not an unaccepted local draft), REVISION_CONFLICT, or idempotency conflict |
| 428 | REVISION_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
| Name | Type | Required | Description |
|---|---|---|---|
| Idempotency-Key | UUID | Yes | Client mutation request identifier |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expectedRevision | integer | Yes | Current 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.
| Status | Meaning |
|---|---|
| 200 | Post archived (or identical replay returned) |
| 400 | Validation error (see Errors) |
| 401 | Authentication required |
| 403 | Key lacks post:delete or lacks authority over every affected target |
| 404 | Post not found |
| 409 | UNSUPPORTED_STATE (only finished posts without active publications can be archived), REVISION_CONFLICT, or idempotency conflict |
| 428 | REVISION_REQUIRED (missing expectedRevision) |
