{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/certifyos/main/json-schema/certifyos-event-email-settings-context-response-schema.json",
  "title": "EventEmailSettingsContextResponse",
  "description": "Event email settings for one context (practitioner or facility), covering both the context-level fields (ccEmail, logoUrl, logoWidth, mmoOutcomeFilter) and both modes' settings. Returned by the context-level update endpoints (cc-email, logo-url, logo-settings, recipient-preferences, mmo-outcome-filter).",
  "x-generated": "2026-10-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/certifyos-event-email-settings-api-openapi.yml#/components/schemas/EventEmailSettingsContextResponse",
  "type": "object",
  "properties": {
    "ccEmail": {
      "type": "string",
      "description": "Resolved CC email for this context: the context-level value if set, otherwise falling back to the credentialing mode's value, then the recredentialing mode's value. Null if none is set."
    },
    "logoUrl": {
      "type": "string",
      "description": "Resolved logo image URL for this context, using the same context-then-credentialing-then-recredentialing fallback as ccEmail. Null if none is set."
    },
    "logoWidth": {
      "type": "string",
      "description": "Resolved logo display width for this context, using the same fallback as ccEmail/logoUrl, as a percentage string (e.g. \"50%\"); no format is enforced server-side. Null if none is set."
    },
    "credentialing": {
      "$ref": "#/$defs/EventEmailSettingsModeResponse",
      "type": "object",
      "description": "Credentialing-mode settings for this context, or null if never configured."
    },
    "recredentialing": {
      "$ref": "#/$defs/EventEmailSettingsModeResponse",
      "type": "object",
      "description": "Recredentialing-mode settings for this context, or null if never configured."
    },
    "mmoOutcomeFilter": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Primary MMO (Managed Medical Outcomes) result types to send emails for. Allowed values: \"Positive\" (approved plan outcomes), \"Negative\" (denied plan outcomes). When the workflow has both approved and denied plan UDFs for the same event, the complementary outcome email is still sent regardless of this filter (e.g. filter [\"Positive\"] still sends the denied-plans email if present, and vice versa) — this filter narrows the primary outcome, it does not suppress the paired one. Null or empty = no restriction (both sent)."
    }
  },
  "$defs": {
    "EventEmailRecipientPreferencesDto": {
      "type": "object",
      "description": "Boolean flags controlling which recipient types receive event emails for a context.",
      "properties": {
        "primaryEmail": {
          "type": "boolean",
          "description": "true to send event emails to the practitioner's or facility's primary email on file; false or null to skip this recipient."
        },
        "caqhPrimaryEmail": {
          "type": "boolean",
          "description": "true to send event emails to the CAQH-sourced primary email on file; false or null to skip this recipient."
        },
        "credentialingPrimaryContact": {
          "type": "boolean",
          "description": "true to send event emails to the credentialing workflow's primary contact; false or null to skip this recipient."
        },
        "credentialingOfficeManager": {
          "type": "boolean",
          "description": "true to send event emails to the office manager on the credentialing workflow; false or null to skip this recipient."
        }
      }
    },
    "EventEmailSettingsModeResponse": {
      "type": "object",
      "required": [
        "recipientPreferences",
        "typeSettings"
      ],
      "description": "One mode's (credentialing or recredentialing) event email settings, nested inside EventEmailSettingsContextResponse. Does not repeat the context-level ccEmail/logoUrl/logoWidth fields, which live on the parent context object.",
      "properties": {
        "recipientPreferences": {
          "$ref": "#/$defs/EventEmailRecipientPreferencesDto",
          "type": "object",
          "description": "Resolved recipient preference flags for the parent context (context-level value if set, otherwise this mode's own stored value)."
        },
        "typeSettings": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EventEmailTypeSettingsDto"
          },
          "description": "One entry per configured event email type for this mode (initiated, approved, denied, cancelled, psvReady, inProgress)."
        }
      }
    },
    "EventEmailTemplateDto": {
      "type": "object",
      "required": [
        "subject",
        "bodyHtml"
      ],
      "description": "Subject and body content for one event email type's template.",
      "properties": {
        "subject": {
          "type": "string",
          "description": "Email subject line. Required and must be non-blank when the parent typeSettings entry has enabled: true."
        },
        "bodyHtml": {
          "type": "string",
          "description": "Email body as HTML markup. Required and must be non-blank when the parent typeSettings entry has enabled: true."
        }
      }
    },
    "EventEmailTypeSettingsDto": {
      "type": "object",
      "required": [
        "type",
        "template",
        "enabled"
      ],
      "description": "Template and enablement settings for one event email type within a mode.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "initiated",
            "approved",
            "denied",
            "cancelled",
            "psvReady",
            "inProgress"
          ],
          "pattern": "\\S",
          "description": "Which workflow event this entry configures: \"initiated\" (workflow started), \"approved\" (credentialing/recredentialing approved), \"denied\" (application denied), \"cancelled\" (workflow cancelled), \"psvReady\" (primary source verification complete), \"inProgress\" (workflow in progress)."
        },
        "template": {
          "$ref": "#/$defs/EventEmailTemplateDto",
          "type": "object",
          "description": "Email subject/body template for this event type. Required (non-blank subject and bodyHtml) when enabled is true; the server rejects the save with 400 otherwise."
        },
        "enabled": {
          "type": "boolean",
          "description": "Whether an email is sent for this event type. When true, template.subject and template.bodyHtml must be non-blank."
        }
      }
    }
  }
}