Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 812 Bytes

include-type-of-operation-in-webhook-response.md

File metadata and controls

26 lines (20 loc) · 812 Bytes

Include Type Of Operation In Webhook Response

When setting up a webhook in Sanity Studio, you can specify what types of operations you want to trigger the webhook: create, update, and delete.

If you include all three for a webhook, then you'll probably want to know in your webhook handler which type of operation you're receiving.

Webhooks are run in Delta Mode which means that a collection of GROQ functions are available in the filter and projection blocks. These functions include delta::operation.

Here is what a projection using delta::operation might look like:

{
  _id,
  firstName,
  lastName,
  email,
  'operation': delta::operation()
}

This function can resolve to either create, update, or delete.