Insights

Read saved account and post metrics, batch reads, and daily metric history with freshness and explicit gaps.

Updated

Open in ClaudeOpen in ChatGPT
On this page

The insights endpoints return metrics that Postkub has already synced from the connected accounts - never fabricated numbers. Every response reports freshness (fresh, stale, or never_synced) and lastSyncedAt, and when a requested range is not fresh, the read still returns the last saved snapshot while enqueueing a background sync for next time. Missing or unsupported metrics are explicit: value is null and unavailableReason says why, in plain machine-readable reasons. All endpoints need insight:read for API keys; sessions read everything in the workspace.

Range rules apply to every endpoint: pass rangeStartUtc and rangeEndUtc together as ISO instants with start before end, and the window may span at most 90 days. Omit both to read the default range of the last 30 days ending now. All times are UTC.

Read account insights

GET /api/v1/accounts/{id}/insights

Reads the saved insight snapshot for one account over the requested range. Scopes: insight:read. CLI: postkub insights account. MCP: insights_account.

Parameters

NameInTypeRequiredDescription
idpathstringYesSocial account ID
rangeStartUtcquerystringWith rangeEndUtcISO instant, range window start
rangeEndUtcquerystringWith rangeStartUtcISO instant, range window end, max 90 days after the start

Request example

curl -sS "https://postkub.com/api/v1/accounts/acc_example1/insights?rangeStartUtc=2026-11-04T00:00:00.000Z&rangeEndUtc=2026-12-04T00:00:00.000Z" \
  -H "Authorization: Bearer <API_KEY>"

Response 200 OK

{
  "accountId": "acc_example1",
  "range": { "startUtc": "2026-11-04T00:00:00.000Z", "endUtc": "2026-12-04T00:00:00.000Z" },
  "freshness": "fresh",
  "lastSyncedAt": "2026-12-04T07:45:00.000Z",
  "metrics": [
    { "name": "impressions", "value": 1200, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
    { "name": "reach", "value": 980, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
    { "name": "likes", "value": 154, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
    { "name": "comments", "value": 23, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
    { "name": "shares", "value": 12, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
    { "name": "saves", "value": null, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": "unsupported_by_provider" },
    { "name": "video_views", "value": 3100, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
    { "name": "profile_views", "value": 45, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
    { "name": "followers", "value": 1261, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null }
  ]
}

The metrics array always lists the same nine names: impressions, reach, likes, comments, shares, saves, video_views, profile_views, followers. unit is count or milliseconds. When a metric has no value, unavailableReason explains it: unsupported_by_provider, not_available_yet, permission_denied, or unknown; the API never fills gaps with zeros or guesses. freshness is fresh when the snapshot was synced within the last 15 minutes; stale and never_synced responses still return whatever is saved and enqueue a refresh.

StatusMeaning
200Saved snapshot returned (possibly stale)
400Invalid UTC range (see Errors)
401Authentication required
403Key lacks insight:read
404Account not found or outside the key's scope

Read post insights

GET /api/v1/posts/{id}/insights

Reads saved insights for one post, one entry per authorized target account. The response echoes the requested range, but the background sync always fetches the provider post's lifetime insights, so treat the values as lifetime figures. Scopes: insight:read. CLI: postkub insights post. MCP: insights_post.

Parameters

NameInTypeRequiredDescription
idpathstringYesPost ID
rangeStartUtcquerystringWith rangeEndUtcISO instant, range window start
rangeEndUtcquerystringWith rangeStartUtcISO instant, range window end, max 90 days after the start

Request example

curl -sS "https://postkub.com/api/v1/posts/post_example123/insights" \
  -H "Authorization: Bearer <API_KEY>"

Response 200 OK

{
  "postId": "post_example123",
  "range": { "startUtc": "2026-11-04T00:00:00.000Z", "endUtc": "2026-12-04T00:00:00.000Z" },
  "targets": [
    {
      "socialAccountId": "acc_example1",
      "freshness": "never_synced",
      "lastSyncedAt": null,
      "metrics": [
        { "name": "impressions", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "reach", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "likes", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "comments", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "shares", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "saves", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "video_views", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "profile_views", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" },
        { "name": "followers", "value": null, "unit": "count", "asOf": null, "unavailableReason": "not_available_yet" }
      ],
      "unavailableReason": "not_published"
    }
  ]
}

A target whose publication has not produced a provider post yet answers freshness: never_synced with unavailableReason: not_published; published targets use the same metric shape as the account endpoint. A key only sees targets inside its own scope, and a post with no accessible targets answers 404.

StatusMeaning
200Per-target snapshots returned (possibly stale)
400Invalid UTC range (see Errors)
401Authentication required
403Key lacks insight:read
404Post not found or no accessible target accounts

Batch account insights

GET /api/v1/insights/accounts

Consolidates a dashboard read into one request: the selected accounts for the active window and, optionally, a comparison window. Per-item authorization and freshness gating match the single-account endpoint, including per-item sync enqueues. Not available as a CLI command or MCP tool. Scopes: insight:read.

Query parameters

NameTypeRequiredDescription
accountIdstringYesRepeatable account filter, 1-25 IDs
rangeStartUtcstringNoISO instant, active window start
rangeEndUtcstringNoISO instant, active window end
previousRangeStartUtcstringNoISO instant, comparison window start, must start before the active window
previousRangeEndUtcstringNoISO instant, comparison window end

Each start/end pair must be provided together, and each window may span at most 90 days.

Request example

curl -sS "https://postkub.com/api/v1/insights/accounts?accountId=acc_example1&accountId=acc_example2&rangeStartUtc=2026-11-04T00:00:00.000Z&rangeEndUtc=2026-12-04T00:00:00.000Z&previousRangeStartUtc=2026-10-04T00:00:00.000Z&previousRangeEndUtc=2026-11-04T00:00:00.000Z" \
  -H "Authorization: Bearer <API_KEY>"

Response 200 OK

{
  "accounts": [
    {
      "accountId": "acc_example1",
      "range": { "startUtc": "2026-11-04T00:00:00.000Z", "endUtc": "2026-12-04T00:00:00.000Z" },
      "freshness": "fresh",
      "lastSyncedAt": "2026-12-04T07:45:00.000Z",
      "metrics": [
        { "name": "impressions", "value": 1200, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "reach", "value": 980, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "likes", "value": 154, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "comments", "value": 23, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "shares", "value": 12, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "saves", "value": null, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": "unsupported_by_provider" },
        { "name": "video_views", "value": 3100, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "profile_views", "value": 45, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "followers", "value": 1261, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null }
      ]
    }
  ],
  "previousAccounts": [
    {
      "accountId": "acc_example1",
      "range": { "startUtc": "2026-10-04T00:00:00.000Z", "endUtc": "2026-11-04T00:00:00.000Z" },
      "freshness": "fresh",
      "lastSyncedAt": "2026-12-04T07:45:00.000Z",
      "metrics": [
        { "name": "impressions", "value": 1105, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "reach", "value": 940, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "likes", "value": 149, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "comments", "value": 20, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "shares", "value": 9, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "saves", "value": null, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": "unsupported_by_provider" },
        { "name": "video_views", "value": 2870, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "profile_views", "value": 51, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
        { "name": "followers", "value": 1180, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null }
      ]
    }
  ]
}

Each entry in accounts and previousAccounts has the same shape as the single-account response. previousAccounts stays an empty array unless you pass the previousRange pair.

StatusMeaning
200Per-account snapshots returned (possibly stale)
400Invalid query: bad range, more than 25 IDs, or mismatched windows (see Errors)
401Authentication required
403Key lacks insight:read
404One of the requested accounts is unknown or outside the key's scope

Batch post insights

GET /api/v1/insights/posts

Consolidates per-post table reads into one request. Per-item authorization and sync enqueues match the single-post endpoint. Not available as a CLI command or MCP tool. Scopes: insight:read.

Query parameters

NameTypeRequiredDescription
postIdstringYesRepeatable post filter, 1-25 IDs
rangeStartUtcstringNoISO instant, range window start
rangeEndUtcstringNoISO instant, range window end, max 90 days

Request example

curl -sS "https://postkub.com/api/v1/insights/posts?postId=post_example123&postId=post_example124" \
  -H "Authorization: Bearer <API_KEY>"

Response 200 OK

{
  "posts": [
    {
      "postId": "post_example123",
      "range": { "startUtc": "2026-11-04T00:00:00.000Z", "endUtc": "2026-12-04T00:00:00.000Z" },
      "targets": [
        {
          "socialAccountId": "acc_example1",
          "freshness": "fresh",
          "lastSyncedAt": "2026-12-04T07:45:00.000Z",
          "metrics": [
            { "name": "impressions", "value": 540, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
            { "name": "reach", "value": 480, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
            { "name": "likes", "value": 61, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
            { "name": "comments", "value": 12, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
            { "name": "shares", "value": 4, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
            { "name": "saves", "value": null, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": "unsupported_by_provider" },
            { "name": "video_views", "value": 990, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
            { "name": "profile_views", "value": 8, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null },
            { "name": "followers", "value": 1261, "unit": "count", "asOf": "2026-12-04T07:45:00.000Z", "unavailableReason": null }
          ],
          "unavailableReason": null
        }
      ]
    }
  ]
}

Each entry in posts has the same shape as the single-post response.

StatusMeaning
200Per-post snapshots returned (possibly stale)
400Invalid query: bad range or more than 25 IDs (see Errors)
401Authentication required
403Key lacks insight:read
404One of the requested posts is unknown or has no accessible target accounts

Daily metric series

GET /api/v1/insights/metric-series

Returns stored per-day metric snapshots for charting, one series per requested metric per account. The default metric is followers. Accounts with no saved history, or stale ones, enqueue a sync that backfills provider history where the provider exposes it; providers without metric history simply keep returning no rows. Not available as a CLI command or MCP tool. Scopes: insight:read.

Query parameters

NameTypeRequiredDescription
accountIdstringYesRepeatable account filter, 1-25 IDs
metricstringNoRepeatable metric filter, 1-6 values; one of impressions, reach, likes, comments, shares, saves, video_views, profile_views, followers; default followers
rangeStartUtcstringNoISO instant, range window start
rangeEndUtcstringNoISO instant, range window end, max 90 days

Request example

curl -sS "https://postkub.com/api/v1/insights/metric-series?accountId=acc_example1&metric=followers" \
  -H "Authorization: Bearer <API_KEY>"

Response 200 OK

{
  "range": { "startUtc": "2026-11-04T00:00:00.000Z", "endUtc": "2026-12-04T00:00:00.000Z" },
  "accounts": [
    {
      "accountId": "acc_example1",
      "freshness": "fresh",
      "lastSyncedAt": "2026-12-04T07:45:00.000Z",
      "series": [
        {
          "metric": "followers",
          "points": [
            { "day": "2026-12-03", "value": 1250 },
            { "day": "2026-12-04", "value": 1261 }
          ]
        }
      ]
    }
  ]
}

day is a UTC calendar date in YYYY-MM-DD form. Days the sync has not filled simply do not appear in points; the API never interpolates missing days.

StatusMeaning
200Per-account daily series returned (possibly empty for cold ranges)
400Invalid query: bad range, more than 25 IDs, more than 6 metrics, or an unknown metric name (see Errors)
401Authentication required
403Key lacks insight:read
404One of the requested accounts is unknown or outside the key's scope