The userflow that we’re implementing

  1. User selects one or multiple products inside Stedger and Connects them
  2. Stedger notifies the App (via a webhook connected_product.added event)
  3. The App handles the newly connected product internally
  4. The App notifies Stedger how the connection went by sending a POST /v1/connected_products/:id/status with the status “connected” or “failed”.
  5. If the App reported that the connection was a success Stedger will send a webhook connected_product.variant.updated event every time the product is updated

Let’s get to it

First we need to setup a webhook to be notified anytime a new product is to be connected. Start by setting up a webhook for the connected_product.added event (more info here) like so:

{
  "description": "New connected product",
  "enabledEvents": ["connected_product.added"],
  "url": "<https://your-domain.com/webhook-dummy-route>"
}

When that is setup you’re ready to receive these events, and handle them. This can be by creating the product in your own system, or by simply just registering it with an already existing product.

Afterwards you have to notify Stedger how it went by sending a “connected” status back, if it was a success:

{
  "status": "connected"
}

If an error happened, because the product is missing something, or for some other reason you can let Stedger know there was an error - a good idea here is to include an error message, that the user can use to fix the problem:

{
  "status": "failed",
	"errorMessage": "SKU already exists"
}

Working with connected products

Now that a product has been connected you can query all the connected products by requesting /v1/connected_products. Your app will also receive webhook events every time the product has changed if you’ve subscribed to the connected_product.variant.updated topic.