API reference
Base URL, authentication, idempotency, optimistic revisions, errors, and the full v1 operation index for the Postkub REST API.
Updated
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, orKEY_REVOKED). - Sending both a session cookie and an
Authorizationheader returns400 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_CONFLICTwitherror.details.currentRevisionso 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
| Status | Meaning |
|---|---|
| 200 | Success, or an idempotent replay of a previous success |
| 201 | New resource created (draft post) |
| 202 | Accepted asynchronous work; not yet a provider success |
| 400 | Validation error, malformed headers, or ambiguous credentials |
| 401 | Authentication required or key expired/revoked |
| 403 | Scope, target authority, or lane denied |
| 404 | Resource not found or outside the key's scope |
| 409 | Revision conflict, idempotency conflict, or unsupported state |
| 422 | Semantically invalid request (unsupported media, schedule rule, no available slot) |
| 428 | Precondition required (expectedRevision missing) |
| 429 | Key rate limit exceeded; error.details.retryAfterMs indicates the wait |
| 500 | Internal error (sanitized; retryable: false) |
| 503 | Rate-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:
| Operation | Method and path | Scope |
|---|---|---|
| Inspect the authenticated principal | GET /api/v1/me | Any valid key |
| List Brands | GET /api/v1/brands | brand:read |
| List accounts | GET /api/v1/accounts | account:read |
| Get account capabilities | GET /api/v1/accounts/{id}/capabilities | account:read |
| Read schedule settings | GET /api/v1/accounts/{id}/schedule-settings | account:read |
| Update schedule settings | PATCH /api/v1/accounts/{id}/schedule-settings | account:schedule |
| List synced videos | GET /api/v1/accounts/{id}/synced-videos | insight:read |
Posts
On Posts:
| Operation | Method and path | Scope |
|---|---|---|
| Create a post | POST /api/v1/posts | post:create |
| List posts | GET /api/v1/posts | post:read |
| Get a post | GET /api/v1/posts/{id} | post:read |
| Update a post | PATCH /api/v1/posts/{id} | post:update |
| Delete a draft | DELETE /api/v1/posts/{id} | post:delete |
| Archive a post | POST /api/v1/posts/{id}/archive | post:delete |
Publications
On Publications:
| Operation | Method and path | Scope |
|---|---|---|
| Publish now | POST /api/v1/posts/{id}/publish | post:publish |
| Schedule a post | POST /api/v1/posts/{id}/schedule | post:publish, post:schedule |
| Cancel publications | POST /api/v1/posts/{id}/cancel | post:cancel |
| Retry failed publications | POST /api/v1/posts/{id}/retry | post:publish |
| Retry a video cover | POST /api/v1/posts/{id}/cover-retry | post:publish |
Inbox, insights, activity
Owned by their own reference pages:
| Area | Page |
|---|---|
| Threads, inbox posts, comments, replies, likes | Inbox |
| Account insights, post insights, batch reads, metric series | Insights |
| Activity log and durable request lookup | Requests & Activity |
Next steps
- New here? Follow Getting Started to issue a key, then Your First Post.
- Automating from a terminal or an AI agent? See CLI, CLI reference, MCP, and Agents.
