# Lesson 9.1 - Configure webhooks

Create a webhook in Hygraph that triggers a new storefront build on Netlify or Vercel whenever content is published.

In this lesson, you will configure a webhook that triggers a new deployment whenever a product entry is published in Hygraph. Without this, publishing content in Hygraph does not update the live storefront and the deployed site continues to show the version built at the last deployment.

## Generate a build hook

Before configuring the webhook in Hygraph, generate a build hook URL on your deployment platform. Hygraph will send a POST request to this URL whenever the webhook fires.

### Netlify

1. Go to your site in Netlify and navigate to **Project configuration > Build & deploy > Continuous deployment > Build hooks**.
2. In the **Build hook name** field, enter `Deploy from Hygraph`.
3. In the **Branch to build** dropdown, select `main`.
4. Click **Save**.
5. Copy the generated URL.

### Vercel

1. Go to your project in Vercel and navigate to **Settings > Git > Deploy Hooks**.
2. In the hook name field, enter `Deploy from Hygraph`.
3. In the branch field, enter `main`.
4. Click **Create Hook**.
5. Copy the generated URL.

## Configure the webhook in Hygraph

1. Navigate to **Project Settings > Automation > Webhooks** in your Hygraph project.
2. Click **Add webhook**.
3. Fill in the following information:

    | Field | Input |
    |---|---|
    | Name | Deploy to Storefront |
    | Description | Trigger published |
    | Include payload | You can turn this off. Build hooks don't use the payload. |
    | Method | POST |
    | URL | Paste the build hook URL copied from Netlify or Vercel |
    | Secret key | Leave blank |
    | Headers | Leave blank |

    **Keep the build hook URL private.** Build hook URLs don't require any authentication, so anyone with the URL can trigger a deployment. If the URL is exposed, revoke or delete it on your deployment platform and create a new one.

4. Under **Triggers**, configure the following:

    | Field | Input |
    |---|---|
    | Content model | Product |
    | Stage | PUBLISHED |
    | Actions | Leave empty |
    | Sources | Leave empty |

    You need to select the `Product` model because product content is what the storefront displays. Selecting `PUBLISHED` means the webhook only fires when content is published, and saving a content entry does not trigger a deployment. Leaving `Actions` and `Sources` empty acts as a wildcard: all publish actions from all sources trigger the webhook.

5. Click **Add webhook** to save.

Publishing any `Product` entry in Hygraph automatically triggers a new storefront deployment.

## Verify the webhook

To verify the webhook is working, publish a content entry and confirm a new build starts on your deployment platform.

1. Navigate to **Content** and open any `Product` entry.
2. Modify the product entry, for example, edit the product description.
3. Click **Save & Publish**.
4. Check your deployment platform for a new build.
    - **Netlify**: Navigate to **Deploys** in your Netlify site and check if a new build appears at the top of the list, triggered by the webhook.
    - **Vercel**: Navigate to **Deployments** in your Vercel project and check if a new deployment appears, triggered by the webhook.

If no build starts, check the following:
- The webhook URL matches the build hook URL exactly. There should be no trailing spaces or missing characters.
- The content entry you published belongs to the **Product** model. The trigger is scoped to Product only.
- The entry moved to the `PUBLISHED` stage. Saving an entry does not trigger the webhook.

## What's next

[Go to the wrap-up](https://hygraph.com/docs/getting-started/tutorial/tutorial-wrap-up)

Or, go to the [Tutorial overview](https://hygraph.com/docs/getting-started/tutorial/tutorial-overview) for the full lesson list.
