The flow that we’re implementing

  1. Create a product list via the api POST /v1/product_lists
  2. Create a snapshot to create and update list items via POST /v1/product_list/:id/items/snapshot

Let’s first create the product list

{
	"name": "A beautiful list",
	"currency": "dkk",
	"zones": ["DK"],
}
{
	"__typename": "ProductList",
	"id": "pl_e83nLCNupinqqcjsxRTHra",
	"name": "A beautiful list",
	"currency": "dkk",
	"zones": ["DK"]
	"metadata": {},
	"updatedAt": 1628441574461,
	"createdAt": 1628441574461
}

Now let’s populate the product list

Next up we need to create a snapshot of all the price list items. A snapshot is a view of the list items at a specific moment in time - which allows Stedger to both, create, update and delete items from a list without you having to explicitly do this.

To create a snapshot you have to simply send a post request to POST /v1/product_lists/pl_e83nLCNupinqqcjsxRTHra/items/snapshot which will respond with the following:

{
    "id": "snp_pt5k4ibZYUhbYxnh9JSrL1",
    "uploadUrl": "<https://api.stedger.com/v1/snapshots/snp_pt5k4ibZYUhbYxnh9JSrL1/upload>",
    "state": "open"
}

Then you upload the snapshot by sending a post request containing all the variants that should be available to a specific price list - to the provided url, in this case https://api.stedger.com/v1/snapshots/snp_pt5k4ibZYUhbYxnh9JSrL1/upload. Stedger will then make sure to create and update the correct items based on the variantForeignId, and delete the ones that are absent from the list snapshot.

[
	{
		"variantForeignId": "small-shirt-1",
		"price": 23000,
		"dropshipFee": 500,
		"acceptsDropshipOrders": true,
		"acceptsPurchaseOrders": true
	},
  {
		"variantForeignId": "big-shirt-1",
		"price": 27000,
		"dropshipFee": 550,
		"acceptsDropshipOrders": true,
		"acceptsPurchaseOrders": true
	}
]

Then whenever a change needs to be made to the price list, you simply just send all the items, which will result in Stedger copying those actions on our side. No need to keep track of which items need to be update, created or deleted.