{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/samva-dev/json-schema/samva-dev-campaign-content-input-schema.json",
  "title": "CampaignContentInput",
  "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/CampaignContentInput",
  "type": "object",
  "properties": {
    "channel": {
      "type": "string",
      "enum": [
        "email"
      ]
    },
    "email": {
      "$ref": "#/$defs/CampaignEmailInput"
    },
    "issue": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "path": {
              "type": "string",
              "pattern": "^(?!.*\\\\)(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))(?!.*(?:^|\\/)\\.git(?:\\/|$))(?!.*\\p{Cc})issues\\/(?:[^/]+\\/)*[^/]+\\.md$",
              "maxLength": 1024,
              "x-samva-string-checks": [
                {
                  "id": "effect/schema/isMaxLength",
                  "payload": {
                    "maxLength": 1024
                  }
                }
              ]
            },
            "commit": {
              "type": "string",
              "pattern": "^[a-f0-9]{40}$"
            }
          },
          "required": [
            "path",
            "commit"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "Render a saved Markdown issue from the audience topic's repository. Its saved title and preheader supply the email content; templateData supplies recipient fallbacks."
    },
    "from": {
      "$ref": "#/$defs/CampaignFrom"
    },
    "replyMailboxId": {
      "$ref": "#/$defs/CampaignReplyMailbox"
    },
    "conversationId": {
      "$ref": "#/$defs/CampaignConversationRef"
    },
    "metadata": {
      "$ref": "#/$defs/CampaignContentMetadata"
    }
  },
  "required": [
    "channel",
    "email"
  ],
  "additionalProperties": false,
  "$defs": {
    "CampaignContentMetadata": {
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/JsonValue"
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "CampaignConversationRef": {
      "anyOf": [
        {
          "$ref": "#/$defs/ConversationId"
        },
        {
          "type": "null"
        },
        {
          "type": "null"
        }
      ]
    },
    "CampaignEmailInput": {
      "type": "object",
      "properties": {
        "subject": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "html": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "text": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "attachments": {
          "$ref": "#/$defs/EmailAttachments"
        },
        "publicationId": {
          "$ref": "#/$defs/TemplatePublicationId"
        },
        "inputContractId": {
          "$ref": "#/$defs/TemplateInputContractId"
        },
        "templateId": {
          "anyOf": [
            {
              "$ref": "#/$defs/TemplateId"
            },
            {
              "type": "null"
            }
          ]
        },
        "templateSlug": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^(?=.{1,100}$)[a-z0-9]+(?:-[a-z0-9]+)*$"
            },
            {
              "type": "null"
            }
          ]
        },
        "templateData": {
          "$ref": "#/$defs/TemplateData"
        },
        "locale": {
          "$ref": "#/$defs/RenderLocale"
        },
        "timeZone": {
          "$ref": "#/$defs/RenderTimeZone"
        },
        "inReplyToMessageId": {
          "anyOf": [
            {
              "$ref": "#/$defs/MessageId"
            },
            {
              "type": "null"
            }
          ]
        },
        "replyTo": {
          "$ref": "#/$defs/ReplyToAddresses"
        },
        "topicId": {
          "anyOf": [
            {
              "$ref": "#/$defs/TopicId"
            },
            {
              "type": "null"
            },
            {
              "type": "null"
            }
          ],
          "description": "The topic for this send. Omit to inherit the template topic; null disables topic inheritance for a direct send. Campaigns require a topic."
        },
        "tracking": {
          "$ref": "#/$defs/EmailTrackingOverrideV1"
        },
        "footer": {
          "$ref": "#/$defs/EmailFooterOverride"
        },
        "headers": {
          "anyOf": [
            {
              "$ref": "#/$defs/EmailCustomHeaders"
            },
            {
              "type": "null"
            }
          ]
        },
        "preheader": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "CampaignFrom": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "minLength": 1
            },
            "name": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "email"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "CampaignReplyMailbox": {
      "anyOf": [
        {
          "$ref": "#/$defs/MailboxId"
        },
        {
          "type": "null"
        },
        {
          "type": "null"
        }
      ],
      "description": "Omit to inherit the topic mailbox; null disables mailbox inheritance. An explicit email.replyTo overrides an inherited mailbox."
    },
    "ConversationId": {
      "type": "string",
      "pattern": "^conv_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "ConversationId"
    },
    "EmailAttachment": {
      "type": "object",
      "properties": {
        "filename": {
          "type": "string"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "mediaId": {
          "anyOf": [
            {
              "$ref": "#/$defs/MediaId"
            },
            {
              "type": "null"
            }
          ]
        },
        "contentType": {
          "type": "string"
        },
        "size": {
          "type": "integer",
          "maximum": 26214400,
          "exclusiveMinimum": 0
        }
      },
      "required": [
        "filename",
        "contentType",
        "size"
      ],
      "additionalProperties": false
    },
    "EmailAttachments": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EmailAttachment"
          },
          "maxItems": 10
        },
        {
          "type": "null"
        }
      ]
    },
    "EmailCustomHeaders": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "maxProperties": 11,
      "description": "Custom headers copied onto the outgoing message. Each name is an RFC 5322 field name and each value is one non-empty line of printable ASCII. Names Samva or the transport own are rejected."
    },
    "EmailFooterOverride": {
      "type": "object",
      "properties": {
        "enabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "EmailTrackingOverrideV1": {
      "type": "object",
      "properties": {
        "opens": {
          "type": "boolean",
          "description": "Override open tracking for this send. Omit to inherit the organization default. A recipient tracking opt-out always disables tracking."
        },
        "clicks": {
          "type": "boolean",
          "description": "Override click tracking for this send. Omit to inherit the organization default. A recipient tracking opt-out always disables tracking."
        }
      },
      "additionalProperties": false,
      "description": "Requested per-send engagement tracking policy. Recipient opt-out takes precedence, then explicit fields, organization defaults, and product defaults."
    },
    "JsonObject": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      }
    },
    "JsonValue": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/JsonValue"
          }
        },
        {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/JsonValue"
          }
        }
      ]
    },
    "MailboxId": {
      "type": "string",
      "pattern": "^mbx_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "MailboxId"
    },
    "MediaId": {
      "type": "string",
      "pattern": "^media_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "MediaId"
    },
    "MessageId": {
      "type": "string",
      "pattern": "^msg_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "MessageId"
    },
    "RenderLocale": {
      "type": "string",
      "maxLength": 64,
      "x-samva-string-checks": [
        {
          "id": "effect/schema/isMaxLength",
          "payload": {
            "maxLength": 64
          }
        }
      ]
    },
    "RenderTimeZone": {
      "type": "string",
      "maxLength": 64,
      "x-samva-string-checks": [
        {
          "id": "effect/schema/isMaxLength",
          "payload": {
            "maxLength": 64
          }
        }
      ]
    },
    "ReplyToAddresses": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "null"
        },
        {
          "type": "null"
        }
      ]
    },
    "TemplateData": {
      "anyOf": [
        {
          "$ref": "#/$defs/JsonObject"
        },
        {
          "type": "null"
        }
      ]
    },
    "TemplateId": {
      "type": "string",
      "pattern": "^tmpl_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "TemplateId"
    },
    "TemplateInputContractId": {
      "type": "string",
      "pattern": "^tcon_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "TemplateInputContractId"
    },
    "TemplatePublicationId": {
      "type": "string",
      "pattern": "^tpub_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "TemplatePublicationId"
    },
    "TopicId": {
      "type": "string",
      "pattern": "^unsub_[0-9a-hjkmnp-tv-z]{16,24}$",
      "x-samva-brand": "TopicId"
    }
  }
}