Pagination

Cursor pagination on Postkub list endpoints - parameters, ordering, scope-bound cursors, and UTC date filters.

Updated

Open in ClaudeOpen in ChatGPT
On this page

List endpoints on the Postkub API use opaque cursor pagination. Every list response carries the current page in items and an opaque nextCursor string that is null at the end of the visible set.

Parameters

ParameterTypeDefaultNotes
limitinteger 1-10050Page size; values above 100 are rejected
cursorstring-The nextCursor value from the previous page; omit on the first page

All list endpoints share this contract:

EndpointExtra filters
GET /api/v1/brands-
GET /api/v1/accountsbrandId
GET /api/v1/postsbrandId, accountId, status, from, to
GET /api/v1/activitybrandId, accountId, postId, from, to
GET /api/v1/threadsaccountId (repeatable), handled, postTargetId, socialPostId
GET /api/v1/commentsaccountId, threadId, unread
GET /api/v1/owner/webhook-endpoints-
GET /api/v1/owner/webhook-endpoints/{id}/deliveriesstatus (pending, succeeded, dead)

Field-level details for each list live in the API reference.

Response shape

{
  "items": [
    { "id": "post_9f2e1c", "status": "draft", "revision": 1 }
  ],
  "nextCursor": "eyJyIjoicG9zdHMiLCJ3Ijoid3NfMTIzIiwi"
}
  • items - the page's records, projected per your authority.
  • nextCursor - an opaque string for the next page. When it is null, you have reached the end. Always check for null rather than counting items: a short page can still be the last page.

Walk all pages

let cursor: string | undefined = undefined;
for (;;) {
  const params = new URLSearchParams({ limit: "50" });
  if (cursor) params.set("cursor", cursor);
  const res = await fetch(`https://postkub.com/api/v1/posts?${params}`, {
    headers: { Authorization: `Bearer ${process.env.POSTKUB_API_KEY}` },
  });
  const body = await res.json();
  for (const post of body.items) console.log(post.id);
  if (body.nextCursor === null) break;
  cursor = body.nextCursor;
}

Ordering

Lists are ordered newest first: createdAt descending with the record ID descending as the tie-breaker. The exception is GET /api/v1/threads, which orders by the thread's last comment time descending, so an actively discussed thread stays at the top.

Cursors are scope-bound and filter-bound

The cursor is an opaque token; treat it as a black box. Internally it records which workspace, which principal, and which filter set produced it, and a cursor only decodes on the exact same combination:

  • The same endpoint resource (a posts cursor is invalid on accounts).
  • The same workspace and principal - including the API key's ID and revision. Rotating or re-issuing a key invalidates its outstanding cursors.
  • The same filter values. Changing brandId, status, from, or to between pages invalidates the cursor.

A mismatched or malformed cursor is rejected with 400 INVALID_CURSOR. None of these are recoverable by retrying: start a fresh list with your new filters, and keep the filter set stable for the whole walk.

Cursors do not expire on a timer, but the underlying ordering uses creation time and IDs, so new records appear at the front of subsequent pages and deletions can shift results. For stable exports, pin the from/to window and walk the pages immediately.

UTC date-range filters

GET /api/v1/posts and GET /api/v1/activity accept from and to as ISO 8601 instants with a UTC offset or Z, for example 2026-12-01T00:00:00Z. The range applies to the record's creation time, is inclusive, and from must not be after to. Invalid or non-calendar values are rejected with 400 VALIDATION_ERROR. Schedule times and timezones are a different topic; see Scheduling.