{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/softsync-ai/json-schema/softsync-ai-send-email-campaign-dto-schema.json",
  "title": "SendEmailCampaignDto",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/softsync-ai-email-api-openapi.yml#/components/schemas/SendEmailCampaignDto",
  "type": "object",
  "properties": {
    "templateId": {
      "type": "string",
      "description": "Template sent to every recipient."
    },
    "recordIds": {
      "description": "Records to send to, e.g. contacts. Each one receives its own copy with placeholders filled from that record.",
      "maxItems": 1000,
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "integrationId": {
      "type": "string",
      "description": "Mailbox to send from. Defaults to the caller’s first connected mailbox."
    },
    "displayName": {
      "type": "string",
      "description": "Name for this campaign in the app’s activity views. Defaults to the template title."
    },
    "sendWindow": {
      "description": "Restrict delivery to certain hours and days. Messages outside the window wait until it reopens.",
      "allOf": [
        {
          "$ref": "#/$defs/EmailSendWindowDto"
        }
      ]
    },
    "unsubscribeLink": {
      "type": "boolean",
      "description": "End each email with an unsubscribe link (good for newsletters). A recipient who clicks it is marked as opted out (`email_opt_out`) and gets no further campaign emails. Off by default."
    }
  },
  "required": [
    "templateId",
    "recordIds"
  ],
  "$defs": {
    "EmailSendWindowDto": {
      "type": "object",
      "properties": {
        "timezone": {
          "type": "string",
          "description": "IANA timezone the window is expressed in."
        },
        "startTime": {
          "type": "string",
          "description": "Earliest local send time, 24-hour `HH:MM`."
        },
        "endTime": {
          "type": "string",
          "description": "Latest local send time, 24-hour `HH:MM`."
        },
        "weekdays": {
          "description": "Days the window applies to, 0 = Sunday through 6 = Saturday. Defaults to every day.",
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "required": [
        "timezone",
        "startTime",
        "endTime"
      ]
    }
  }
}