Contentful logo

Contentful Community

Trigger Webhook for Parent Content on Asset Change

Let’s say there is a User content model, and it has an image field which is asset. If a webhook is associated on save, publish and unpublish for User. Is it possible to trigger this webhook whenever an asset is updated for the user.

At the moment, If i update user, webhook is triggered but if I update asset. It does not.
Or do I have to create different webhooks to handle this scenario ?

Hi @a.noor I think the best way would be to trigger the webhook for the auto-save, whenever you link an asset to the entry. Then the associated webhook could parse the modified data and verify if a new asset has been added (or removed) and act accordingly.

In the scenario, where asset is already associated with entry and I update any attribute for asset like image itself. It just save the asset and does not unlink/link again with entry. In that scenario, there is no webhook for entry itself.

I understand. Then you are right, the webhook should be associated with the asset publish action. However it depends what you are trying to achieve.

I think the most common scenario would be to update the image in the associated entries. If so, maybe would be better to solve this on the application side, so to not serve the image directly from the entry data, but query the asset for the proper CDN url when the page is loaded.

1 Like

Hi. I have a similar problem.

//works fine
Page publish -> webhook triggered -> handler function pulls data from contentful using url , does some custom manipulation of the data -> stores in redis

//doesn’t work
Updates a nested module on the same page -> webhook triggered -> handler function doesn't know the url of the page The data available as the webhook payload is only child level and not parent level.

There is entity id available in the payload but it is not possible to map it to the page url/ entity id of page. Any pointers is appreciated.