{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fractionalteams-com/json-schema/fractionalteams-com-paid-media-campaign-history-schema.json",
  "title": "PaidMediaCampaignHistory",
  "x-generated": "2026-11-08",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/fractionalteams-com-api-openapi.json#/components/schemas/PaidMediaCampaignHistory",
  "type": "object",
  "required": [
    "campaign",
    "metrics"
  ],
  "properties": {
    "campaign": {
      "type": "object",
      "required": [
        "campaign_id",
        "name",
        "platform"
      ],
      "properties": {
        "campaign_id": {
          "type": "integer"
        },
        "external_campaign_id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "objective": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_seen_at": {
          "type": "string"
        },
        "platform": {
          "type": "string",
          "enum": [
            "reddit",
            "linkedin"
          ]
        },
        "account_label": {
          "type": "string"
        },
        "external_account_id": {
          "type": "string"
        }
      }
    },
    "metrics": {
      "type": "array",
      "description": "Oldest first; one entry per pull",
      "items": {
        "$ref": "#/$defs/PaidMediaMetrics"
      }
    }
  },
  "$defs": {
    "PaidMediaMetrics": {
      "type": "object",
      "description": "One pull: delivery over the 30-day window ending at window_end, recorded at pulled_at.",
      "required": [
        "window_start",
        "window_end",
        "impressions",
        "clicks",
        "spend_minor_units",
        "spend",
        "currency",
        "pulled_at"
      ],
      "properties": {
        "window_start": {
          "type": "string",
          "format": "date"
        },
        "window_end": {
          "type": "string",
          "format": "date"
        },
        "impressions": {
          "type": "integer"
        },
        "clicks": {
          "type": "integer"
        },
        "spend_minor_units": {
          "type": "integer",
          "description": "Spend in the currency's minor units (pence, cents, grosze)"
        },
        "spend": {
          "type": "number",
          "description": "The same spend in major units (spend_minor_units ÷ 100)"
        },
        "currency": {
          "type": "string",
          "description": "ISO 4217 code, e.g. GBP"
        },
        "pulled_at": {
          "type": "string",
          "description": "When the pull ran (UTC)"
        }
      }
    }
  }
}