{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/volanea-com/json-schema/volanea-com-campaign-schema.json",
  "title": "Campaign",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/volanea-com-openapi.json#/components/schemas/Campaign",
  "type": "object",
  "properties": {
    "campaignId": {
      "type": "string"
    },
    "projectId": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "subject": {
      "type": "string"
    },
    "previewText": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 200,
      "description": "Preheader — the preview line inboxes show after the subject. Injected as a hidden block at the top of the body at send time."
    },
    "body": {
      "type": "string"
    },
    "bodyBlocks": {
      "type": [
        "string",
        "array",
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "The visual editor's design `body` was compiled from — a JSON string of the GrapesJS project (or a legacy block array/object), stored so the editor can reopen it. Ignored when sending — only `body` is delivered."
    },
    "fromName": {
      "type": [
        "string",
        "null"
      ]
    },
    "fromEmail": {
      "type": "string",
      "format": "email"
    },
    "replyTo": {
      "type": [
        "string",
        "null"
      ],
      "format": "email",
      "description": "Becomes the Reply-To header when set."
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "scheduled",
        "sending",
        "sent",
        "cancelled"
      ]
    },
    "audience": {
      "type": "string",
      "enum": [
        "all",
        "segment",
        "filter"
      ]
    },
    "segmentId": {
      "type": [
        "string",
        "null"
      ]
    },
    "filter": {
      "oneOf": [
        {
          "$ref": "#/$defs/SegmentConditions"
        },
        {
          "type": "null"
        }
      ]
    },
    "abSubjectB": {
      "type": [
        "string",
        "null"
      ]
    },
    "abSamplePct": {
      "type": [
        "integer",
        "null"
      ]
    },
    "abDecideAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "abWinner": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "a",
        "b",
        null
      ]
    },
    "scheduledFor": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "sentAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "totalRecipients": {
      "type": "integer"
    },
    "delivered": {
      "type": "integer"
    },
    "opened": {
      "type": "integer"
    },
    "clicked": {
      "type": "integer"
    },
    "bounced": {
      "type": "integer"
    },
    "complained": {
      "type": "integer"
    },
    "unsubscribed": {
      "type": "integer"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "campaignId",
    "name",
    "subject",
    "body",
    "fromEmail",
    "status",
    "audience",
    "createdAt"
  ],
  "$defs": {
    "SegmentConditions": {
      "type": "object",
      "description": "Nested condition tree evaluated against contacts, their custom `data`, and their activity.",
      "properties": {
        "logic": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "groups": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "items": {
            "type": "object",
            "properties": {
              "filters": {
                "type": "array",
                "minItems": 1,
                "maxItems": 20,
                "items": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "type": "string",
                      "description": "`email`, `subscribed`, `locale`, `createdAt`, `data.<key>`, `event.<name>`, `email.opened`, …"
                    },
                    "operator": {
                      "type": "string",
                      "description": "`equals`, `notEquals`, `contains`, `notContains`, `greaterThan`, `lessThan`, `exists`, `notExists`, `within`, `notWithin`, `triggered`, `notTriggered`, …"
                    },
                    "value": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    },
                    "days": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 3650,
                      "description": "Time window (days) for activity operators."
                    }
                  },
                  "required": [
                    "field",
                    "operator"
                  ]
                }
              }
            },
            "required": [
              "filters"
            ]
          }
        }
      },
      "required": [
        "logic",
        "groups"
      ]
    }
  }
}