API Basics
Pagination and Filters
Page through lists with a cursor, filter them by time, and change their order.
Every list pages the same way, and every time-based list takes the same time filter. This page also covers sort and include.
Pagination
Every list returns data, nextCursor and hasMore.
{
"data": [{ "id": "pst_3c8a2d6e91b44f7a8e250d6b4c1f9a73" }],
"nextCursor": "eyJrZXkiOjE4MDM...",
"hasMore": true
}| Field | Meaning |
|---|---|
data | The items of this page |
nextCursor | The cursor of the next page, null on the last |
hasMore | true when another page follows |
Pass nextCursor as cursor until hasMore is false. Send the cursor unchanged, and keep the other parameters the same.
Leave cursor out to start over. On lists such as posts, accounts and media, a changed or foreign cursor returns 400 INVALID_CURSOR.
import { Configuration, PostsApi } from "@onepostly/sdk";
const postsApi = new PostsApi(
new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY })
);
let cursor: string | undefined;
do {
const page = await postsApi.listPosts({ status: "published", limit: 100, cursor });
for (const post of page.data) {
console.log(post.id, post.url);
}
cursor = page.nextCursor ?? undefined;
} while (cursor);Page Size
limit sets the page size of a list. A value below 1 or above the maximum for that list returns 400 VALIDATION_ERROR.
| List | Default | Maximum |
|---|---|---|
| Most lists | 50 | 100 |
| Comments and Facebook Page reviews | 50 | 50 |
| Account media | 20 | 20 |
Comments, reviews and account media follow the platform's page size. Each endpoint in the API Reference lists its limit.
Time Filters
Time-based lists and reports take since and until.
| Rule | Detail |
|---|---|
| Format | ISO 8601 with Z or an offset, such as 2026-08-01T00:00:00Z |
since | Inclusive |
until | Exclusive |
| Defaults | Each endpoint has its own, see below |
| Order | since must be before until |
A date alone or a time without a zone returns 400 VALIDATION_ERROR. A since after until returns 400 INVALID_RANGE.
Since until is exclusive, one window ends where the next begins. For all of August, send since=2026-08-01T00:00:00Z and until=2026-09-01T00:00:00Z. Encode + as %2B in a query string.
| Endpoint | Filters on | Default |
|---|---|---|
GET /v1/posts | Schedule, else publish, else creation time | No limit |
GET /v1/accounts | Connection time | No limit |
GET /v1/webhooks/{id}/deliveries | Delivery time | The last 7 days |
GET /v1/posts/{id}/analytics/timeline | UTC days | 90 days, also the maximum |
GET /v1/accounts/{id}/analytics | The insights period | The platform's default |
Deliveries are kept for your plan's log retention. A since older than that starts at the oldest delivery that is still kept.
Sorting
Some lists take sort, a field and a direction, such as created_desc for newest first. Every other list has a fixed order, mostly newest first.
| List | sort values | Default |
|---|---|---|
GET /v1/posts | created_*, published_*, scheduled_*, metric:<name> | created_desc |
GET /v1/accounts | created_desc, created_asc | created_desc |
Each * is desc or asc. See List Posts for the metric sorts.
Include
Some lists add extras when you ask with include, a comma-separated list.
| List | include | Adds |
|---|---|---|
GET /v1/posts | total, facets | Total, and counts per status and platform |
GET /v1/accounts | total | Total |
GET /v1/media | total | Total |
GET /v1/webhooks/{id}/deliveries | facets, histogram | Counts per status, and results over time |
total counts every match across all pages. An unknown value returns 400 VALIDATION_ERROR with the accepted values.
Errors
| Code | HTTP | Cause | Fix |
|---|---|---|---|
VALIDATION_ERROR | 400 | A bad limit, time format, sort or include | Fix the field in param |
INVALID_CURSOR | 400 | cursor is not from this list | Use the last nextCursor, or drop cursor |
INVALID_RANGE | 400 | since is not before until, or the range is too long | Fix the dates |
Other codes are in Errors.