How to include variant metafields in webhook?

Topic summary

Core Issue:
Developers are trying to include variant-level metafields in Shopify’s products/update webhook. When configuring metafield_namespaces, these apply only to product-level metafields, not variant metafields.

Initial Workaround:
Early participants resorted to making additional API calls to fetch variant metafield data after receiving webhooks, as the metafields key in variant objects remained empty despite being present in the payload.

Proposed Solution:
One user (JohnWF) reported success by including the variant metafield namespace in the metafieldNamespaces array when creating the webhook subscription. They shared code showing a GraphQL mutation with includeFields: ['id', 'variants'] and metafieldNamespaces: ['loyalty'] to retrieve variant metafields like variant.metafields.loyalty.points.

Ongoing Problem:
A recent user reports this solution isn’t working for them—webhooks fire when updating variant properties (like SKU) but not when updating variant metafield values directly, suggesting the issue may not be fully resolved or implementation-dependent.

Status: Unresolved for some users; awaiting official Shopify team clarification.

Summarized with AI on October 26. AI used: claude-sonnet-4-5-20250929.

I’m able to configure a webhook for the “products/update” topic that sends my app both product and variant data. Webhooks fire as expected when I update products and variants and their metafields.

The issue is when you configure “metafield_namespaces” on the webhook, they are for the products and not the variants. Is it possible to configure the webhook to return the variant metafields?

2 Likes

any update on this? Having the same issue.

I believe I ended up just unfortunately making extra API calls to fetch the variant data.

We may have to do the same thing, unfortunately.

In the data Shopify sends, there is a key in each variant called
“metafields”, but it is always empty and there is absolutely nothing in the
docs about that.

Can someone from Shopify team reply please?

Hi, sorry to side track,

but how did you manage to trigger the product/update webhook when updating a variant’s metafield?

I was able to trigger for product level metafield but not variant level metafield. Appreciate any tips you could provide!

Hey guys! For anyone looking at this in the present day, I figured it out for me - if you include the variant metafield namespace in your “metafieldNamespaces” array when making the webhook, those webhooks will turn up in “metafields” in “variants”. I tried subscribing with no metafieldNamespaces - nothing. I tried with the variant metafield namespace - voila.

Hi John, can you share the syntax please

Hey @internetperson1 , my request body ended up looking like this:

{
  query: '\n' +
    '    mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {\n' +
    '      webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {\n' +
    '        webhookSubscription {\n' +
    '    id\n' +
    '    endpoint\n' +
    '    callbackUrl\n' +
    '  }\n' +
    '        userErrors {\n' +
    '          field\n' +
    '          message\n' +
    '        }\n' +
    '      }\n' +
    '    }\n' +
    '  ',
  variables: {
    topic: 'PRODUCTS_UPDATE',
    webhookSubscription: {
      callbackUrl: 'https://etc.',
      format: 'JSON',
      includeFields: [ 'id', 'variants' ],
      metafieldNamespaces: [ 'loyalty' ]
    }
  }
}

to get variant metafield of variant.metafields.loyalty.points.

Here’s the query more readable, which is just passing in the variables:

mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {
  webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
    webhookSubscription {
      id
      endpoint
      callbackUrl
    }
    userErrors {
      field
      message
    }
  }
}

3 Likes

Hello, I don’t see this working, I created a new variant metafield with namespace as clay_rating please check the screenshot below

Then I updated the webhook subscription payload as below

{
“id”: “gid://shopify/WebhookSubscription/1316605689967”,
“webhookSubscription”: {
“callbackUrl”: “https://wh3fd05a0e7c2fd3d850.free.beeceptor.com”,
“includeFields”: [ “id”, “variants”],
“metafieldNamespaces”: [“clay_rating”]
}
}

I still did not receive webhook when the metafield value was updated, but when I update any other variant details like sku value etc then i receive the webhook.