Including metafields in webhooks using toml file

Hey,

I would really love to receive app metafields in webhooks. I am subscribed to a PRODUCTS_CREATE and PRODUCTS_UPDATE webhook using the shopify.app.toml file like this:

[[webhooks.subscriptions]]
topics = [ “products/update” ]
uri = “/webhooks/products_update”
include_fields = [ “admin_graphql_api_id”, … ]

Currently, I’m fetching the metafields as the webhooks come in, but when I get spammed with a bunch of webhooks, the server gets overwhelmed. I could easiliy get rid of that unnecessary API request for metafields by adding a field in toml if it was possible.

From docs I see that it is possible to filter webhooks by app metafields:

But I see no mention of this for payloads.

I did however find this doc that says we can’t add metafield namespaces:

I see that multiple people have pointed out this lack of metafields in webhooks and would like to easily add them: Get webhook with metafields using shopify.app.toml

I know I could just use GraphQL to subscribe to webhooks, but that seems like unnecessary hassle and keeping track of those per store.

Thank you :slight_smile:

Hey @Rolands_Kundzins - thanks for reaching out. You’re correct that it’s not currently possible to include metafield values in webhook payloads configured through the toml file. The include_fields option only supports top-level fields from the webhook payload itself, and metafields aren’t part of that surface right now.

The metafield-based filtering you found in the docs is specifically for controlling which webhooks fire (based on metafield values), not for including metafield data in the payload itself.

Just so I can better understand your use case here, is the main concern the server load from having to make a separate API call per shop or were there other concerns you had (like high volume usage bursts or multiple webhooks needing API subscription calls per shop)? Just want to make sure I’m capturing the full picture.

Either way, I’m happy to look into this on our end and at the very least put through a feature request for you. Can’t guarantee anything in terms of if/when a change would be released, but I want to make sure your feedback is documented.

Let me know if I can clarify anything on our end here!

Hey @Alan_G ,

Thanks for the thorough and quick response.
You got the right idea there, I would like to get metafield values in webhook payload.

Let me expand.
So, currently I’m subscribed only to app-specific webhooks with the toml file as per the toml example I gave in the previous msg. I have no store-specific webhooks as those require a bit more setup, that I think could be avoided.

When the Product update webhook (app-specific) comes in:

  1. I check if the product contains images that were created by my app (image filename includes a specific string, for example “abc”).
  2. And I make an GraphQL API request to get the product metafield that is related to my app “hasImagesFromApp”.
  3. If the value in step1 differs from step2, I make GraphQL API request to update the metafield

And I use the “hasImagesFromApp” metafield for filtering products later with graphQL requests.
So, ideally, if I could get rid of the 2nd step (getting metafield value), my app wouldn’t need to make any extra API requests unless an update to metafield value is needed. This would be especially helpful as there are times where a burst of thousands of webhooks come in a short time span.
And to add, I decided not to just set this metafield “hasImagesFromApp" at time of my app adding the images to product, as these images could be reused for other products and I want to keep track of those changes via webhooks (especially when removing images).

Yep, I figured that filtering by metafields isn’t directly related, but it could hint that it might be possible to add metafields in the payload for app-specific webhooks in the TOML file as a feature request. :wink:
If you could open this as a feature request, that would be awesome. BTW, what is like the very approximate timeline on your end for features like this?

Thanks, have a great weekend!