{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fractionalteams-com/json-schema/fractionalteams-com-paid-media-account-schema.json",
  "title": "PaidMediaAccount",
  "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/PaidMediaAccount",
  "type": "object",
  "required": [
    "platform",
    "account_id",
    "external_account_id",
    "label",
    "last_pulled_at",
    "campaigns"
  ],
  "properties": {
    "platform": {
      "type": "string",
      "enum": [
        "reddit",
        "linkedin"
      ]
    },
    "account_id": {
      "type": "integer",
      "description": "Portal id"
    },
    "external_account_id": {
      "type": "string",
      "description": "The platform's own account id"
    },
    "label": {
      "type": "string",
      "description": "Connection label and account name, as shown on the portal"
    },
    "last_pulled_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "Most recent pull across the account's campaigns (null if none)"
    },
    "campaigns": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/PaidMediaCampaign"
      }
    }
  },
  "$defs": {
    "PaidMediaCampaign": {
      "type": "object",
      "required": [
        "campaign_id",
        "external_campaign_id",
        "name",
        "latest"
      ],
      "properties": {
        "campaign_id": {
          "type": "integer",
          "description": "Portal id, the handle for getPaidMediaCampaignHistory"
        },
        "external_campaign_id": {
          "type": "string",
          "description": "The platform's own campaign id"
        },
        "name": {
          "type": "string"
        },
        "objective": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": [
            "string",
            "null"
          ],
          "description": "The platform's status word as pulled, e.g. ACTIVE, PAUSED, COMPLETED"
        },
        "last_seen_at": {
          "type": "string",
          "description": "Last pull in which the platform still listed this campaign"
        },
        "latest": {
          "description": "The most recent pull, or null if no pull has written metrics for this campaign",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/$defs/PaidMediaMetrics"
            }
          ]
        }
      }
    },
    "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)"
        }
      }
    }
  }
}