# Copy options

The destination collection, per-copy options, pricing and stock rules, and category and handle text.

Source: https://clonelyapp.com/api/options/


`POST /copies` and `POST /products/copy` take the same optional objects: `destination`, `options` and `applyToEach`. Unknown fields anywhere in the body are refused with `400 invalid_request`, and `issues` in the error names each one.

## destination

The collection the copied products are added to. Send exactly one of these fields:

| Field | |
|---|---|
| `collectionId` | The Admin API GID of an existing collection, like `gid://shopify/Collection/123456789`. A bare number is refused. |
| `collectionHandle` | The handle of an existing collection, like `boots`. |
| `newCollectionTitle` | The title of a collection to create. Each request creates a new one, even if a collection with this title exists. |

Clonely checks an existing collection before the copy starts; an unknown one is `400 invalid_request`. Leave `destination` out to add the products to no collection. Smart (automated) collections are left as they are, since Shopify fills them by their conditions.

```json
{ "destination": { "collectionId": "gid://shopify/Collection/123456789" } }
```

## options

Settings for this copy only, the same ones as the copy page's advanced options. Any field you leave out takes the value saved in Settings at the moment the copy starts. The saved settings don't change.

| Field | Values | |
|---|---|---|
| `publish` | boolean | Publish new products, or save them as drafts. |
| `importTags` | boolean | Copy tags. |
| `importTax` | boolean | Copy the "charge tax" setting. |
| `importSku` | boolean | Copy SKUs. |
| `onDuplicate` | `skip`, `update` | What to do when the product is already in your store. |
| `updateMatch` | `copied`, `handle`, `handle_sku` | 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` | `all`, `selected` | Update every field, or only the ones turned on below. |
| `updatePrice` | boolean | Update the price. |
| `updateCompareAtPrice` | boolean | Update the compare-at price. |
| `updateCost` | boolean | Update the cost. |
| `updateImagesMode` | `none`, `add`, `match`, `replace` | `add`: only new images. `match`: also remove images the source dropped. `replace`: all images. |
| `updateTitle` | boolean | Update the title. |
| `updateDescription` | boolean | Update the description. |
| `updateTagsMode` | `none`, `merge`, `replace` | `merge` keeps the product's tags and adds the source's. `replace` uses only the source's. |
| `updateAddVariants` | boolean | Add variants that are new at the source. |
| `updateRemoveVariants` | boolean | Remove variants the source no longer has. |
| `updateStock` | boolean | Apply the [stock rules](#stock) to products that already exist. |
| `price` | object | See [price](#price). |
| `stock` | object | See [stock](#stock). |

The `update...` fields only matter when `onDuplicate` is `update`. To see every value a copy runs with, read `options` on [`GET /copies/{id}`](https://clonelyapp.com/api/copies/#get-copiesid).

```json
{
  "options": {
    "publish": false,
    "onDuplicate": "update",
    "updateMatch": "copied",
    "updateScope": "selected",
    "updatePrice": true,
    "updateCompareAtPrice": true
  }
}
```

### price

How prices are set, as under Pricing in Settings. Fields you leave out keep their saved value, field by field inside `price`, `compareAt` and `cost`.

| Field | |
|---|---|
| `enabled` | `false` copies prices unchanged, whatever the other fields say. |
| `price` | Rule for the price. `base`: `supplierPrice` or `fromSupplierPrice`. |
| `compareAt` | Rule for the compare-at price. `base`: `supplierCompare`, `supplierPrice`, `fromSupplierCompare`, `fromSupplierPrice`, `fromNewPrice` or `none`. |
| `cost` | Rule for the cost. `base`: `supplierPrice`, `fromSupplierPrice`, `fromNewPrice` or `none`. |

The bases without `from` copy the value as it is (`supplierCompare` is the supplier's compare-at price). The `from...` bases start from that value and apply the adjustment; `fromNewPrice` starts from the price Clonely just worked out. `none` sets no value.

Each rule also takes the adjustment:

| Field | |
|---|---|
| `type` | `none`, `percentage` or `amount`. |
| `value` | The percentage or amount. Positive raises the price, negative lowers it. |
| `rounding` | The cents the result ends in, 0 to 99 (`99` makes 12.99), or `null` for no rounding. |
| `roundingDirection` | `standard`, `up` or `down`. |

This sets the price to the supplier price plus 20%, ending in .99, and the compare-at price to 30% above the new price:

```json
{
  "options": {
    "price": {
      "enabled": true,
      "price": { "base": "fromSupplierPrice", "type": "percentage", "value": 20, "rounding": 99, "roundingDirection": "up" },
      "compareAt": { "base": "fromNewPrice", "type": "percentage", "value": 30, "rounding": 0, "roundingDirection": "standard" }
    }
  }
}
```

### stock

Stock quantities per location, as under Stock in Settings. The rules need inventory access, which you grant in Clonely's Settings. Without it, Clonely skips them.

| Field | |
|---|---|
| `enabled` | Turn the stock rules on or off. |
| `rules` | Up to 100 rules, one per location. When you send `rules`, they replace the saved rules for this copy. A location with no rule is never changed. |

Each rule:

| Field | |
|---|---|
| `locationId` | The location's GID, like `gid://shopify/Location/123456789`. |
| `locationName` | Optional. Shown on the task page. |
| `inStock` | For variants the supplier has in stock: `{ "action": "set", "quantity": 100 }` sets the quantity, `{ "action": "ignore" }` leaves it alone. |
| `outOfStock` | For variants the supplier has sold out, the same way. |

```json
{
  "options": {
    "stock": {
      "enabled": true,
      "rules": [
        {
          "locationId": "gid://shopify/Location/123456789",
          "inStock": { "action": "set", "quantity": 100 },
          "outOfStock": { "action": "set", "quantity": 0 }
        }
      ]
    }
  }
}
```

## applyToEach

Applied to each product the copy creates.

| Field | |
|---|---|
| `categoryId` | A Shopify product category GID, like `gid://shopify/TaxonomyCategory/aa-1-13-8`. Set on every product the copy creates or updates. |
| `handleStart` | Text added to the start of each new URL handle, up to 100 characters. |
| `handleEnd` | Text added to the end of each new URL handle, up to 100 characters. |

```json
{ "applyToEach": { "categoryId": "gid://shopify/TaxonomyCategory/aa-1-13-8", "handleStart": "acme-" } }
```

## sourcePassword

If the source store is password protected, send its storefront password as `sourcePassword`. Clonely uses it once to log in and doesn't store it. Without it, the request gets `400 password_required`; a wrong one gets `400 password_wrong`.

