{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/instasent/json-schema/instasent-campaign-summary-schema.json",
  "title": "CampaignSummary",
  "description": "What this project has been doing with campaigns: how many are in each phase, the\nlast one sent with its headline figures, the next one scheduled, and the sending\ncadence. Built from aggregates, so it answers \"what is going on here\" without\npaging through the campaign list.\n",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/product.openapi.yaml#/components/schemas/CampaignSummary",
  "type": "object",
  "properties": {
    "total": {
      "type": "integer"
    },
    "byPhase": {
      "type": "object",
      "description": "Campaign counts grouped into the six phases a person recognizes. The many\ninternal statuses map onto these; `byStatus` keeps the raw breakdown.\n",
      "properties": {
        "draft": {
          "type": "integer"
        },
        "preparing": {
          "type": "integer"
        },
        "scheduled": {
          "type": "integer"
        },
        "sending": {
          "type": "integer"
        },
        "sent": {
          "type": "integer"
        },
        "stopped": {
          "type": "integer"
        }
      }
    },
    "byStatus": {
      "type": "object",
      "description": "Campaign counts by raw status.",
      "additionalProperties": {
        "type": "integer"
      }
    },
    "lastSent": {
      "type": [
        "object",
        "null"
      ],
      "description": "The most recently sent campaign with its headline figures, or null if none was ever sent.",
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "channel": {
          "type": "string"
        },
        "sentAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "sentAgo": {
          "type": [
            "string",
            "null"
          ],
          "description": "How long ago it was sent, in words."
        },
        "recipients": {
          "type": "integer",
          "description": "Contacts the campaign was sent to."
        },
        "sent": {
          "type": "integer"
        },
        "delivered": {
          "type": "integer"
        },
        "deliveryRate": {
          "type": "number",
          "format": "float",
          "description": "Delivered over sent, precomputed as a fraction between 0 and 1."
        },
        "clicks": {
          "type": "integer"
        },
        "cost": {
          "type": "number",
          "format": "float",
          "description": "What the campaign cost, in the organization's billing currency."
        },
        "statsAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "When the campaign's statistics were last consolidated."
        }
      }
    },
    "nextScheduled": {
      "type": [
        "object",
        "null"
      ],
      "description": "The next campaign due to go out, or null if none is scheduled.",
      "properties": {
        "id": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "channel": {
          "type": "string"
        },
        "scheduledAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "inHours": {
          "type": [
            "number",
            "null"
          ],
          "format": "float",
          "description": "Hours from now until it sends."
        },
        "recipients": {
          "type": "integer",
          "description": "Contacts currently resolved for it."
        }
      }
    },
    "cadence": {
      "type": "object",
      "description": "How many campaigns were sent in each recent window.",
      "properties": {
        "sentLast30Days": {
          "type": "integer"
        },
        "sentLast90Days": {
          "type": "integer"
        }
      }
    }
  },
  "required": [
    "total",
    "byPhase",
    "byStatus",
    "cadence"
  ]
}