{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/postking-app/json-schema/postking-app-social-performance-response-schema.json",
  "title": "SocialPerformanceResponse",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/postking-app-openapi.json#/components/schemas/SocialPerformanceResponse",
  "type": "object",
  "properties": {
    "brandId": {
      "type": "string"
    },
    "days": {
      "type": "integer"
    },
    "platform": {
      "type": [
        "string",
        "null"
      ]
    },
    "period": {
      "type": "object",
      "properties": {
        "start": {
          "type": "string"
        },
        "end": {
          "type": "string"
        },
        "previousStart": {
          "type": "string"
        },
        "previousEnd": {
          "type": "string"
        }
      },
      "required": [
        "start",
        "end",
        "previousStart",
        "previousEnd"
      ]
    },
    "previousCoverage": {
      "type": "string",
      "enum": [
        "full",
        "partial",
        "none"
      ]
    },
    "summary": {
      "type": "object",
      "properties": {
        "followers": {
          "type": [
            "number",
            "null"
          ]
        },
        "followersPrevious": {
          "type": [
            "number",
            "null"
          ]
        },
        "postsPublished": {
          "type": "integer"
        },
        "postsPublishedPrevious": {
          "type": [
            "number",
            "null"
          ]
        },
        "impressions": {
          "type": [
            "number",
            "null"
          ]
        },
        "impressionsPrevious": {
          "type": [
            "number",
            "null"
          ]
        },
        "engagements": {
          "type": [
            "number",
            "null"
          ]
        },
        "engagementsPrevious": {
          "type": [
            "number",
            "null"
          ]
        },
        "engagementRate": {
          "type": [
            "number",
            "null"
          ]
        },
        "engagementRateBasis": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "posts": {
              "type": "integer"
            },
            "impressions": {
              "type": "number"
            },
            "engagements": {
              "type": "number"
            }
          },
          "required": [
            "posts",
            "impressions",
            "engagements"
          ],
          "description": "What engagementRate was computed from: only posts with measured impressions."
        },
        "pulse": {
          "type": [
            "number",
            "null"
          ]
        },
        "pulsePrevious": {
          "type": [
            "number",
            "null"
          ]
        },
        "pulseDeltaPct": {
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "followers",
        "followersPrevious",
        "postsPublished",
        "postsPublishedPrevious",
        "impressions",
        "impressionsPrevious",
        "engagements",
        "engagementsPrevious",
        "engagementRate",
        "engagementRateBasis",
        "pulse",
        "pulsePrevious",
        "pulseDeltaPct"
      ]
    },
    "accounts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "accountId": {
            "type": "string"
          },
          "platform": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "personal",
              "company",
              "page"
            ]
          },
          "handle": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "connected",
              "token_expired",
              "sync_failing",
              "disconnected",
              "session_invalid"
            ]
          },
          "statusSince": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "followers": {
            "type": [
              "number",
              "null"
            ]
          },
          "followersPrevious": {
            "type": [
              "number",
              "null"
            ]
          },
          "historyStart": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastSyncAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "posts": {
            "type": "integer"
          },
          "postsPrevious": {
            "type": [
              "number",
              "null"
            ]
          },
          "impressions": {
            "type": [
              "number",
              "null"
            ]
          },
          "impressionsPrevious": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagements": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagementsPrevious": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagementRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagementRateBasis": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "posts": {
                "type": "integer"
              },
              "impressions": {
                "type": "number"
              },
              "engagements": {
                "type": "number"
              }
            },
            "required": [
              "posts",
              "impressions",
              "engagements"
            ],
            "description": "What engagementRate was computed from: only posts with measured impressions."
          },
          "metricsAvailable": {
            "type": "object",
            "properties": {
              "followers": {
                "type": "boolean"
              },
              "postImpressions": {
                "type": "boolean"
              },
              "pageImpressions": {
                "type": "boolean"
              },
              "pageEngagements": {
                "type": "boolean"
              }
            },
            "required": [
              "followers",
              "postImpressions",
              "pageImpressions",
              "pageEngagements"
            ]
          },
          "metricsStatus": {
            "type": "string",
            "enum": [
              "ok",
              "sync_failing",
              "not_collected"
            ],
            "description": "Post-metrics sync health (separate from connection status): ok | sync_failing (the latest syncs errored, e.g. missing permission) | not_collected."
          },
          "metricsError": {
            "type": [
              "string",
              "null"
            ],
            "description": "Brief reason when metricsStatus is sync_failing."
          },
          "metricsStaleSince": {
            "type": [
              "string",
              "null"
            ],
            "description": "When post metrics stopped updating, if the newest metrics are older than ~30 days."
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "accountId",
          "platform",
          "type",
          "handle",
          "name",
          "status",
          "statusSince",
          "lastError",
          "followers",
          "followersPrevious",
          "historyStart",
          "lastSyncAt",
          "posts",
          "postsPrevious",
          "impressions",
          "impressionsPrevious",
          "engagements",
          "engagementsPrevious",
          "engagementRate",
          "engagementRateBasis",
          "metricsAvailable",
          "metricsStatus",
          "metricsError",
          "metricsStaleSince",
          "notes"
        ]
      }
    },
    "topPosts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "postId": {
            "type": "string"
          },
          "platform": {
            "type": "string"
          },
          "accountId": {
            "type": [
              "string",
              "null"
            ]
          },
          "publishedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "postLink": {
            "type": [
              "string",
              "null"
            ]
          },
          "preview": {
            "type": "string",
            "description": "First ~140 characters of the post."
          },
          "impressions": {
            "type": [
              "number",
              "null"
            ]
          },
          "reactions": {
            "type": [
              "number",
              "null"
            ],
            "description": "Platform-correct reactions (X: equals likes)."
          },
          "likes": {
            "type": [
              "number",
              "null"
            ]
          },
          "quotes": {
            "type": [
              "number",
              "null"
            ],
            "description": "X quote tweets; null on other platforms."
          },
          "comments": {
            "type": [
              "number",
              "null"
            ]
          },
          "shares": {
            "type": [
              "number",
              "null"
            ],
            "description": "Null when the platform does not provide shares."
          },
          "clicks": {
            "type": [
              "number",
              "null"
            ],
            "description": "Null when the platform does not provide clicks."
          },
          "engagementRate": {
            "type": [
              "number",
              "null"
            ],
            "description": "(reactions + comments) / impressions, 0..1. Null when impressions unknown."
          },
          "measuredAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "deletedOnPlatform": {
            "type": "boolean"
          },
          "duplicateOf": {
            "type": [
              "string",
              "null"
            ],
            "description": "Id of the earlier identical post (same account, <=30 min). Exclude from totals."
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "theme": {
            "type": [
              "string",
              "null"
            ],
            "description": "Theme the post was generated from (library or custom); null = not stored."
          },
          "format": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "text",
              "image",
              "carousel",
              "video",
              "poll",
              "reply",
              null
            ],
            "description": "text | image | carousel | video | poll | reply, derived from attached assets; null = unknown."
          },
          "visualType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "none",
              "image",
              "carousel",
              "video",
              null
            ],
            "description": "none | image | carousel | video; null = unknown (crawled post without stored media)."
          },
          "hook": {
            "type": [
              "string",
              "null"
            ],
            "description": "First line of the post (derived; PostKing stores no separate hook)."
          },
          "crawledId": {
            "type": "string",
            "description": "Set when this row's numbers come from the crawled LinkedIn company copy of the PostKing post `postId`."
          }
        },
        "required": [
          "postId",
          "platform",
          "accountId",
          "publishedAt",
          "postLink",
          "preview",
          "impressions",
          "reactions",
          "likes",
          "quotes",
          "comments",
          "shares",
          "clicks",
          "engagementRate",
          "measuredAt",
          "deletedOnPlatform",
          "duplicateOf",
          "note"
        ]
      }
    },
    "bottomPosts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "postId": {
            "type": "string"
          },
          "platform": {
            "type": "string"
          },
          "accountId": {
            "type": [
              "string",
              "null"
            ]
          },
          "publishedAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "postLink": {
            "type": [
              "string",
              "null"
            ]
          },
          "preview": {
            "type": "string",
            "description": "First ~140 characters of the post."
          },
          "impressions": {
            "type": [
              "number",
              "null"
            ]
          },
          "reactions": {
            "type": [
              "number",
              "null"
            ],
            "description": "Platform-correct reactions (X: equals likes)."
          },
          "likes": {
            "type": [
              "number",
              "null"
            ]
          },
          "quotes": {
            "type": [
              "number",
              "null"
            ],
            "description": "X quote tweets; null on other platforms."
          },
          "comments": {
            "type": [
              "number",
              "null"
            ]
          },
          "shares": {
            "type": [
              "number",
              "null"
            ],
            "description": "Null when the platform does not provide shares."
          },
          "clicks": {
            "type": [
              "number",
              "null"
            ],
            "description": "Null when the platform does not provide clicks."
          },
          "engagementRate": {
            "type": [
              "number",
              "null"
            ],
            "description": "(reactions + comments) / impressions, 0..1. Null when impressions unknown."
          },
          "measuredAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "deletedOnPlatform": {
            "type": "boolean"
          },
          "duplicateOf": {
            "type": [
              "string",
              "null"
            ],
            "description": "Id of the earlier identical post (same account, <=30 min). Exclude from totals."
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "theme": {
            "type": [
              "string",
              "null"
            ],
            "description": "Theme the post was generated from (library or custom); null = not stored."
          },
          "format": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "text",
              "image",
              "carousel",
              "video",
              "poll",
              "reply",
              null
            ],
            "description": "text | image | carousel | video | poll | reply, derived from attached assets; null = unknown."
          },
          "visualType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "none",
              "image",
              "carousel",
              "video",
              null
            ],
            "description": "none | image | carousel | video; null = unknown (crawled post without stored media)."
          },
          "hook": {
            "type": [
              "string",
              "null"
            ],
            "description": "First line of the post (derived; PostKing stores no separate hook)."
          },
          "crawledId": {
            "type": "string",
            "description": "Set when this row's numbers come from the crawled LinkedIn company copy of the PostKing post `postId`."
          }
        },
        "required": [
          "postId",
          "platform",
          "accountId",
          "publishedAt",
          "postLink",
          "preview",
          "impressions",
          "reactions",
          "likes",
          "quotes",
          "comments",
          "shares",
          "clicks",
          "engagementRate",
          "measuredAt",
          "deletedOnPlatform",
          "duplicateOf",
          "note"
        ]
      },
      "description": "Lowest-scoring measured posts (same ranking as topPosts, ascending)."
    },
    "bestTimes": {
      "type": "object",
      "properties": {
        "timezone": {
          "type": "string",
          "enum": [
            "UTC"
          ]
        },
        "platforms": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "platform": {
                "type": "string"
              },
              "posts": {
                "type": "integer"
              },
              "cells": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Group label; null = posts where this dimension is not stored."
                    },
                    "posts": {
                      "type": "integer"
                    },
                    "impressions": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "engagements": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "clicks": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "engagementRate": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "engagementRateBasis": {
                      "type": [
                        "object",
                        "null"
                      ],
                      "properties": {
                        "posts": {
                          "type": "integer"
                        },
                        "impressions": {
                          "type": "number"
                        },
                        "engagements": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "posts",
                        "impressions",
                        "engagements"
                      ],
                      "description": "What engagementRate was computed from: only posts with measured impressions."
                    },
                    "medianEngagementRate": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Median of per-post engagementRate over posts with a measured rate."
                    },
                    "lowSample": {
                      "type": "boolean",
                      "description": "True when fewer than 3 posts have a measured rate."
                    },
                    "dayOfWeek": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 6,
                      "description": "0 = Monday ... 6 = Sunday (UTC)."
                    },
                    "day": {
                      "type": "string"
                    },
                    "hour": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 23,
                      "description": "Hour of day, UTC."
                    }
                  },
                  "required": [
                    "key",
                    "posts",
                    "impressions",
                    "engagements",
                    "clicks",
                    "engagementRate",
                    "engagementRateBasis",
                    "medianEngagementRate",
                    "lowSample",
                    "dayOfWeek",
                    "day",
                    "hour"
                  ]
                }
              }
            },
            "required": [
              "platform",
              "posts",
              "cells"
            ]
          }
        }
      },
      "required": [
        "timezone",
        "platforms"
      ]
    },
    "byTheme": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Group label; null = posts where this dimension is not stored."
          },
          "posts": {
            "type": "integer"
          },
          "impressions": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagements": {
            "type": [
              "number",
              "null"
            ]
          },
          "clicks": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagementRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagementRateBasis": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "posts": {
                "type": "integer"
              },
              "impressions": {
                "type": "number"
              },
              "engagements": {
                "type": "number"
              }
            },
            "required": [
              "posts",
              "impressions",
              "engagements"
            ],
            "description": "What engagementRate was computed from: only posts with measured impressions."
          },
          "medianEngagementRate": {
            "type": [
              "number",
              "null"
            ],
            "description": "Median of per-post engagementRate over posts with a measured rate."
          },
          "lowSample": {
            "type": "boolean",
            "description": "True when fewer than 3 posts have a measured rate."
          }
        },
        "required": [
          "key",
          "posts",
          "impressions",
          "engagements",
          "clicks",
          "engagementRate",
          "engagementRateBasis",
          "medianEngagementRate",
          "lowSample"
        ]
      }
    },
    "byFormat": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Group label; null = posts where this dimension is not stored."
          },
          "posts": {
            "type": "integer"
          },
          "impressions": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagements": {
            "type": [
              "number",
              "null"
            ]
          },
          "clicks": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagementRate": {
            "type": [
              "number",
              "null"
            ]
          },
          "engagementRateBasis": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "posts": {
                "type": "integer"
              },
              "impressions": {
                "type": "number"
              },
              "engagements": {
                "type": "number"
              }
            },
            "required": [
              "posts",
              "impressions",
              "engagements"
            ],
            "description": "What engagementRate was computed from: only posts with measured impressions."
          },
          "medianEngagementRate": {
            "type": [
              "number",
              "null"
            ],
            "description": "Median of per-post engagementRate over posts with a measured rate."
          },
          "lowSample": {
            "type": "boolean",
            "description": "True when fewer than 3 posts have a measured rate."
          }
        },
        "required": [
          "key",
          "posts",
          "impressions",
          "engagements",
          "clicks",
          "engagementRate",
          "engagementRateBasis",
          "medianEngagementRate",
          "lowSample"
        ]
      }
    },
    "timeseries": {
      "type": "object",
      "properties": {
        "granularity": {
          "type": "string",
          "enum": [
            "day",
            "week",
            "month"
          ]
        },
        "dates": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "posts": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "impressions": {
          "type": "array",
          "items": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "engagements": {
          "type": "array",
          "items": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "followers": {
          "type": "array",
          "items": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      },
      "required": [
        "granularity",
        "dates",
        "posts",
        "impressions",
        "engagements",
        "followers"
      ]
    },
    "cadence": {
      "type": "object",
      "properties": {
        "targetPerWeek": {
          "type": "number"
        },
        "publishedThisWeek": {
          "type": "number"
        },
        "publishedLastWeek": {
          "type": "number"
        },
        "streakWeeks": {
          "type": "number"
        },
        "weeklyPosts": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "perPlatform": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "platform": {
                "type": "string"
              },
              "target": {
                "type": "number"
              },
              "thisWeek": {
                "type": "number"
              },
              "lastWeek": {
                "type": "number"
              },
              "onTarget": {
                "type": "boolean"
              },
              "streakWeeks": {
                "type": "number"
              },
              "lastPostedAt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "platform",
              "target",
              "thisWeek",
              "lastWeek",
              "onTarget",
              "streakWeeks",
              "lastPostedAt"
            ]
          }
        }
      },
      "required": [
        "targetPerWeek",
        "publishedThisWeek",
        "publishedLastWeek",
        "streakWeeks",
        "weeklyPosts",
        "perPlatform"
      ]
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "brandId",
    "days",
    "platform",
    "period",
    "previousCoverage",
    "notes"
  ]
}