{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mammoth-io/json-schema/mammoth-io-batches-post-request-schema.json",
  "title": "BatchesPostRequest",
  "description": "Specs for new batch to be created",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mammoth-io-batches-api-openapi.yml#/components/schemas/BatchesPostRequest",
  "properties": {
    "source_id": {
      "oneOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "description": "Source dataset id — omit when file_id is provided"
    },
    "mapping": {
      "oneOf": [
        {
          "items": {
            "$ref": "#/$defs/ColumnIdMapping"
          },
          "type": "array"
        },
        {
          "items": {
            "$ref": "#/$defs/ColumnNameMapping"
          },
          "type": "array"
        }
      ],
      "description": "Column mapping — not used, and may be omitted, when file_id is provided"
    },
    "validate_only": {
      "type": "boolean",
      "description": "Validation required",
      "default": false
    },
    "delete_source_ds": {
      "type": "boolean",
      "description": "Delete source dataset",
      "default": false
    },
    "new_ds_details": {
      "oneOf": [
        {
          "$ref": "#/$defs/NewDsDetails"
        },
        {
          "type": "null"
        }
      ],
      "description": "New dataset details"
    },
    "file_id": {
      "oneOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "description": "Id of an already-uploaded, unprocessed PDF file to replay this PDF-derived dataset's own recipe against, instead of combining with another dataset via source_id (PRD-2699)"
    },
    "projected_source_schema": {
      "oneOf": [
        {
          "items": {
            "$ref": "#/$defs/ProjectedSourceColumn"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "description": "The source dataset's schema as it will be once a pending interpretation recipe is confirmed. Only honored when validate_only is True - lets a dry-run validate the mapping against columns that don't exist yet, without mutating the source dataset."
    }
  },
  "type": "object",
  "required": [],
  "$defs": {
    "ColumnIdMapping": {
      "properties": {
        "destination_c_id": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Destination column id. Omitted when action is 'add_column' since the destination column does not exist yet."
        },
        "source_c_id": {
          "type": "string",
          "description": "Source column id"
        },
        "expected_destination_c_type": {
          "type": "string",
          "enum": [
            "TEXT",
            "NUMERIC",
            "DATE"
          ],
          "description": "Expected destination column data type"
        },
        "action": {
          "type": [
            "null",
            "string"
          ],
          "enum": [
            "add_column",
            null
          ],
          "description": "Mapping action. 'add_column' creates a new destination column from the source column. Omit to map the source column onto an existing destination column. Source columns the user wants to skip are simply left out of the mapping."
        }
      },
      "type": "object",
      "required": [
        "expected_destination_c_type",
        "source_c_id"
      ],
      "title": "ColumnIdMapping"
    },
    "ColumnNameMapping": {
      "properties": {
        "destination_c_name": {
          "type": "string",
          "description": "Destination column name"
        },
        "source_c_name": {
          "type": "string",
          "description": "Source column name"
        },
        "expected_destination_c_type": {
          "type": "string",
          "enum": [
            "TEXT",
            "NUMERIC",
            "DATE"
          ],
          "description": "Expected destination column data type"
        }
      },
      "type": "object",
      "required": [
        "destination_c_name",
        "expected_destination_c_type",
        "source_c_name"
      ],
      "title": "ColumnNameMapping"
    },
    "NewDsDetails": {
      "properties": {
        "name": {
          "type": "string",
          "description": "New dataset name"
        }
      },
      "type": "object",
      "required": [
        "name"
      ],
      "title": "NewDsDetails"
    },
    "ProjectedSourceColumn": {
      "properties": {
        "internal_name": {
          "type": "string",
          "description": "Internal column name the source dataset will have once its pending interpretation recipe is confirmed"
        },
        "type": {
          "type": "string",
          "enum": [
            "TEXT",
            "NUMERIC",
            "DATE"
          ],
          "description": "Column data type"
        }
      },
      "type": "object",
      "required": [
        "internal_name",
        "type"
      ],
      "title": "ProjectedSourceColumn"
    }
  }
}