{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/coverwhaleinsurancesolutions/json-schema/coverwhaleinsurancesolutions-cancellation-notice-decision-schema.json",
  "title": "CancellationNoticeDecision",
  "description": "Persisted notice-rule decision or request history; otherwise an advisory preview. Properties vary by phase and hold. Actual persisted dates are the top-level response fields.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/coverwhaleinsurancesolutions-openapi.json#/components/schemas/CancellationNoticeDecision",
  "type": "object",
  "properties": {
    "phase": {
      "type": "string",
      "enum": [
        "request",
        "approval",
        "coverage"
      ],
      "description": "Stage evaluated. A saved request decision can remain in the response if approval enforcement is disabled."
    },
    "state": {
      "type": [
        "string",
        "null"
      ],
      "description": "Policy state used to resolve the notice rule."
    },
    "reason": {
      "type": "string",
      "description": "Normalized comma-separated external reason codes used for this evaluation."
    },
    "notice_minimum_required": {
      "type": "boolean",
      "description": "Whether this evaluation requires a statutory notice minimum. False only for a whole-policy reason set containing only insured_broker_request; applicable date/term validation and legacy courtesy/carrier document, email and filing work still apply. Partial NOC generation always requires the minimum."
    },
    "ground": {
      "type": "string",
      "enum": [
        "non_payment",
        "uw",
        "unknown"
      ],
      "description": "Resolved cancellation ground. Unknown reasons can use a conservative underwriting proposal."
    },
    "floor_days": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Minimum notice days, or null when no statutory notice minimum is required or a required rule is unresolved. Inspect notice_minimum_required and held."
    },
    "days_in_force": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Policy age on the evaluation day."
    },
    "minimum_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "Proposed notice minimum from the evaluation day; null when no statutory notice minimum is required or the rule is unresolved. Not the actual stored date."
    },
    "held": {
      "type": "boolean",
      "description": "Evaluation requires manual review. In advisory metadata on a successful legacy response this is a proposal; HTTP 422 identifies an actual refusal."
    },
    "hold_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Manual-review explanation when available."
    },
    "changes": {
      "$ref": "#/$defs/CancellationNoticeChanges"
    },
    "date_measurements": {
      "type": "object",
      "description": "Signed requested notice-day measurements by date field.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "requested_days": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Requested days from the evaluation day."
          },
          "floor_days": {
            "type": [
              "integer",
              "null"
            ]
          },
          "delta_days": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Requested days minus the floor; negative values indicate a shortfall."
          }
        }
      }
    },
    "current_dates": {
      "type": "object",
      "description": "Dates evaluated before proposed changes; use the response root for actual persisted dates.",
      "properties": {
        "effective_date_transaction": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "effective_date_transaction_al": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "effective_date_transaction_wc": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        }
      }
    },
    "enabled": {
      "type": "boolean",
      "description": "Enforcement enabled for this evaluation; inspect phase rather than treating it as the current state of all rollout controls."
    },
    "historical_exempt": {
      "type": "boolean",
      "description": "Attributable authorized historical correction preserves its dates; this is not an API opt-out."
    },
    "evaluated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp present for a persisted decision."
    },
    "stored_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Reason stored before approval, when an approval decision was recorded."
    },
    "approved_reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Reason approved, when an approval decision was recorded."
    },
    "historical_actor_id": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Authorized correction actor, when recorded."
    },
    "historical_source": {
      "type": [
        "string",
        "null"
      ],
      "description": "Authorized correction source, when recorded."
    },
    "historical_justification": {
      "type": [
        "string",
        "null"
      ],
      "description": "Attributable correction justification, when recorded."
    },
    "preview_stale": {
      "type": "boolean",
      "description": "Present when confirmed web preview values changed before approval."
    },
    "effective_date_transaction": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "Proposed or evaluated date for this phase. The top-level response date is the actual persisted value."
    },
    "effective_date_transaction_al": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "Proposed or evaluated date for this phase. The top-level response date is the actual persisted value."
    },
    "effective_date_transaction_wc": {
      "type": [
        "string",
        "null"
      ],
      "format": "date",
      "description": "Proposed or evaluated date for this phase. The top-level response date is the actual persisted value."
    },
    "date_role": {
      "type": "string",
      "enum": [
        "proposal",
        "applied",
        "persisted"
      ],
      "description": "Meaning of this evaluation: advisory proposal, applied decision, or retained persisted record. Read phase and the top-level actual response dates."
    },
    "wc_action": {
      "type": "string",
      "enum": [
        "cancel",
        "retain",
        "not_applicable"
      ],
      "description": "WC applicability for this cancellation decision. A null WC response date does not by itself prove absence of WC coverage."
    },
    "persisted_dates": {
      "type": "object",
      "description": "Stored date values captured with the recorded decision. Use top-level response dates for the current actual persisted values.",
      "properties": {
        "effective_date_transaction": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "effective_date_transaction_al": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "effective_date_transaction_wc": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        }
      }
    },
    "request_decision": {
      "type": "object",
      "description": "Earlier recorded request-phase decision retained when approval records its own evaluation; includes its original rule and date provenance.",
      "properties": {
        "changes": {
          "$ref": "#/$defs/CancellationNoticeChanges"
        },
        "notice_minimum_required": {
          "type": "boolean",
          "description": "Whether this evaluation requires a statutory notice minimum. False only for a whole-policy reason set containing only insured_broker_request; applicable date/term validation and legacy courtesy/carrier document, email and filing work still apply. Partial NOC generation always requires the minimum."
        }
      },
      "additionalProperties": true
    }
  },
  "$defs": {
    "CancellationNoticeChanges": {
      "description": "Proposed or applied date changes by cancellation date field; no requested date is shortened. An empty array means no dates were adjusted, including historical exemptions. This shape also applies to a retained request_decision.",
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "from": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              }
            }
          }
        },
        {
          "type": "array",
          "maxItems": 0
        }
      ]
    }
  }
}