{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/postzen-dev/json-schema/postzen-dev-analytics-post-schema.json",
  "title": "AnalyticsPost",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/postzen-dev-analytics-api-openapi.yml#/components/schemas/AnalyticsPost",
  "type": "object",
  "required": [
    "postId",
    "postzenPostId",
    "status",
    "content",
    "scheduledFor",
    "publishedAt",
    "analytics",
    "platformAnalytics",
    "platform",
    "platformPostUrl",
    "isExternal",
    "syncStatus",
    "message",
    "thumbnailUrl",
    "mediaType",
    "mediaItems"
  ],
  "properties": {
    "postId": {
      "type": "string"
    },
    "postzenPostId": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string"
    },
    "content": {
      "type": "string"
    },
    "scheduledFor": {
      "type": "string",
      "format": "date-time"
    },
    "publishedAt": {
      "type": "string",
      "format": "date-time"
    },
    "analytics": {
      "$ref": "#/$defs/AnalyticsMetrics"
    },
    "platformAnalytics": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PlatformAnalytics"
      }
    },
    "platform": {
      "$ref": "#/$defs/AnalyticsPlatform"
    },
    "platformPostUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "isExternal": {
      "type": "boolean"
    },
    "syncStatus": {
      "type": "string",
      "enum": [
        "synced",
        "pending",
        "failed"
      ]
    },
    "message": {
      "type": [
        "string",
        "null"
      ]
    },
    "thumbnailUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "mediaType": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "image",
        "video",
        "text",
        "carousel",
        null
      ]
    },
    "mediaItems": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AnalyticsMediaItem"
      }
    }
  },
  "$defs": {
    "AnalyticsMediaItem": {
      "type": "object",
      "required": [
        "type",
        "url",
        "thumbnail"
      ],
      "properties": {
        "type": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "thumbnail": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "AnalyticsMetricTotals": {
      "type": "object",
      "description": "The eight normalized metrics returned for every platform. A platform that reports a single view count returns it in both `views` and `impressions`. A metric the platform does not report is returned as `0`, so check the per-platform coverage in the API reference before reading a zero as no activity. `reach` is currently reported for Instagram only.",
      "required": [
        "impressions",
        "reach",
        "likes",
        "comments",
        "shares",
        "saves",
        "clicks",
        "views"
      ],
      "properties": {
        "impressions": {
          "type": "number"
        },
        "reach": {
          "type": "number"
        },
        "likes": {
          "type": "number"
        },
        "comments": {
          "type": "number"
        },
        "shares": {
          "type": "number"
        },
        "saves": {
          "type": "number"
        },
        "clicks": {
          "type": "number"
        },
        "views": {
          "type": "number"
        }
      }
    },
    "AnalyticsMetrics": {
      "allOf": [
        {
          "$ref": "#/$defs/AnalyticsMetricTotals"
        },
        {
          "type": "object",
          "required": [
            "engagementRate",
            "lastUpdated"
          ],
          "properties": {
            "engagementRate": {
              "type": "number",
              "description": "Interactions (likes + comments + shares + saves + clicks) divided by impressions, multiplied by 100 and rounded to two decimals. On platforms that report no impressions, such as Bluesky, the value is the interaction count multiplied by 100 and is not a rate."
            },
            "lastUpdated": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            }
          }
        }
      ]
    },
    "AnalyticsPlatform": {
      "type": "string",
      "enum": [
        "x",
        "instagram",
        "tiktok",
        "linkedin",
        "facebook",
        "youtube",
        "threads",
        "pinterest",
        "bluesky",
        "telegram"
      ]
    },
    "PlatformAnalytics": {
      "type": "object",
      "required": [
        "platform",
        "status",
        "platformPostId",
        "accountId",
        "accountUsername",
        "analytics",
        "syncStatus",
        "platformPostUrl",
        "errorMessage"
      ],
      "properties": {
        "platform": {
          "$ref": "#/$defs/AnalyticsPlatform"
        },
        "status": {
          "type": "string"
        },
        "platformPostId": {
          "type": "string"
        },
        "accountId": {
          "type": "string"
        },
        "accountUsername": {
          "type": "string"
        },
        "analytics": {
          "$ref": "#/$defs/AnalyticsMetrics"
        },
        "syncStatus": {
          "type": "string",
          "enum": [
            "synced",
            "pending",
            "failed"
          ]
        },
        "platformPostUrl": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "errorMessage": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}