API reference

Base URL, authentication, idempotency, optimistic revisions, errors, and the full v1 operation index for the Postkub REST API.

Updated

Open in ClaudeOpen in ChatGPT
On this page

The Postkub REST API v1 is the single HTTP surface that external clients use: your own scripts call it directly, and the CLI and MCP server are thin clients over the same endpoints. This page covers the rules every request follows (base URL, authentication, idempotency, revisions, errors) and indexes every operation. The detailed reference is split across six pages.

Base URL

All v1 paths are rooted at:

https://postkub.com/api/v1

The web app origin proxies /api to the API service, so the same paths also work against the web origin. Examples in this documentation use the production base URL.

Authentication

Send your API key in the Authorization header on every request:

Authorization: Bearer <API_KEY>
  • A missing, malformed, expired, or revoked key returns 401 (UNAUTHORIZED, INVALID_TOKEN, KEY_EXPIRED, or KEY_REVOKED).
  • Sending both a session cookie and an Authorization header returns 400 AMBIGUOUS_CREDENTIALS. Pick one lane per request; API clients always use the Bearer header.
  • Every request is checked against the key's selected Brands, accounts, and action scopes. A key that passes authentication but lacks the required action or target returns 403 PERMISSION_DENIED.

The canonical scope strings and the scopes table live in Authentication & Scopes. Do not send cookies from a browser session in API clients.

Idempotency for mutations

Every mutating request (POST, PATCH, DELETE) requires an Idempotency-Key header holding a client-generated UUID:

Idempotency-Key: 7f6c2f1e-8b4a-4c3d-9e2f-1a2b3c4d5e6f
  • A missing or non-UUID value returns 400 VALIDATION_ERROR.
  • Repeating the same key with the same operation and payload returns the stored result of the first request instead of running the mutation twice.
  • Reusing a key with a different path, operation, or payload returns 409 IDEMPOTENCY_CONFLICT.
  • Replay is resolved before revision checks, so a safe retry of a lost response never fails with a stale revision.

Generate a fresh UUID per logical mutation and keep it until you have the final outcome. Full rules and request lookup are in Idempotency.

Revisions with expectedRevision

Every change to an existing resource (update a post, publish, schedule, cancel, retry, change schedule settings) requires the current expectedRevision integer in the body:

  • Omitting it returns 428 REVISION_REQUIRED.
  • Sending a stale value returns 409 REVISION_CONFLICT with error.details.currentRevision so you can re-read and retry.
  • Each accepted mutation increments the resource revision, so concurrent writers cannot silently overwrite each other.

Read requests never need a revision.

Error envelope

Every error response uses the same JSON envelope:

{
  "error": {
    "code": "REVISION_CONFLICT",
    "message": "Revision mismatch",
    "details": { "currentRevision": 3 },
    "retryable": false
  },
  "requestId": "7f6c2f1e-8b4a-4c3d-9e2f-1a2b3c4d5e6f"
}

requestId echoes your Idempotency-Key (or X-Request-ID) header when it is a valid UUID. The full error-code table and retry guidance live in Errors.

Pagination

List endpoints accept cursor and limit (1-100, default 50) and return nextCursor (null at the end). See Pagination.

HTTP status codes

StatusMeaning
200Success, or an idempotent replay of a previous success
201New resource created (draft post)
202Accepted asynchronous work; not yet a provider success
400Validation error, malformed headers, or ambiguous credentials
401Authentication required or key expired/revoked
403Scope, target authority, or lane denied
404Resource not found or outside the key's scope
409Revision conflict, idempotency conflict, or unsupported state
422Semantically invalid request (unsupported media, schedule rule, no available slot)
428Precondition required (expectedRevision missing)
429Key rate limit exceeded; error.details.retryAfterMs indicates the wait
500Internal error (sanitized; retryable: false)
503Rate-limit infrastructure unavailable; safe to retry

202 responses always carry per-target states and a status URL. Never treat 202 as provider success; see Scheduling.

Human-only surfaces

Keys, social connections, billing, and webhooks are managed in the dashboard with a signed-in human session and are not reachable with an API key: the owner administration routes under /api/v1/owner/** and the media upload gateway under /api/v1/media/** reject API keys with 403 KEY_LANE_FORBIDDEN. External clients attach media with public HTTPS URLs instead; see Hosted Media.

Operation index

Every operation below requires an authenticated key with the listed scope. Links jump to the full reference section.

Discovery

On Discovery:

OperationMethod and pathScope
Inspect the authenticated principalGET /api/v1/meAny valid key
List BrandsGET /api/v1/brandsbrand:read
List accountsGET /api/v1/accountsaccount:read
Get account capabilitiesGET /api/v1/accounts/{id}/capabilitiesaccount:read
Read schedule settingsGET /api/v1/accounts/{id}/schedule-settingsaccount:read
Update schedule settingsPATCH /api/v1/accounts/{id}/schedule-settingsaccount:schedule
List synced videosGET /api/v1/accounts/{id}/synced-videosinsight:read

Posts

On Posts:

OperationMethod and pathScope
Create a postPOST /api/v1/postspost:create
List postsGET /api/v1/postspost:read
Get a postGET /api/v1/posts/{id}post:read
Update a postPATCH /api/v1/posts/{id}post:update
Delete a draftDELETE /api/v1/posts/{id}post:delete
Archive a postPOST /api/v1/posts/{id}/archivepost:delete

Publications

On Publications:

OperationMethod and pathScope
Publish nowPOST /api/v1/posts/{id}/publishpost:publish
Schedule a postPOST /api/v1/posts/{id}/schedulepost:publish, post:schedule
Cancel publicationsPOST /api/v1/posts/{id}/cancelpost:cancel
Retry failed publicationsPOST /api/v1/posts/{id}/retrypost:publish
Retry a video coverPOST /api/v1/posts/{id}/cover-retrypost:publish

Inbox, insights, activity

Owned by their own reference pages:

AreaPage
Threads, inbox posts, comments, replies, likesInbox
Account insights, post insights, batch reads, metric seriesInsights
Activity log and durable request lookupRequests & Activity

Next steps