CopyHero

Preflight Product Change

POST
/api/v1/product-changes/preflight

Preview a product change

Dry run of proposing a product change: the diff, change types and what the approval rules would decide. Nothing is stored.

Authorization

HTTPBearer
headerAuthorizationBearer <token>

Request Body

application/json
  1. body
internal_product_id*Internal Product Id
Formatuuid
store_id*Store Id
patch*

The change a client proposes, on the fields of InternalProductUpdateRequest: null leaves a field alone, a list replaces the whole list. Metafields are not in the product document, so they are set or deleted one namespace.key at a time. delete removes the product and stands alone.

reason?|

Why the change is proposed; shown to the user who decides.

Response Body

Successful Response

application/json
  1. response

What creating the change would answer; nothing is stored.

result*Result
Value in"pending""auto_approved"
change_types*array<>
diff*

product_change.diff: old and new value of every field the change touches, computed against base_revision_number; variants and images per element.

base_revision_number*Base Revision Number
risk_level*|null
evaluation*

product_change.evaluation and the rule result of pchange.api.evaluate. risk_level is null for auto_approve; order_data_missing marks an auto_approve lowered to manual_low because the store has no order data.

Example Request
curl -X POST 'https://app.copyhero.app/api/v1/product-changes/preflight' \  -H 'Content-Type: application/json' \  -d '{  "internal_product_id": "17d65d0a-2bba-46da-af25-e6db2fc23598",  "store_id": 0,  "patch": {}}'
Example Response
{  "result": "pending",  "change_types": [    "price"  ],  "diff": {    "fields": [      {        "field": "title",        "old": null,        "new": null      }    ],    "variants": [      {        "ref": {          "key": "string",          "sku": "string",          "option_values": [            {              "name": "string",              "value": "string"            }          ],          "create": true        },        "old": {          "sku": "string",          "price": "string",          "compare_at_price": "string",          "option_values": [            {              "name": "string",              "value": "string"            }          ],          "image_src": "string",          "metafields": [            {              "namespace": "string",              "key": "string",              "type": "string",              "value": "string"            }          ]        },        "new": {          "sku": "string",          "price": "string",          "compare_at_price": "string",          "option_values": [            {              "name": "string",              "value": "string"            }          ],          "image_src": "string",          "metafields": [            {              "namespace": "string",              "key": "string",              "type": "string",              "value": "string"            }          ]        }      }    ],    "images": [      {        "ref": {          "key": "string",          "shopify_id": "string",          "url": "string",          "create": true        },        "old": {          "src": "string",          "position": 0,          "alt_text": "string"        },        "new": {          "src": "string",          "position": 0,          "alt_text": "string"        }      }    ]  },  "base_revision_number": 0,  "risk_level": "low",  "evaluation": {    "outcome": "auto_approve",    "risk_level": "low",    "order_data_missing": true,    "change_types": [      {        "change_type": "price",        "outcome": "auto_approve",        "winner_rule_id": "a0d63d6e-eec1-49e2-b3f1-596e5cd260a6",        "rules": [          {            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",            "name": "string",            "outcome": "auto_approve",            "change_types": [              "price"            ],            "conditions": {              "v": 1,              "all": [                {                  "field": "string",                  "op": "string",                  "value": null                }              ]            }          }        ]      }    ]  }}