{
  "openapi": "3.1.0",
  "info": {
    "title": "lossruns.claims: the loss run as typed data",
    "version": "1.0.0",
    "description": "The loss run is the carrier-issued claims history on a policy: carrier, policy, term, valuation date, and every claim with paid, reserve and incurred. A free typed schema, checks and an MCP server for agents. The schema, example, validation and MCP tools are keyless; parsing documents needs an access key (request one at https://lossruns.claims/#access)."
  },
  "servers": [
    {
      "url": "https://lossruns.claims"
    }
  ],
  "paths": {
    "/schema.json": {
      "get": {
        "operationId": "getLossRunSchema",
        "summary": "The LossRun JSON Schema (2020-12)",
        "responses": {
          "200": {
            "description": "The JSON Schema.",
            "content": {
              "application/schema+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/example.json": {
      "get": {
        "operationId": "getLossRunExample",
        "summary": "A complete, valid LossRun with fictional values",
        "responses": {
          "200": {
            "description": "An example LossRun.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LossRun"
                }
              }
            }
          }
        }
      }
    },
    "/validate": {
      "post": {
        "operationId": "validateLossRun",
        "summary": "Check a LossRun against the schema and the document's own checks",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LossRun"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The result. Nothing is stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationResult"
                }
              }
            }
          },
          "400": {
            "description": "The body is not JSON."
          }
        }
      }
    },
    "/parse": {
      "post": {
        "operationId": "parseLossRun",
        "summary": "Parse a document into a LossRun",
        "security": [
          {
            "accessKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "document"
                ],
                "properties": {
                  "document": {
                    "type": "string",
                    "format": "binary",
                    "description": "The document: PDF, image or a native data file."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The typed LossRun.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LossRun"
                }
              }
            }
          },
          "401": {
            "description": "An access key is required. Request one at the request_access URL in the body."
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcp",
        "summary": "MCP server (Streamable HTTP, JSON-RPC 2.0). Keyless, read-only tools.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response."
          },
          "202": {
            "description": "Notification accepted."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LossRun": {
        "type": "object",
        "description": "A carrier-issued claims-history report on a policy, valued as of valuation_date. A point-in-time snapshot: open claims can move after it.",
        "required": [
          "carrier",
          "insured",
          "policy_number",
          "term_start",
          "term_end",
          "valuation_date",
          "claims",
          "totals"
        ],
        "properties": {
          "carrier": {
            "type": "string",
            "description": "Issuing carrier. Authoritative only from the carrier that held the policy."
          },
          "insured": {
            "type": "string",
            "description": "Named insured on the policy."
          },
          "policy_number": {
            "type": "string",
            "description": "The policy the history covers."
          },
          "line_of_business": {
            "type": "string",
            "description": "The line it covers, e.g. commercial_property."
          },
          "term_start": {
            "type": "string",
            "format": "date"
          },
          "term_end": {
            "type": "string",
            "format": "date"
          },
          "valuation_date": {
            "type": "string",
            "format": "date",
            "description": "The date every figure is true as of."
          },
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LossRunClaim"
            }
          },
          "totals": {
            "$ref": "#/components/schemas/LossRunTotals"
          }
        }
      },
      "LossRunClaim": {
        "type": "object",
        "required": [
          "claim_number",
          "date_of_loss",
          "status",
          "paid",
          "reserve",
          "incurred"
        ],
        "properties": {
          "claim_number": {
            "type": "string",
            "description": "The carrier's claim identifier."
          },
          "date_of_loss": {
            "type": "string",
            "format": "date",
            "description": "Occurrence date, not report date."
          },
          "cause_of_loss": {
            "type": "string",
            "description": "Peril or cause code, e.g. wind_hail, water_damage, theft."
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "closed"
            ],
            "description": "Open means paid, reserve and incurred can still move. Closed with paid = 0 means closed without payment."
          },
          "paid": {
            "type": "number",
            "minimum": 0,
            "description": "USD actually issued to date on the claim."
          },
          "reserve": {
            "type": "number",
            "minimum": 0,
            "description": "The carrier's booked estimate of what remains to pay. Carrier accounting, not a promise."
          },
          "incurred": {
            "type": "number",
            "minimum": 0,
            "description": "paid + reserve. The figure underwriting prices on."
          },
          "coverage": {
            "type": "string",
            "description": "Coverage part the figures fall under, when the carrier splits them."
          }
        }
      },
      "LossRunTotals": {
        "type": "object",
        "required": [
          "paid",
          "reserve",
          "incurred",
          "claim_count",
          "open_count"
        ],
        "properties": {
          "paid": {
            "type": "number"
          },
          "reserve": {
            "type": "number"
          },
          "incurred": {
            "type": "number"
          },
          "claim_count": {
            "type": "integer"
          },
          "open_count": {
            "type": "integer"
          }
        }
      },
      "Issue": {
        "type": "object",
        "required": [
          "path",
          "message"
        ],
        "properties": {
          "path": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ValidationResult": {
        "type": "object",
        "required": [
          "valid",
          "consistent",
          "errors",
          "warnings"
        ],
        "properties": {
          "valid": {
            "type": "boolean",
            "description": "The record matches the schema."
          },
          "consistent": {
            "type": "boolean",
            "description": "It also passes every check: sums, dates, codes."
          },
          "schema": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Issue"
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Issue"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "accessKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An access key issued on request at https://lossruns.claims/#access."
      }
    }
  }
}