{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fuxux-com/json-schema/fuxux-com-analytics-response-schema.json",
  "title": "AnalyticsResponse",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/fuxux-com-openapi.json#/components/schemas/AnalyticsResponse",
  "type": "object",
  "properties": {
    "chartDays": {
      "type": "integer",
      "enum": [
        7,
        14,
        30,
        90
      ]
    },
    "summary": {
      "type": "object",
      "properties": {
        "totalPublished": {
          "type": "integer"
        },
        "publishedThisMonth": {
          "type": "integer"
        },
        "publishedLastMonth": {
          "type": "integer"
        },
        "momChange": {
          "type": [
            "integer",
            "null"
          ]
        },
        "scheduled": {
          "type": "integer"
        },
        "successRate": {
          "type": [
            "number",
            "null"
          ],
          "description": "% of variants published successfully in the selected window"
        }
      }
    },
    "dailyPosts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "description": "YYYY-MM-DD"
          },
          "count": {
            "type": "integer"
          }
        }
      }
    },
    "platformBreakdown": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "platform": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "published": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "engagement": {
            "$ref": "#/$defs/EngagementTotals"
          },
          "postsWithInsights": {
            "type": "integer",
            "description": "How many of this platform's published posts in the window have synced engagement data"
          }
        }
      }
    },
    "engagement": {
      "allOf": [
        {
          "$ref": "#/$defs/EngagementTotals"
        },
        {
          "type": "object",
          "properties": {
            "postsWithInsights": {
              "type": "integer",
              "description": "How many published posts in the window have synced engagement data"
            }
          }
        }
      ],
      "description": "Aggregated real engagement (likes/comments/shares/views/impressions/reach) synced from the platforms for posts published in the selected window. engagement_rate is not summed here since it's a per-post percentage; it's only present per-post on recentPosts[].post_variants[].insights."
    },
    "recentPosts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "description": "Each item's post_variants[] may include an `insights` object (likes, comments, shares, views, impressions, reach, engagement_rate, and other platform-specific fields) and `insights_updated_at`, where synced."
      }
    }
  },
  "$defs": {
    "EngagementTotals": {
      "type": "object",
      "properties": {
        "likes": {
          "type": "integer"
        },
        "comments": {
          "type": "integer"
        },
        "shares": {
          "type": "integer"
        },
        "views": {
          "type": "integer"
        },
        "impressions": {
          "type": "integer"
        },
        "reach": {
          "type": "integer"
        }
      }
    }
  }
}