How to create webhook only for a specific content type?

I am using Strapi 4.12.0

I can create fine Webhooks via both admin ui and now via code provisioning (will make pr contribute to Strapi in github with ts types as well).

My problem is that I want to specify notify me about entity.create ONLY FOR ENTITY of type page
I cannot find a way to do this right now.

I get notified for all entities, category, page, tag etc etc.

It is true that I can filter myself in the receiver webhook but we need a way to avoid sending useless webhooks for things that we are not interested.

The Webhook will work globally but you can filter it out to work only for specific content type from Request data using ctx.request.body.model will return the model name from where you have performed any action in the Strapi admin.

Eg: If you want your webhook to work only for Page content type

function webhook(ctx) {
  if(ctx.request.body.model ===  'page') {
    // You logic
  }
}
1 Like

Hi Shehkhar thanks for the reply.
I am aware of this and have already mentioned in my question.

I am asking for some webhooks for example like Stripe payment systems in which you can specify in a granular way:
notify me about entity:update,publish,delete of type Page only.
That means that Strapi send event to this particular webhook only for the conditions above and not all the updates.
Or you can combine different combinations like: entity:update for Page, entity:delete for Category etc so to be able to customise while creating the webhook

The last point of yours is a good idea but I am not sure about customizing webhook creation for different combinations like you said. Currently the webooks in strapi only supports event trigger.

Ok I see. So then I will create a feature request in the github repository.

I would like your help also with another question of mine:

@Shekhar Can you please tell in which file, I can add this function

You can add this function in any of the Content type by creating a custom api endpoint.

Steps to create custom api can be found here