{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/politicalcomms-com/json-schema/politicalcomms-com-email-template-schema.json",
  "title": "EmailTemplate",
  "description": "A reusable email design in the organization's template library.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/politicalcomms-com-email-templates-api-openapi.yml#/components/schemas/EmailTemplate",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "name": {
      "type": "string",
      "maxLength": 255
    },
    "description": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 2000
    },
    "content": {
      "$ref": "#/$defs/EmailTemplateContent"
    },
    "thumbnail_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "Preview image rendered by a background job. Null until it has run."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "name",
    "content"
  ],
  "additionalProperties": true,
  "$defs": {
    "EmailTemplateContent": {
      "type": "object",
      "properties": {
        "subject": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 900
        },
        "preheader": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 255
        },
        "html": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 2097152
        },
        "text": {
          "type": [
            "string",
            "null"
          ],
          "description": "Plain-text alternative. Generated from the HTML when omitted.",
          "maxLength": 512000
        },
        "editor": {
          "type": "string",
          "enum": [
            "html",
            "document"
          ],
          "description": "`html` for a template imported or hand-written as HTML; `document` for one built in the dashboard's document editor. Both are returned as rendered HTML here. This surface only accepts HTML content on create. Updating the `content` of a `document` template returns `409 CONFLICT` with `details.reason` set to `TEMPLATE_IS_DOCUMENT`: edit it in the dashboard, or convert it to an HTML template first."
        }
      },
      "description": "The renderable body of a template.",
      "additionalProperties": true
    }
  }
}