{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/fleetkeep-co-uk/json-schema/fleetkeep-co-uk-apply-spreadsheet-payload-schema.json",
  "title": "ApplySpreadsheetPayload",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/fleetkeep-co-uk-imports-api-openapi.yml#/components/schemas/ApplySpreadsheetPayload",
  "allOf": [
    {
      "$ref": "#/$defs/SpreadsheetPayload"
    },
    {
      "type": "object",
      "required": [
        "confirmDigest",
        "idempotencyKey"
      ],
      "properties": {
        "confirmDigest": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "idempotencyKey": {
          "type": "string",
          "minLength": 8,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{7,127}$"
        },
        "offset": {
          "type": "integer",
          "minimum": 0,
          "maximum": 999,
          "description": "Position within the sorted selected rows. Required for batches; each request applies at most five rows."
        },
        "confirmSelectionDigest": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "Exact selectionDigest from preview. Required when offset is supplied."
        }
      }
    }
  ],
  "$defs": {
    "SpreadsheetPayload": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "sourceName",
            "csv"
          ],
          "properties": {
            "sourceName": {
              "type": "string",
              "pattern": "^.*\\.[cC][sS][vV]$",
              "maxLength": 160
            },
            "csv": {
              "type": "string",
              "maxLength": 262144
            },
            "selectedRows": {
              "type": "array",
              "minItems": 1,
              "maxItems": 1000,
              "uniqueItems": true,
              "items": {
                "type": "integer",
                "minimum": 0,
                "maximum": 999
              },
              "description": "Original zero-based data-row indices, excluding the header. Omission selects all rows. Repeat the same selection on preview and apply."
            }
          }
        },
        {
          "type": "object",
          "required": [
            "sourceName",
            "contentBase64"
          ],
          "properties": {
            "sourceName": {
              "type": "string",
              "pattern": "^.*\\.[xX][lL][sS][xX]$",
              "maxLength": 160
            },
            "contentBase64": {
              "type": "string",
              "contentEncoding": "base64"
            },
            "selectedRows": {
              "type": "array",
              "minItems": 1,
              "maxItems": 1000,
              "uniqueItems": true,
              "items": {
                "type": "integer",
                "minimum": 0,
                "maximum": 999
              },
              "description": "Original zero-based data-row indices, excluding the header. Omission selects all rows. Repeat the same selection on preview and apply."
            }
          }
        }
      ]
    }
  }
}