# Trigger builds with webhooks

Use Hygraph webhooks to start a new build on Vercel, Netlify, or any hosting platform that provides a build hook URL whenever your content changes.

Use a webhook to start a new build of your site whenever content changes in Hygraph. Without one, publishing content in Hygraph does not update your deployed site, which continues to show the version built at the last deployment.

This works with any hosting platform that gives you a build hook or deploy hook URL. If you use Vercel or Netlify, you can also use the [Vercel integration](https://hygraph.com/docs/integrations/connect-vercel) or the [Netlify integration](https://hygraph.com/docs/integrations/connect-netlify) instead.

**Warning:**

**Webhooks are environment specific**. This means their configuration is applied per environment. Take this into consideration if you're working with a project using more than one environment.

## 1. Get a build hook URL

Before you configure the webhook in Hygraph, generate a build hook URL on your hosting platform. Hygraph sends a request to this URL whenever the webhook fires.

### Vercel

1. Go to your project in Vercel and navigate to **Settings > Git > Deploy Hooks**.
2. Enter a name for the hook, for example `Deploy from Hygraph`. The name is only a reference for you.
3. Enter the Git branch you want to deploy, for example `main`.
4. Click **Create Hook**.

    ![Vercel Deploy Hooks form](https://hygraph.com/images/docs/developer-guides/project-guides/webhooks/vercel-deploy-hooks-form.png)

5. Copy the generated URL.

    ![Vercel deploy hook URL](https://hygraph.com/images/docs/developer-guides/project-guides/webhooks/vercel-deploy-hook-url.png)

### 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 a name, for example `Deploy from Hygraph`.
3. In the **Branch to build** dropdown, select the branch you want to build, for example `main`.
4. Click **Save**.
5. Copy the generated URL.

### Other platforms

Check your hosting platform's documentation for how to create a build hook or deploy hook. You need a URL that starts a new build of your site when it receives a request.

Webhook URLs in Hygraph must start with `https://`.

**Warning:**

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

## 2. Configure the webhook in Hygraph

1. Navigate to **Project Settings > Automation > Webhooks** in your Hygraph project.
2. Click **Add webhook**.
3. Enter a **Name** for your webhook, and paste the build hook URL into the **URL** field. Set **Method** to **POST**. You can turn off **Include payload**, because build hooks don't use it.

    ![Hygraph webhook configuration](https://hygraph.com/images/docs/developer-guides/project-guides/webhooks/webhook-config.png)

4. Under **Triggers**, choose what starts a build. Selecting none in a field acts as a wildcard.

    - **Content Model**: The content models that trigger this webhook. If you don't select any, every content model triggers it.
    - **Stage**: The content stage to watch. For example, select `Published` so that a build only starts when content is published, and not when someone saves a draft. To build a staging site from the `Draft` stage, create a separate project on your hosting platform connected to the same repository, and repeat step 1 for it.
    - **Action**: The actions that trigger the webhook. Leave this empty to start a build whenever content is published or unpublished.
    - **Source**: Which source of changes triggers the webhook: a Permanent Auth Token, a project member editing content in Studio, or the Public API. Leave this empty to start a build whenever content changes, whatever the source.

    ![Hygraph webhook triggers](https://hygraph.com/images/docs/developer-guides/project-guides/webhooks/webhook-triggers.png)

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

For a description of every webhook setting, see [Automate with webhooks](https://hygraph.com/docs/developer-guides/webhooks/webhooks-overview).

## 3. Publish content and check the build

1. Open a content entry that matches your triggers, make a change, and click **Save & Publish**.
2. Check your hosting platform for a new build:
    - **Vercel**: Navigate to **Deployments** in your Vercel project.
    - **Netlify**: Navigate to **Deploys** in your Netlify site.

If no build starts, check the following:

- The webhook URL matches the build hook URL exactly, with no trailing spaces or missing characters.
- The content entry you published belongs to a content model you selected in the triggers.
- The entry moved to the stage you selected. For example, if you selected `Published`, saving an entry does not trigger the webhook.
