{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/Bundle",
  "definitions": {
    "Bundle": {
      "type": "object",
      "properties": {
        "resourceType": {
          "type": "string",
          "const": "Bundle",
          "description": "Fixed resource type discriminator"
        },
        "id": {
          "type": "string",
          "description": "Logical id of this resource. Assigned by the server or originating system."
        },
        "meta": {
          "$ref": "#/definitions/Meta",
          "description": "Metadata about the resource"
        },
        "identifier": {
          "$ref": "#/definitions/Identifier",
          "description": "A persistent identifier for the bundle that won't change as it is copied from server to server."
        },
        "type": {
          "type": "string",
          "enum": [
            "document",
            "message",
            "transaction",
            "transaction-response",
            "batch",
            "batch-response",
            "searchset",
            "history",
            "collection"
          ],
          "description": "The purpose of this bundle.\n\n- `document` — A complete, self-contained document (e.g., submission package, policy snapshot)\n- `message` — A message exchanged between systems\n- `transaction` — A set of operations to be processed atomically\n- `transaction-response` — Response to a transaction bundle\n- `batch` — A set of independent operations\n- `batch-response` — Response to a batch bundle\n- `searchset` — Results of a search query\n- `history` — Version history of one or more resources\n- `collection` — An arbitrary collection of resources"
        },
        "timestamp": {
          "type": "string",
          "description": "When the bundle was assembled.",
          "format": "date-time"
        },
        "total": {
          "type": "number",
          "description": "Total number of matching resources (only for searchset and history bundles). May be larger than the number of entries if results are paginated.",
          "minimum": 0
        },
        "link": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/BundleLink"
          },
          "description": "Links related to this bundle (e.g., pagination: self, next, previous)"
        },
        "entry": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/BundleEntry"
          },
          "description": "The individual resources and associated metadata in this bundle"
        }
      },
      "required": [
        "resourceType",
        "type"
      ],
      "additionalProperties": false,
      "description": "A Bundle is a container for a collection of BIND resources. It enables systems to exchange groups of related resources in a single payload — for example, a complete submission package, a policy with all its coverages and risks, or a batch of updates.\n\nBundle types serve different purposes:\n- **document**: A coherent set of resources treated as a document (e.g., a full submission package).\n- **message**: A message between systems, where the first entry defines the message intent.\n- **transaction**: A set of resources to be processed as a single atomic operation.\n- **transaction-response**: The server's response to a transaction bundle.\n- **batch**: A set of independent operations to be processed individually.\n- **batch-response**: The server's response to a batch bundle.\n- **searchset**: Results of a search operation.\n- **history**: Version history of a resource.\n- **collection**: A generic collection of resources with no particular processing semantics.",
      "examples": [
        {
          "resourceType": "Bundle",
          "id": "submission-package-001",
          "type": "document",
          "timestamp": "2025-07-01T10:30:00Z",
          "entry": [
            {
              "fullUrl": "Submission/sub-2025-001",
              "resource": {
                "resourceType": "Submission",
                "id": "sub-2025-001",
                "status": "submitted",
                "insured": {
                  "reference": "Insured/ins-001",
                  "display": "Acme Manufacturing Corp"
                }
              }
            },
            {
              "fullUrl": "Insured/ins-001",
              "resource": {
                "resourceType": "Insured",
                "id": "ins-001",
                "name": "Acme Manufacturing Corp"
              }
            },
            {
              "fullUrl": "Risk/risk-prop-001",
              "resource": {
                "resourceType": "Risk",
                "id": "risk-prop-001",
                "riskType": {
                  "coding": [
                    {
                      "code": "property",
                      "display": "Property"
                    }
                  ]
                }
              }
            }
          ]
        }
      ]
    },
    "Meta": {
      "type": "object",
      "properties": {
        "versionId": {
          "type": "string",
          "description": "Version-specific identifier for this resource version. Changes each time the resource is updated."
        },
        "lastUpdated": {
          "type": "string",
          "description": "When this resource was last updated.",
          "format": "date-time"
        },
        "source": {
          "type": "string",
          "description": "URI identifying the originating system that created or last modified this resource.",
          "format": "uri"
        },
        "tag": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Coding"
          },
          "description": "Security or access control tags"
        }
      },
      "additionalProperties": false,
      "description": "Metadata about a resource instance. Tracks versioning, provenance, and timestamps."
    },
    "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"
        }
      ]
    },
    "Identifier": {
      "type": "object",
      "properties": {
        "system": {
          "type": "string",
          "description": "The namespace for the identifier value.",
          "format": "uri"
        },
        "value": {
          "type": "string",
          "description": "The identifier value within the namespace"
        },
        "type": {
          "$ref": "#/definitions/CodeableConcept",
          "description": "The kind of identifier (e.g., EIN, NAIC, NPN, FEIN)"
        },
        "period": {
          "$ref": "#/definitions/Period",
          "description": "Period during which this identifier is/was valid"
        }
      },
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "description": "A business identifier for an entity (e.g., NAIC code, EIN, NPN, policy number). Separates business identifiers from coded concepts.",
      "examples": [
        {
          "system": "urn:oid:2.16.840.1.113883.6.300",
          "value": "29459",
          "type": {
            "text": "NAIC"
          }
        }
      ]
    },
    "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."
    },
    "Period": {
      "type": "object",
      "properties": {
        "start": {
          "type": "string",
          "description": "Start of the period (inclusive).",
          "format": "date"
        },
        "end": {
          "type": "string",
          "description": "End of the period (inclusive).",
          "format": "date"
        }
      },
      "additionalProperties": false,
      "description": "A time period defined by a start and/or end date. Used for policy terms, coverage periods, etc.",
      "examples": [
        {
          "start": "2025-01-01",
          "end": "2026-01-01"
        }
      ]
    },
    "BundleLink": {
      "type": "object",
      "properties": {
        "relation": {
          "type": "string",
          "description": "The relationship of this link to the bundle. Common values: `self`, `next`, `previous`, `first`, `last`."
        },
        "url": {
          "type": "string",
          "description": "The URL for this link.",
          "format": "uri"
        }
      },
      "required": [
        "relation",
        "url"
      ],
      "additionalProperties": false,
      "description": "A navigation or context link associated with a bundle. Used for pagination in search results and for self-referencing.",
      "examples": [
        {
          "relation": "self",
          "url": "https://api.example.com/bind/Submission?status=submitted"
        }
      ]
    },
    "BundleEntry": {
      "type": "object",
      "properties": {
        "link": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/BundleLink"
          },
          "description": "Links related to this entry"
        },
        "fullUrl": {
          "type": "string",
          "description": "The absolute or relative URL for this resource. For BIND resources this is typically `{ResourceType}/{id}`.",
          "format": "uri"
        },
        "resource": {
          "$ref": "#/definitions/Resource",
          "description": "The resource contained in this entry. Can be any BIND resource type (Policy, Submission, Claim, etc.)."
        },
        "search": {
          "$ref": "#/definitions/BundleEntrySearch",
          "description": "Search result metadata (only in searchset bundles)"
        },
        "request": {
          "$ref": "#/definitions/BundleEntryRequest",
          "description": "Transaction/batch request metadata"
        },
        "response": {
          "$ref": "#/definitions/BundleEntryResponse",
          "description": "Transaction/batch response metadata"
        }
      },
      "additionalProperties": false,
      "description": "An entry in a Bundle, containing a resource and/or transaction metadata.\n\nThe content of each entry depends on the bundle type:\n- **document / collection**: `fullUrl` + `resource`\n- **transaction / batch**: `fullUrl` + `resource` + `request`\n- **transaction-response / batch-response**: `fullUrl` + `resource` + `response`\n- **searchset**: `fullUrl` + `resource` + `search`\n- **history**: `fullUrl` + `resource` + `request` + `response`",
      "examples": [
        {
          "fullUrl": "Policy/pol-2025-1001",
          "resource": {
            "resourceType": "Policy",
            "id": "pol-2025-1001",
            "status": "active",
            "policyNumber": "CGL-2025-001001"
          }
        }
      ]
    },
    "Resource": {
      "type": "object",
      "properties": {
        "resourceType": {
          "type": "string",
          "description": "Discriminator field identifying the BIND resource type"
        },
        "id": {
          "type": "string",
          "description": "Logical id of this resource. Assigned by the server or originating system."
        },
        "meta": {
          "$ref": "#/definitions/Meta",
          "description": "Metadata about the resource"
        }
      },
      "required": [
        "resourceType"
      ],
      "additionalProperties": false,
      "description": "Base resource interface for all BIND resources. Every resource in the BIND standard extends this base type.",
      "examples": [
        {
          "resourceType": "Policy",
          "id": "pol-abc-123",
          "meta": {
            "versionId": "1",
            "lastUpdated": "2025-01-15T10:30:00Z",
            "source": "https://carrier.example.com"
          }
        }
      ]
    },
    "BundleEntrySearch": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "match",
            "include"
          ],
          "description": "Why this resource is in the result set.\n\n- `match` — The resource matched the search criteria\n- `include` — The resource was included because another matching resource references it"
        },
        "score": {
          "type": "number",
          "description": "Relevance ranking score (0.0–1.0) assigned by the server. Higher values indicate a closer match to the search criteria.",
          "minimum": 0,
          "maximum": 1
        }
      },
      "additionalProperties": false,
      "description": "Search result metadata for an entry in a searchset bundle.",
      "examples": [
        {
          "mode": "match",
          "score": 0.95
        }
      ]
    },
    "BundleEntryRequest": {
      "type": "object",
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "GET",
            "HEAD",
            "POST",
            "PUT",
            "DELETE",
            "PATCH"
          ],
          "description": "The HTTP method for this entry.\n\n- `GET` — Read the resource\n- `HEAD` — Check resource existence (headers only)\n- `POST` — Create a new resource\n- `PUT` — Create or update a resource\n- `DELETE` — Remove a resource\n- `PATCH` — Partially update a resource"
        },
        "url": {
          "type": "string",
          "description": "The URL for this entry, relative to the server base.",
          "format": "uri"
        },
        "ifNoneMatch": {
          "type": "string",
          "description": "Only perform the operation if the ETag does not match (for caching). Maps to the HTTP `If-None-Match` header."
        },
        "ifModifiedSince": {
          "type": "string",
          "description": "Only perform the operation if the resource was modified after this date. Maps to the HTTP `If-Modified-Since` header.",
          "format": "date-time"
        },
        "ifMatch": {
          "type": "string",
          "description": "Only perform the operation if the ETag matches (for concurrency control). Maps to the HTTP `If-Match` header."
        },
        "ifNoneExist": {
          "type": "string",
          "description": "Only perform the create if no resource already matches the given criteria. Prevents duplicate creation in POST operations."
        }
      },
      "required": [
        "method",
        "url"
      ],
      "additionalProperties": false,
      "description": "Request metadata for an entry in a transaction or batch bundle. Describes the HTTP operation the server should perform for this entry.",
      "examples": [
        {
          "method": "PUT",
          "url": "Policy/pol-2025-1001"
        }
      ]
    },
    "BundleEntryResponse": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "description": "The HTTP status code and phrase returned by the server.",
          "examples": [
            "200 OK",
            "201 Created"
          ]
        },
        "location": {
          "type": "string",
          "description": "The location header returned by the server (for created/updated resources).",
          "format": "uri"
        },
        "etag": {
          "type": "string",
          "description": "The ETag for the resource, as returned by the server"
        },
        "lastModified": {
          "type": "string",
          "description": "When the resource was last modified on the server.",
          "format": "date-time"
        }
      },
      "required": [
        "status"
      ],
      "additionalProperties": false,
      "description": "Response metadata for an entry in a transaction-response or batch-response bundle. Contains the outcome of the operation that was performed.",
      "examples": [
        {
          "status": "201 Created",
          "location": "Policy/pol-2025-1001/_history/1",
          "etag": "W/\"1\"",
          "lastModified": "2025-07-01T10:30:00Z"
        }
      ]
    }
  },
  "$id": "https://bind-standard.org/schema/Bundle",
  "title": "Bundle"
}
