Managing Webhook API versions

Step 1: Update the Code

Before you select a newer webhook API version, you need to test it against your code.

Add logic to your code so that it handles webhooks differently depending on their API versions. To check the API version, your app can use the X-Shopify-Api-Version request header in every webhook POST request.

Step 2: Test the Newer API Version

From your store’s notification settings, add some webhooks that use the newer version, and then send some test payloads. Your existing webhooks will continue to use the older API version. Check that your code correctly handles the test webhooks, and make any necessary adjustments.

  1. From the Shopify admin, go to Settings > Notifications.
  2. Click Create webhook, or click an existing webhook.
  3. If this is a new webhook, then provide the event, format, and URL.
  4. Select an API version from the Webhook API version drop-down list.

Step 3: Select the newer API Version

Select the newer API version for app. Your updated webhook uses that version.

Select a webhook API version for a public or custom app by following the steps below:

  1. From your Partner dashboard, go to Apps.
  2. Click the public or custom app that you want to update.
  3. Click App setup.
  4. In the Event subscriptions section, from the Event version drop-down list, select an API version.
  5. Click Save.

Select a webhook API version for a private app by following the steps below:

  1. From the Shopify admin, go to Apps.
  2. Click Develop apps for your store
  3. Click the private app that you want to update.
  4. In the Admin API section, from the Webhook API version drop-down list, select an API version.
  5. Click Save.

Step 4 : Test Webhook and remove references to the older API Version

Make sure that your code handles the updated webhook payloads correctly. After you’ve verified that everything is working, update your code to remove the following:

  • The logic that you added
  • References to the old webhook API version

Leave a comment

Your email address will not be published. Required fields are marked *