{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/BundleEntry",
  "definitions": {
    "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"
          }
        }
      ]
    },
    "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"
        }
      ]
    },
    "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"
          }
        }
      ]
    },
    "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"
        }
      ]
    },
    "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/BundleEntry",
  "title": "BundleEntry"
}
