1. Webhook Setup

Setup a product (aka “advert”) webhook that will emit an event every time a new product is created.

Build Outcome

By the end of this section we will have:

  • Set up a Product Created Webhook in Marketplacer
  • Tested that the Webhook fires

Steps

Create the webhook

Login to the Marketplacer Operator Portal as an Administrator, and:

1: Expand Configuration and select Webhooks

Select Webhooks


2: Select New Webhook

New Webhook


3: Populate the webhook creation fields

Webhook Fields


  • Enabled: True - Activates / Deactivates the webhook
  • Type: Advert - The object type we are interested in
  • Event Name (filter): Create - The event type we are interested in
  • URL: This will be our Azure HTTP trigger function eventually, for now you can populate with a test endpoint supplied by: webhook.site

Note: webhook.site is a 3rd party app which will receive webhook payloads from Marketplacer, please use at your own discretion.

  • Headers: {"AuthKey":"<some key value>"} - We will be validating this header in our Azure function to determine whether we can trust this webhook event. Please generate your own unique key value. Headers are defined as JSON objects.
  • GraphQL: This is a GraphQL query that shapes our webhook payload. An example query is shown below that you can use:
query ($id: ID!) {
	node(id: $id) {
		... on Advert {
			__typename
			id
			legacyId
			title
			description
			variants {
				nodes {
					id
					sku
					countOnHand
				}
			}
		}
	}
}

We provide more examples of the queries you can use to shape your webhook payloads in our API collections (see the Webhook Query Template folder.)


4: When you are happy, clicking Save will return you to the newly created webhook.

Webhook Created


Test the webhook

5: To test this webhook we need to create an Advert in Marketplacer, you can do this in one of the following ways:

  • Manually create in the Seller Portal
  • Use the Seller API advertUpsert mutation
  • CSV Upload

Creating an Advert should result in an event being generated in webhook.site as follows:


Webhook Event