GROQ-powered webhooks
Webhooks now support version documents
v2025-02-19
You can now run webhooks on version documents. Previously, using sanity.io/manage or the webhooks API, webhooks could be configured to trigger on changes to published or draft documents.
Now, versions from Content Releases can also utilize webhooks. To take advantage of this today, enable the "Trigger webhook when versions are modified" checkbox in sanity.io/manage.
For API users, set the includeAllVersions
property to true
.
Gotcha
As with drafts, running webhooks on version updates can result in rapid requests. The same considerations apply to versions as they do in drafts. Learn more in the GROQ-powered webhooks documentation.
New GROQ-Powered Webhooks
v2021-10-04
A complete revamp of the webhooks API, which allows for sophisticated webhook configuration using GROQ. Read more in the docs, or read the announcement blog post.
Migrating the legacy webhook behavior to GROQ-powered Webhooks
If you need to recreate the previous webhook behavior – triggering on all changes, and on a dataset level rather than document-level – you can do so by following these steps:
- Create a webhook set to trigger on create, update and delete
- Leave the Filter field empty
- Add the following to the Projection field
// 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
]
}
}
You can also click this link to get a template with the settings described above.
Other improvements
In addition to the filter and projection functionality, we’ve made a bunch of other improvements as well:
- There’s a new UI for webhooks in the management interface and a full RESTful API
- Webhooks can now be edited after you have created them
- You can enable and disable webhooks
- Webhook entries contain more metadata, including name, description, and more
- You can add custom headers, and specify its HTTP method
- There’s a new attempts log that makes troubleshooting and testing easier
- Webhooks support a secret that will be hashed in the request which you can use to authenticate that the request originates from your project
- We include idempotency keys in the headers, which you can use when syncing data to verify you haven’t received it before
- Webhook configurations can be shared via URL
- Webhooks are now guaranteed to include the content changes that caused them
- Webhooks will now be retried (and are also rate-limited to 60 per second)
- We also added a `sanity` namespace to GROQ that can be used in projections