{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "run": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "campaignId": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "campaignRevision": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "status": {
          "type": "string",
          "enum": [
            "finding_prospects",
            "verifying_contacts",
            "preparing_emails",
            "adding_prospects",
            "completed",
            "added_to_campaign",
            "saved_to_crm",
            "failed"
          ]
        },
        "terminal": {
          "type": "boolean"
        },
        "progress": {
          "type": "object",
          "properties": {
            "target": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                {
                  "type": "null"
                }
              ]
            },
            "prospectsFound": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "prospectsQualified": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                {
                  "type": "null"
                }
              ]
            },
            "contactsVerified": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "emailsPrepared": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "emailsHeld": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                {
                  "type": "null"
                }
              ]
            },
            "addedToCampaign": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "target",
            "prospectsFound",
            "prospectsQualified",
            "contactsVerified",
            "emailsPrepared",
            "emailsHeld",
            "addedToCampaign"
          ],
          "additionalProperties": false
        },
        "skipped": {
          "maxItems": 8,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "reason": {
                "type": "string",
                "enum": [
                  "not_a_fit",
                  "no_verified_email",
                  "already_contacted",
                  "not_eligible",
                  "details_unverified",
                  "email_not_written",
                  "lead_limit_reached",
                  "other"
                ]
              },
              "count": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "label": {
                "type": "string"
              }
            },
            "required": ["reason", "count", "label"],
            "additionalProperties": false
          }
        },
        "failure": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "reason": {
                  "type": "string",
                  "enum": [
                    "workspace_details_missing",
                    "no_matching_accounts",
                    "no_verified_emails",
                    "allowance_reached",
                    "temporarily_unavailable",
                    "emails_not_prepared",
                    "prospects_not_added",
                    "could_not_complete"
                  ]
                },
                "stoppedAt": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "finding_prospects",
                        "verifying_contacts",
                        "preparing_emails",
                        "adding_prospects"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "message": {
                  "type": "string"
                }
              },
              "required": ["reason", "stoppedAt", "message"],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "createdAt": {
          "type": "string"
        },
        "updatedAt": {
          "type": "string"
        },
        "completedAt": {
          "type": ["string", "null"]
        },
        "reviewUrl": {
          "type": "string",
          "format": "uri"
        },
        "next": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "campaignId",
        "campaignRevision",
        "status",
        "terminal",
        "progress",
        "skipped",
        "failure",
        "createdAt",
        "updatedAt",
        "completedAt",
        "reviewUrl",
        "next"
      ],
      "additionalProperties": false
    }
  },
  "required": ["run"],
  "additionalProperties": false
}
