{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/Endorsement",
  "definitions": {
    "Endorsement": {
      "type": "object",
      "properties": {
        "endorsementNumber": {
          "type": "string",
          "description": "Endorsement number or identifier"
        },
        "type": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "Type of endorsement."
        },
        "effectiveDate": {
          "type": "string",
          "description": "Date the endorsement becomes effective.",
          "format": "date"
        },
        "description": {
          "type": "string",
          "description": "Description of what the endorsement changes"
        },
        "premiumChange": {
          "$ref": "#/definitions/Money",
          "description": "Total premium change resulting from this endorsement (positive = additional, negative = return)"
        },
        "changes": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/EndorsementChange"
          },
          "description": "Atomic changes made by this endorsement, broken down by coverage"
        },
        "document": {
          "$ref": "#/definitions/Attachment",
          "description": "Reference to the endorsement document/form"
        }
      },
      "required": [
        "type",
        "effectiveDate"
      ],
      "additionalProperties": false,
      "description": "An endorsement (amendment) to an insurance policy. Endorsements modify the terms, coverages, or conditions of the base policy.",
      "examples": [
        {
          "endorsementNumber": "END-002",
          "type": {
            "text": "Mid-Term Modification"
          },
          "effectiveDate": "2025-09-01",
          "description": "Increase GL limits and add Hired & Non-Owned Auto",
          "premiumChange": {
            "value": 3200,
            "currency": "USD"
          },
          "changes": [
            {
              "coverage": {
                "reference": "Coverage/cov-gl-001",
                "display": "General Liability"
              },
              "action": "modify",
              "limits": [
                {
                  "type": {
                    "text": "Each Occurrence"
                  },
                  "amount": {
                    "value": 2000000,
                    "currency": "USD"
                  }
                }
              ],
              "premiumChange": {
                "value": 2500,
                "currency": "USD"
              },
              "description": "Increase each-occurrence limit from $1M to $2M"
            },
            {
              "coverage": {
                "reference": "Coverage/cov-gl-001",
                "display": "General Liability"
              },
              "action": "modify",
              "coverageExtensions": [
                {
                  "type": {
                    "text": "Hired & Non-Owned Auto"
                  },
                  "included": true,
                  "sublimit": {
                    "value": 1000000,
                    "currency": "USD"
                  },
                  "additionalPremium": {
                    "value": 700,
                    "currency": "USD"
                  }
                }
              ],
              "premiumChange": {
                "value": 700,
                "currency": "USD"
              },
              "description": "Add Hired & Non-Owned Auto extension"
            }
          ]
        }
      ]
    },
    "CodeableConcept": {
      "type": "object",
      "properties": {
        "coding": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Coding"
          },
          "description": "Code(s) from formal code systems"
        },
        "text": {
          "type": "string",
          "description": "Plain text representation of the concept"
        }
      },
      "additionalProperties": false,
      "description": "A concept with a coding and optional text. Wraps one or more Coding values with a human-readable summary."
    },
    "Coding": {
      "type": "object",
      "properties": {
        "system": {
          "type": "string",
          "description": "The code system URI that defines the code.",
          "format": "uri"
        },
        "code": {
          "type": "string",
          "description": "The code value from the code system"
        },
        "display": {
          "type": "string",
          "description": "Human-readable display text for the code"
        }
      },
      "required": [
        "code"
      ],
      "additionalProperties": false,
      "description": "A coded value from a defined code system. Used throughout BIND for standardized enumerations.",
      "examples": [
        {
          "system": "https://bind.codes/line-of-business",
          "code": "GL",
          "display": "General Liability"
        }
      ]
    },
    "Money": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "description": "Numeric amount. Represented as a number; precision should be maintained by the consuming system."
        },
        "currency": {
          "type": "string",
          "description": "ISO 4217 currency code.",
          "default": "USD"
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "description": "A monetary amount with currency.",
      "examples": [
        {
          "value": 1000000,
          "currency": "USD"
        }
      ]
    },
    "EndorsementChange": {
      "type": "object",
      "properties": {
        "coverage": {
          "$ref": "#/definitions/Reference",
          "description": "Reference to the coverage being changed"
        },
        "action": {
          "type": "string",
          "enum": [
            "add",
            "modify",
            "remove"
          ],
          "description": "The action being performed on the coverage.\n\n- `add` — A new coverage is being added to the policy\n- `modify` — An existing coverage is being changed\n- `remove` — A coverage is being removed from the policy"
        },
        "limits": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CoverageLimit"
          },
          "description": "Modified or new coverage limits (values after the endorsement takes effect)"
        },
        "deductible": {
          "$ref": "#/definitions/Deductible",
          "description": "Modified or new deductible"
        },
        "coverageExtensions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CoverageExtension"
          },
          "description": "Modified, added, or removed coverage extensions"
        },
        "classifications": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Classification"
          },
          "description": "Modified classifications"
        },
        "premiumChange": {
          "$ref": "#/definitions/Money",
          "description": "Premium change attributable to this specific coverage change"
        },
        "description": {
          "type": "string",
          "description": "Human-readable description of this specific change"
        }
      },
      "required": [
        "coverage",
        "action"
      ],
      "additionalProperties": false,
      "description": "An atomic change within an endorsement, scoped to a single coverage. Captures what was modified, added, or removed, along with the premium impact attributable to this specific change.",
      "examples": [
        {
          "coverage": {
            "reference": "Coverage/cov-gl-001",
            "display": "General Liability"
          },
          "action": "modify",
          "limits": [
            {
              "type": {
                "text": "Each Occurrence"
              },
              "amount": {
                "value": 2000000,
                "currency": "USD"
              }
            }
          ],
          "premiumChange": {
            "value": 2500,
            "currency": "USD"
          },
          "description": "Increase each-occurrence limit from $1M to $2M"
        }
      ]
    },
    "Reference": {
      "type": "object",
      "properties": {
        "reference": {
          "type": "string",
          "description": "Relative or absolute reference to another resource. Format: `{ResourceType}/{id}` for relative references."
        },
        "type": {
          "type": "string",
          "description": "The resource type being referenced"
        },
        "display": {
          "type": "string",
          "description": "Text alternative for the reference (e.g. display name)"
        }
      },
      "additionalProperties": false,
      "description": "A reference from one BIND resource to another.",
      "examples": [
        {
          "reference": "Insured/ins-789",
          "display": "Acme Corp"
        }
      ]
    },
    "CoverageLimit": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "The type of limit (Each Occurrence, Aggregate, Per Person, etc.)"
        },
        "amount": {
          "$ref": "#/definitions/Money",
          "description": "The limit amount (either amount or splitAmounts should be present)"
        },
        "splitAmounts": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SplitLimitComponent"
          },
          "description": "Split limit components (e.g., auto liability 100/300/100)"
        },
        "shared": {
          "type": "boolean",
          "description": "Whether this limit is shared across multiple coverages"
        },
        "basisType": {
          "type": "string",
          "description": "Basis type for the limit (e.g., \"per occurrence\", \"per location\", \"per project\")"
        },
        "isSublimit": {
          "type": "boolean",
          "description": "Whether this is a sublimit of a broader coverage limit"
        },
        "parentLimit": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "The parent limit this sublimit falls under"
        },
        "attachmentPoint": {
          "$ref": "#/definitions/Money",
          "description": "Attachment point for excess/umbrella layers"
        },
        "eroded": {
          "$ref": "#/definitions/Money",
          "description": "Amount of the limit that has been eroded by losses"
        },
        "remaining": {
          "$ref": "#/definitions/Money",
          "description": "Remaining limit after erosion"
        },
        "reinstatements": {
          "type": "number",
          "description": "Number of times the limit can be reinstated after a loss"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "description": "A specific limit of insurance within a coverage. Commercial policies typically have multiple limit types (e.g., per-occurrence, aggregate, per-person).",
      "examples": [
        {
          "type": {
            "text": "Each Occurrence"
          },
          "amount": {
            "value": 1000000,
            "currency": "USD"
          }
        }
      ]
    },
    "SplitLimitComponent": {
      "type": "object",
      "properties": {
        "category": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "The category of this split limit component (e.g., Per Person BI, Per Accident BI, PD)."
        },
        "amount": {
          "$ref": "#/definitions/Money",
          "description": "The limit amount for this component"
        }
      },
      "required": [
        "category",
        "amount"
      ],
      "additionalProperties": false,
      "description": "A component of a split limit structure. Used when a coverage has separate limits for different categories (e.g., auto liability split limits: 100/300/100)."
    },
    "Deductible": {
      "type": "object",
      "properties": {
        "amount": {
          "$ref": "#/definitions/Money",
          "description": "The deductible amount (required for fixed-amount deductibles, optional for percentage-based)"
        },
        "type": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "How the deductible applies."
        },
        "application": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "How loss adjustment expenses (ALAE/LAE) interact with the deductible."
        },
        "isSIR": {
          "type": "boolean",
          "description": "Whether this is a Self-Insured Retention (SIR) rather than a traditional deductible. SIRs require the insured to handle claims within the retention before the carrier responds."
        },
        "aggregateAmount": {
          "$ref": "#/definitions/Money",
          "description": "Aggregate cap on deductible obligations in a policy period"
        },
        "corridorPercentage": {
          "type": "number",
          "description": "Corridor percentage (used in corridor deductible structures). Expressed as a percentage of the loss amount."
        },
        "franchiseAmount": {
          "$ref": "#/definitions/Money",
          "description": "Franchise deductible threshold — losses below this are fully retained; above, fully covered"
        },
        "disappearingThreshold": {
          "$ref": "#/definitions/Money",
          "description": "Disappearing deductible threshold — deductible phases out above this loss amount"
        },
        "percentage": {
          "type": "number",
          "description": "Percentage-based deductible (e.g., 2% hurricane deductible).",
          "minimum": 0,
          "maximum": 100
        },
        "percentageBasis": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "What the percentage is applied to (e.g., \"Coverage A dwelling value\", \"total insured value\")"
        },
        "description": {
          "type": "string",
          "description": "Free-text description of deductible terms"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "description": "A structured deductible definition for a coverage section. Replaces the inline `Money` deductible and separate `deductibleType` fields, capturing the full complexity of insurance deductible structures including SIRs, corridors, franchises, and disappearing deductibles.",
      "examples": [
        {
          "amount": {
            "value": 25000,
            "currency": "USD"
          },
          "type": "per-occurrence",
          "application": "loss-only",
          "isSIR": false,
          "aggregateAmount": {
            "value": 100000,
            "currency": "USD"
          }
        }
      ]
    },
    "CoverageExtension": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "Name or type of the extension."
        },
        "included": {
          "type": "boolean",
          "description": "Whether this extension is included or excluded"
        },
        "sublimit": {
          "$ref": "#/definitions/Money",
          "description": "Sublimit for this extension, if applicable"
        },
        "additionalPremium": {
          "$ref": "#/definitions/Money",
          "description": "Additional premium for this extension"
        },
        "description": {
          "type": "string",
          "description": "Description or notes about this extension"
        }
      },
      "required": [
        "type",
        "included"
      ],
      "additionalProperties": false,
      "description": "An additional coverage feature, extension, or sublimit. Examples: Hired & Non-Owned Auto, Employee Benefits Liability, Blanket Additional Insured."
    },
    "Classification": {
      "type": "object",
      "properties": {
        "classCode": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "The classification or class code"
        },
        "exposure": {
          "$ref": "#/definitions/Quantity",
          "description": "Exposure measure for this classification"
        },
        "rate": {
          "type": "number",
          "description": "Rate applied to this classification"
        },
        "premium": {
          "$ref": "#/definitions/Money",
          "description": "Premium for this classification"
        },
        "location": {
          "$ref": "#/definitions/Reference",
          "description": "Location reference, if class is location-specific"
        },
        "description": {
          "type": "string",
          "description": "Description of operations at this classification"
        }
      },
      "required": [
        "classCode"
      ],
      "additionalProperties": false,
      "description": "A classification or class code within a coverage. Used to categorize exposure units, particularly in GL and WC.",
      "examples": [
        {
          "classCode": {
            "code": "91580",
            "display": "Machine Shop NOC"
          },
          "exposure": {
            "value": 1500000,
            "unit": "payroll"
          },
          "rate": 2.45,
          "premium": {
            "value": 36750,
            "currency": "USD"
          }
        }
      ]
    },
    "Quantity": {
      "type": "object",
      "properties": {
        "value": {
          "type": "number",
          "description": "Numeric value"
        },
        "unit": {
          "type": "string",
          "description": "Unit of measure (e.g. \"sqft\", \"vehicles\", \"employees\")"
        },
        "system": {
          "type": "string",
          "description": "Code system URI for the unit.",
          "format": "uri"
        },
        "code": {
          "type": "string",
          "description": "Coded form of the unit"
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "description": "A quantity with a value and unit.",
      "examples": [
        {
          "value": 50000,
          "unit": "sqft"
        }
      ]
    },
    "Attachment": {
      "type": "object",
      "properties": {
        "contentType": {
          "type": "string",
          "description": "MIME type of the content.",
          "examples": [
            "application/pdf"
          ]
        },
        "url": {
          "type": "string",
          "description": "URI where the attachment data can be retrieved.",
          "format": "uri"
        },
        "title": {
          "type": "string",
          "description": "Human-readable title for the attachment"
        },
        "creation": {
          "type": "string",
          "description": "Date the attachment was created.",
          "format": "date-time"
        }
      },
      "additionalProperties": false,
      "description": "An attachment or document reference. Used for loss runs, applications, endorsement forms, etc."
    }
  },
  "$id": "https://bind-standard.org/schema/Endorsement",
  "title": "Endorsement"
}
