Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

How to identify the author of a change in Sanity using GROQ-powered webhooks.

2 replies
Last updated: Sep 12, 2023
Hi,In the GROQ-powered Webhooks, I need to know who made the change in Sanity that triggered the webhook.

Legacy webhook used to provide transaction id, from which I used to fetch transaction details which had author information.

The migration guide indicates that transaction id is not supported in the new groq powered webhooks.

https://www.sanity.io/help/6816a33e-f07d-4fdf-ad29-14c6337e19e3
// webhook projection
{
  "transactionId": "Not supported",
  "projectId": sanity::projectId(),
  "dataset": sanity::dataset(),
  "ids": {
    "created": [
    	select(before() == null && after() != null => _id)
    ],
    "deleted": [
      select(before() != null && after() == null => _id)
    ],
    "updated": [
      select(before() != null && after() != null => _id)
    ],
    "all": [
      _id
    ]
  }
}
Any way to know the author?

Purpose to know this is to identify which webhook trigger came from a change done by user on sanity studio, and which one came from change done by my own robot script. I need to differentiate for processing only user initiated changes, as my robot script has already done the changes needed and need to avoid calling it again.

Thanks.
Sep 12, 2023, 2:56 AM
Can you try the identity() function? I believe that should work, even from within a webhook.
Sep 12, 2023, 4:59 AM
amazing, it worked beautifully! thank you Geoff!
Sep 12, 2023, 5:14 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?