{
  "type": "object",
  "properties": {
    "profileId": {
      "type": "string"
    },
    "policyId": {
      "type": "string"
    },
    "mimeType": {
      "type": "string"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "custody": {
      "type": "string",
      "enum": [
        "PROVIDER_MANAGED",
        "CUSTOMER_MANAGED",
        "HASH_ONLY"
      ]
    },
    "dataReference": {
      "type": "string",
      "format": "uri",
      "description": "Allow-listed object reference; arbitrary server-side URL fetching is forbidden."
    },
    "digest": {
      "$ref": "Digest.json"
    },
    "archivalPeriod": {
      "$ref": "ArchivalPeriod.json"
    },
    "groupId": {
      "type": "string"
    },
    "clientReference": {
      "type": "string"
    },
    "requestTime": {
      "type": "string",
      "format": "date-time"
    },
    "uploadId": {
      "type": "string",
      "minLength": 1,
      "description": "Identifier of a completed upload in an agreed storage connector; upload transport is outside these REST contracts."
    },
    "externalObjectId": {
      "type": "string",
      "minLength": 1,
      "description": "Owner-retained data identifier for hash-only preservation; not an automatic fetch URL."
    }
  },
  "required": [
    "profileId",
    "policyId",
    "mimeType",
    "custody",
    "digest",
    "archivalPeriod"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "custody": {
            "const": "PROVIDER_MANAGED"
          }
        },
        "required": [
          "custody"
        ]
      },
      "then": {
        "required": [
          "uploadId"
        ],
        "not": {
          "anyOf": [
            {
              "required": [
                "dataReference"
              ]
            },
            {
              "required": [
                "externalObjectId"
              ]
            }
          ]
        }
      }
    },
    {
      "if": {
        "properties": {
          "custody": {
            "const": "CUSTOMER_MANAGED"
          }
        },
        "required": [
          "custody"
        ]
      },
      "then": {
        "required": [
          "dataReference"
        ],
        "not": {
          "anyOf": [
            {
              "required": [
                "uploadId"
              ]
            },
            {
              "required": [
                "externalObjectId"
              ]
            }
          ]
        }
      }
    },
    {
      "if": {
        "properties": {
          "custody": {
            "const": "HASH_ONLY"
          }
        },
        "required": [
          "custody"
        ]
      },
      "then": {
        "required": [
          "externalObjectId"
        ],
        "not": {
          "anyOf": [
            {
              "required": [
                "dataReference"
              ]
            },
            {
              "required": [
                "uploadId"
              ]
            }
          ]
        }
      }
    }
  ],
  "examples": [
    {
      "profileId": "profile-test-01",
      "policyId": "policy-test-v1",
      "mimeType": "text/plain",
      "metadata": {
        "title": "LTANS-SYN-001 / r1",
        "sourceId": "LTANS-SYN-001",
        "sourceRevision": "r1"
      },
      "custody": "CUSTOMER_MANAGED",
      "dataReference": "https://storage.example.invalid/test/primary-record.txt",
      "digest": {
        "algorithm": "SHA-256",
        "value": "35bc4fcffc4a16c8a9db81d1a8f9042c27a1daaf51628b4c880f312178fe3085"
      },
      "archivalPeriod": {
        "endAt": "2036-10-15T00:00:00Z"
      },
      "clientReference": "LTANS-SYN-001/r1",
      "requestTime": "2026-10-15T05:00:00Z",
      "groupId": "grp-syn-001"
    }
  ]
}
