App reviews, troubleshooting, and recommendations
I have integrated shopify with my app using the rest api and I have also configured webhooks so anytime an action is done i get events,Awesome.. Now I want to identify what triggered the webhook, is it the api or from the store client itself.. If its the api I want to return 200 immediately.. How do I detect webhook events triggered by my api?? Please any help will be highly appreciated.. Thanks
You can identify what triggered the webhook by including a unique identifier in the metadata of the objects you manipulate via the REST API. When you receive a webhook event, you can check the metadata to determine if it was triggered by your app or by another source.
When creating or updating a resource (e.g., an order or a product) using the REST API, include a custom metadata field that contains a unique identifier for your app. For example:
{
"product": {
"title": "My Product",
"metafields": [
{
"key": "app_id",
"value": "your_unique_app_id",
"value_type": "string",
"namespace": "your_app_namespace"
}
]
}
}
When your app receives a webhook event, check the metadata of the resource included in the webhook payload. If the `app_id` metadata field matches your app's unique identifier, this means the webhook was triggered by your app.
Based on the metadata check, you can decide whether to return a 200 status code immediately or process the webhook event as needed.
Keep in mind that not all webhook events include the entire resource data in their payload. In some cases, you may need to make an additional API call to fetch the resource and its metadata to determine if your app triggered the webhook event.
I hope this helps.
Thanks for replying but this solution can't help me because there are some endpoint like making a put or delete request i can't attach a metafield .. What do you think is the best.. Shouldnt be a header to indicate if I want a webhook triggered for this request or webhook header to detect if the webhook was triggered by my api.. Thanks
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025