{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/clonelyapp-com/json-schema/clonelyapp-com-start-copy-request-schema.json",
  "title": "StartCopyRequest",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clonelyapp-com-openapi.json#/components/schemas/StartCopyRequest",
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "collection",
        "store"
      ]
    },
    "sourceUrl": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048
    },
    "destination": {
      "$ref": "#/$defs/Destination"
    },
    "sourcePassword": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Storefront password of a password-protected source store. Used once to log in, never stored."
    },
    "options": {
      "$ref": "#/$defs/CopyOptions"
    },
    "applyToEach": {
      "$ref": "#/$defs/ApplyToEach"
    }
  },
  "required": [
    "kind",
    "sourceUrl"
  ],
  "additionalProperties": false,
  "$defs": {
    "ApplyToEach": {
      "type": "object",
      "properties": {
        "categoryId": {
          "type": "string",
          "pattern": "^gid:\\/\\/shopify\\/TaxonomyCategory\\/[a-z]{2}(-\\d+)*$",
          "description": "Product category set on every product the copy creates (and updates)."
        },
        "handleStart": {
          "type": "string",
          "maxLength": 100,
          "description": "Text added to the start of each new URL handle."
        },
        "handleEnd": {
          "type": "string",
          "maxLength": 100,
          "description": "Text added to the end of each new URL handle."
        }
      },
      "additionalProperties": false,
      "description": "Applied to each product this copy creates."
    },
    "CopyOptions": {
      "type": "object",
      "properties": {
        "publish": {
          "type": "boolean",
          "description": "Publish new products (true) or save them as drafts."
        },
        "importTags": {
          "type": "boolean",
          "description": "Copy tags."
        },
        "importTax": {
          "type": "boolean",
          "description": "Copy the \"charge tax\" setting."
        },
        "importSku": {
          "type": "boolean",
          "description": "Copy SKUs."
        },
        "onDuplicate": {
          "type": "string",
          "enum": [
            "skip",
            "update"
          ],
          "description": "When the product is already in the store: skip it, or update it with the fields below."
        },
        "updateMatch": {
          "type": "string",
          "enum": [
            "copied",
            "handle",
            "handle_sku"
          ],
          "description": "Which existing products an update may change. copied: only products Clonely copied. handle: any product with the same URL handle. handle_sku: the same URL handle or SKU."
        },
        "updateScope": {
          "type": "string",
          "enum": [
            "all",
            "selected"
          ],
          "description": "all: update every field. selected: only the fields below."
        },
        "updatePrice": {
          "type": "boolean"
        },
        "updateCompareAtPrice": {
          "type": "boolean"
        },
        "updateCost": {
          "type": "boolean"
        },
        "updateImagesMode": {
          "type": "string",
          "enum": [
            "none",
            "add",
            "match",
            "replace"
          ],
          "description": "none, add (only new images), match (also remove images the source dropped), replace (all)."
        },
        "updateTitle": {
          "type": "boolean"
        },
        "updateDescription": {
          "type": "boolean"
        },
        "updateTagsMode": {
          "type": "string",
          "enum": [
            "none",
            "merge",
            "replace"
          ],
          "description": "none, merge (keep the product's tags) or replace."
        },
        "updateAddVariants": {
          "type": "boolean"
        },
        "updateRemoveVariants": {
          "type": "boolean"
        },
        "updateStock": {
          "type": "boolean",
          "description": "Apply the stock rules to products that already exist."
        },
        "price": {
          "$ref": "#/$defs/PriceRules"
        },
        "stock": {
          "$ref": "#/$defs/StockRules"
        }
      },
      "additionalProperties": false,
      "description": "Options for this copy only, as in the copy page's advanced options. Fields left out use the store's saved settings at the time the copy starts. Unknown fields are refused."
    },
    "Destination": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "collectionId": {
              "type": "string",
              "pattern": "^gid:\\/\\/shopify\\/Collection\\/\\d+$",
              "description": "Admin API GID of an existing collection. A bare numeric ID is refused."
            }
          },
          "required": [
            "collectionId"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "collectionHandle": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "description": "Handle of an existing collection."
            }
          },
          "required": [
            "collectionHandle"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "newCollectionTitle": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "description": "Title of a collection to create. Not de-duplicated: each request creates a new collection, even if one with this title exists. For a single product it is created only after the copy succeeds."
            }
          },
          "required": [
            "newCollectionTitle"
          ],
          "additionalProperties": false
        }
      ],
      "description": "The collection copied products are added to: an existing one by GID or handle (checked before the copy starts; unknown is 400 invalid_request), or a new one. Omit to add them to no collection. Smart (automated) collections are left unchanged."
    },
    "PriceRules": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Off: prices are copied unchanged, whatever the fields below say."
        },
        "price": {
          "type": "object",
          "properties": {
            "base": {
              "type": "string",
              "enum": [
                "supplierPrice",
                "fromSupplierPrice"
              ]
            },
            "type": {
              "type": "string",
              "enum": [
                "none",
                "percentage",
                "amount"
              ],
              "description": "none, percentage or amount. The value carries the sign."
            },
            "value": {
              "type": "number",
              "description": "Percentage or amount. Positive raises the price, negative lowers it."
            },
            "rounding": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 99,
              "description": "Cents the result ends in (99 makes 12.99), or null for no rounding."
            },
            "roundingDirection": {
              "type": "string",
              "enum": [
                "standard",
                "up",
                "down"
              ]
            }
          },
          "additionalProperties": false
        },
        "compareAt": {
          "type": "object",
          "properties": {
            "base": {
              "type": "string",
              "enum": [
                "supplierCompare",
                "supplierPrice",
                "fromSupplierCompare",
                "fromSupplierPrice",
                "fromNewPrice",
                "none"
              ]
            },
            "type": {
              "type": "string",
              "enum": [
                "none",
                "percentage",
                "amount"
              ],
              "description": "none, percentage or amount. The value carries the sign."
            },
            "value": {
              "type": "number",
              "description": "Percentage or amount. Positive raises the price, negative lowers it."
            },
            "rounding": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 99,
              "description": "Cents the result ends in (99 makes 12.99), or null for no rounding."
            },
            "roundingDirection": {
              "type": "string",
              "enum": [
                "standard",
                "up",
                "down"
              ]
            }
          },
          "additionalProperties": false
        },
        "cost": {
          "type": "object",
          "properties": {
            "base": {
              "type": "string",
              "enum": [
                "supplierPrice",
                "fromSupplierPrice",
                "fromNewPrice",
                "none"
              ]
            },
            "type": {
              "type": "string",
              "enum": [
                "none",
                "percentage",
                "amount"
              ],
              "description": "none, percentage or amount. The value carries the sign."
            },
            "value": {
              "type": "number",
              "description": "Percentage or amount. Positive raises the price, negative lowers it."
            },
            "rounding": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0,
              "maximum": 99,
              "description": "Cents the result ends in (99 makes 12.99), or null for no rounding."
            },
            "roundingDirection": {
              "type": "string",
              "enum": [
                "standard",
                "up",
                "down"
              ]
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false,
      "description": "How prices are set, as under Pricing in Settings. Fields left out keep the saved value (each of price, compareAt and cost field by field)."
    },
    "StockRules": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "rules": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "locationId": {
                "type": "string"
              },
              "locationName": {
                "type": "string",
                "maxLength": 255,
                "description": "Shown on the task page."
              },
              "inStock": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "set",
                      "ignore"
                    ],
                    "description": "set: set the quantity below. ignore: leave it alone."
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000000,
                    "default": 0
                  }
                },
                "required": [
                  "action"
                ],
                "additionalProperties": false,
                "description": "For variants the supplier has in stock."
              },
              "outOfStock": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "set",
                      "ignore"
                    ],
                    "description": "set: set the quantity below. ignore: leave it alone."
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000000000,
                    "default": 0
                  }
                },
                "required": [
                  "action"
                ],
                "additionalProperties": false,
                "description": "For variants the supplier has sold out."
              }
            },
            "required": [
              "locationId",
              "inStock",
              "outOfStock"
            ],
            "additionalProperties": false
          },
          "maxItems": 100,
          "description": "Replaces the saved rules when given. A location with no rule is never changed."
        }
      },
      "additionalProperties": false,
      "description": "Stock quantities per location, as under Stock in Settings. Needs inventory access, which the merchant grants in Settings; without it the rules are skipped."
    }
  }
}