{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/clonelyapp-com/json-schema/clonelyapp-com-copy-schema.json",
  "title": "Copy",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clonelyapp-com-openapi.json#/components/schemas/Copy",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "collection",
        "store"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "PENDING",
        "IN_PROGRESS",
        "COMPLETED",
        "FAILED",
        "CANCELLED"
      ]
    },
    "message": {
      "type": [
        "string",
        "null"
      ],
      "description": "The pause, retry or failure reason the task page shows."
    },
    "sourceUrl": {
      "type": "string"
    },
    "destinationCollectionId": {
      "type": [
        "string",
        "null"
      ]
    },
    "productsCopied": {
      "type": "integer",
      "description": "Products added, updated or saved with issues so far. A running counter of copy events: a copy that was paused and resumed can count a product again, so it can differ from `outcomes`."
    },
    "productsTotal": {
      "type": "integer",
      "description": "0 until the copy starts reading the source. While it runs it is the source's product count; on completion it is the number of products the copy processed."
    },
    "totalIsEstimate": {
      "type": "boolean",
      "description": "true until status is COMPLETED: productsTotal can still change."
    },
    "outcomes": {
      "type": "object",
      "properties": {
        "added": {
          "type": "integer"
        },
        "updated": {
          "type": "integer"
        },
        "savedWithIssues": {
          "type": "integer"
        },
        "skippedAlreadyExists": {
          "type": "integer"
        },
        "skippedUnchanged": {
          "type": "integer"
        },
        "skippedNotCopied": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        },
        "waitingForVariantLimit": {
          "type": "integer"
        }
      },
      "description": "Distinct products per result (by the handle this copy gives them), as on the task page. A product recorded twice with the same result counts once, but one product can count under two results (for example added, then skippedAlreadyExists after a resume), so the values can add up to more than the number of products. `failed` excludes products that later got another result."
    },
    "options": {
      "$ref": "#/$defs/EffectiveOptions"
    },
    "applyToEach": {
      "type": "object",
      "properties": {
        "categoryId": {
          "type": [
            "string",
            "null"
          ]
        },
        "categoryName": {
          "type": [
            "string",
            "null"
          ]
        },
        "handleStart": {
          "type": [
            "string",
            "null"
          ]
        },
        "handleEnd": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "categoryId",
        "categoryName",
        "handleStart",
        "handleEnd"
      ]
    },
    "retryAfter": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "A paused copy resumes after this time."
    },
    "stoppedAtProductLimit": {
      "type": "boolean",
      "description": "Finished at Shopify's 25,000-product limit for a storefront listing: the source may have more products. Copy its collections separately to get the rest."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "kind",
    "status",
    "message",
    "sourceUrl",
    "destinationCollectionId",
    "productsCopied",
    "productsTotal",
    "totalIsEstimate",
    "outcomes",
    "options",
    "applyToEach",
    "retryAfter",
    "stoppedAtProductLimit",
    "createdAt",
    "updatedAt"
  ],
  "$defs": {
    "EffectiveOptions": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "publish": {
          "type": "boolean"
        },
        "importTags": {
          "type": "boolean"
        },
        "importTax": {
          "type": "boolean"
        },
        "importSku": {
          "type": "boolean"
        },
        "onDuplicate": {
          "type": "string",
          "enum": [
            "skip",
            "update"
          ]
        },
        "updateMatch": {
          "type": "string",
          "enum": [
            "copied",
            "handle",
            "handle_sku"
          ]
        },
        "updateScope": {
          "type": "string",
          "enum": [
            "all",
            "selected"
          ]
        },
        "updatePrice": {
          "type": "boolean"
        },
        "updateCompareAtPrice": {
          "type": "boolean"
        },
        "updateCost": {
          "type": "boolean"
        },
        "updateImagesMode": {
          "type": "string",
          "enum": [
            "none",
            "add",
            "match",
            "replace"
          ]
        },
        "updateTitle": {
          "type": "boolean"
        },
        "updateDescription": {
          "type": "boolean"
        },
        "updateTagsMode": {
          "type": "string",
          "enum": [
            "none",
            "merge",
            "replace"
          ]
        },
        "updateAddVariants": {
          "type": "boolean"
        },
        "updateRemoveVariants": {
          "type": "boolean"
        },
        "updateStock": {
          "type": "boolean"
        },
        "price": {
          "$ref": "#/$defs/PriceRules"
        },
        "stock": {
          "$ref": "#/$defs/StockRules"
        }
      },
      "required": [
        "publish",
        "importTags",
        "importTax",
        "importSku",
        "onDuplicate",
        "updateMatch",
        "updateScope",
        "updatePrice",
        "updateCompareAtPrice",
        "updateCost",
        "updateImagesMode",
        "updateTitle",
        "updateDescription",
        "updateTagsMode",
        "updateAddVariants",
        "updateRemoveVariants",
        "updateStock",
        "price",
        "stock"
      ],
      "description": "null: the copy reads the store's saved settings when it starts (copies started in the app without advanced options)."
    },
    "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."
    }
  }
}