Skip to Content

Webhook

In this part we will configure sanity webhook. Without enabling webhook you have to build your site everytime you create or update a blog post.

To configure webhook follow these steps below:

  1. Go to the API tab in your Sanity project and navigate to Webhooks
  2. Click the “Create webhook” button
  3. Set the Name & Description
  4. Set the URL to https://yoursite.com/api/webhook/sanity 
  5. Choose Dataset to “production” or choose the one you prefer.
  6. Set the following options as shown below.
    • Trigger on: “Create”, “Update”, and “Delete”

    • Set Filter: _type == “post” (or your custom post type name)

    • Projection: Leave empty

    • Status: Keep it enabled

    • HTTP method: POST

    • HTTP Headers: Leave empty

    • Include drafts: No

    • Secret: Add random value and copy it.

Update the webhook env variable with the webhook secret.

SANITY_WEBHOOK_SECRET=YOUR_WEBHOOK_SECRET

Now, Save the configuration and create a webhook

Last updated on