{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/samva-dev/json-schema/samva-dev-campaign-run-report-schema.json",
  "title": "CampaignRunReport",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/samva-dev-campaigns-api-openapi.yml#/components/schemas/CampaignRunReport",
  "type": "object",
  "properties": {
    "campaignId": {
      "$ref": "#/$defs/CampaignId"
    },
    "runId": {
      "$ref": "#/$defs/CampaignRunId"
    },
    "totalRecipients": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "dispatchedCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "failedCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "skippedCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "deliveredCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "hardBounceCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "softBounceCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "complaintCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "engagement": {
      "$ref": "#/$defs/CampaignRunReportEngagement"
    },
    "unsubscribesByTopic": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CampaignRunReportTopicUnsubscribes"
      }
    },
    "replyCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "skippedReasons": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CampaignRunReportSkippedReason"
      }
    }
  },
  "required": [
    "campaignId",
    "runId",
    "totalRecipients",
    "dispatchedCount",
    "failedCount",
    "skippedCount",
    "deliveredCount",
    "hardBounceCount",
    "softBounceCount",
    "complaintCount",
    "engagement",
    "unsubscribesByTopic",
    "replyCount",
    "skippedReasons"
  ],
  "additionalProperties": false,
  "$defs": {
    "CampaignId": {
      "type": "string",
      "pattern": "^camp_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "CampaignId"
    },
    "CampaignRunId": {
      "type": "string",
      "pattern": "^crun_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "CampaignRunId"
    },
    "CampaignRunReportEngagement": {
      "type": "object",
      "properties": {
        "measurement": {
          "type": "string",
          "enum": [
            "directional"
          ]
        },
        "uniqueOpens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Directional unique recipients who opened, excluding machine events; not an exact measurement."
        },
        "uniqueClicks": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Directional unique recipients who clicked, excluding machine events; not an exact measurement."
        }
      },
      "required": [
        "measurement",
        "uniqueOpens",
        "uniqueClicks"
      ],
      "additionalProperties": false
    },
    "CampaignRunReportSkippedReason": {
      "type": "object",
      "properties": {
        "reason": {
          "type": "string",
          "enum": [
            "unsubscribed",
            "blocked",
            "suppressed",
            "opted_out",
            "unreachable",
            "no_identity",
            "inactive",
            "run_cancelled",
            "run_failed",
            "missing_merge_field"
          ]
        },
        "count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "reason",
        "count"
      ],
      "additionalProperties": false
    },
    "CampaignRunReportTopicUnsubscribes": {
      "type": "object",
      "properties": {
        "topicId": {
          "$ref": "#/$defs/TopicId"
        },
        "count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "topicId",
        "count"
      ],
      "additionalProperties": false
    },
    "TopicId": {
      "type": "string",
      "pattern": "^unsub_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "TopicId"
    }
  }
}