Filter webhooks by custom type

Is it possible to filter a webhook by a custom type?

Also, is it possible to pass along the id/uid of the element that triggered the webhook in the first place?

I understand you can utilise date and time based predicates to obtain the last edited document at the time the hook was triggered. I guess I could do this, but then I would need to filter based on a custom type to see if a specific type of content was published. Seems like a long way around, so looking for a more direct path if there is one!

And is anyone using webhooks to trigger push notifications?
e.g. using a push notification custom type for the content, then triggering a hook upon publish or release, which would communicate with a push notification api.

Thanks!

Hi @tim, unfortunately it isn’t possible to filter a webhook by a given Custom Type, and the Webhooks do not specify what has changed, just that something has changed.

As you mentioned, you could do a query based on the Last Publication Date to see which documents have been changed or added recently. But unfortunately this won’t tell you if anything has been archived.

Another option is to keep a snapshot of your content. When you receive a webhook, query all your content and compare this to your snapshot to see what changed.

I think it could be interesting for the Webhooks to identify what changes have been made, so I’ll added another tick for this in our feature request tracker as a possible improvement for the future. And I will also let the @features-team know in case they have any follow-up questions for you.

Threads close after a period of inactivity. Flag this thread to re-open it and continue the conversation.

Anything new about this feature ? I have a usecase where I need to invalidate cached pages, so I need the custom type and the uid :frowning:.

1 Like

Hello @Marv

Welcome to the Prismic community and thanks for reaching out to us.

Unfortunately, there is no update. I don't have any ETA too. You can read complete detail in the article Webhooks.

Thanks,
Priyanka

Maybe you can trigger the webhook by hand and query the latest updated documents in your endpoint for now. Something like:

{
  _allDocuments(lastPublicationDate_after: "2022-04-29T08:00:00Z") {
    edges {
      node {
        __typename
        _meta {
          uid
        }
      }
    }
  }
}