# Introducing Deploy Hooks

**Published:** July 30, 2019 | **Authors:** Javi Velasco, Sarup Banskota | **Category:** Company News

*Trigger new deployments using any external event\.*

---

Thanks to our first-class [GitHub](https://zeit.co/github) and [GitLab](https://zeit.co/gitlab) Integrations, you can simply push your code to deploy with [Vercel](https://zeit.co/home). But what if you wanted to create a deployment not based on change of source code, but another external event, such as an update in CMS content?

Starting today, you can **deploy based on *****any***** event with Deploy Hooks.**

![An illustration of a Vercel Deploy Hook set on Contentful. The Deploy Hook ensures a build and deployment each time content is updated.](//images.ctfassets.net/e5382hct74si/H1KCy7NQXghHzEU971iL8/ba0fa922484b06b27cffcb7f921b0cc1/magnifying-glass-03.png)

## What is a Deploy Hook?

A Deploy Hook is a URL that accepts POST requests to trigger deployments with Vercel.

Any platform that can make POST requests can trigger Deploy Hooks — this includes third-party services such as headless CMSes, cron utilities, and even your command line.

## Static Example: Gatsby + Contentful

In order to illustrate Deploy Hooks, we consider the popular pairing of a [Gatsby](https://gatsbyjs.org)-powered static site, backed by content on [Contentful](https://contentful.com). Let's set it up so that the static site automatically builds and deploys each time content is updated.

**1. Set up Boilerplate**

Luckily for us, the Contentful community already has a [Gatsby + Contentful](https://github.com/contentful-userland/gatsby-contentful-starter) boilerplate available.

```bash
gatsby new contentful-starter https://github.com/contentful-userland/gatsby-contentful-starter
```

**2. Sign up for Contentful and Obtain Tokens**

Once signed up, we run the `setup` script highlighted on [Contentful](https://contentful.com)'s onboarding page.

![`npm run setup` takes care of setting up the environment variables that Gatsby needs from Contentful.](//images.ctfassets.net/e5382hct74si/3OVDMiLqgK4sfQBXz8Zrw8/9c98086f2570b2ca14099a38f103fc4e/image-02.png)

Next, we set the `CONTENTFUL_SPACE_ID` and `CONTENTFUL_ACCESS_TOKEN` [environment variables](https://zeit.co/docs/v2/build-step#using-environment-variables-and-secrets).

**4. Create Deploy Hook and Specify on Contentful**

We want our Gatsby site to re-build and deploy whenever there is an update in Contentful. Therefore, we create a Deploy Hook pointing to the git `master` branch, and specify the Deploy Hook as a **webhook** within Contentful.

It's easy to create a Deploy Hook for any Vercel project — the [docs](https://zeit.co/docs/v2/advanced/deploy-hooks/) visually explain how.

![Once the webhook is created, our setup is complete.](//images.ctfassets.net/e5382hct74si/1WRiPauiTuZDreD0r90BdY/bf0059047bbbd8ca1619277f8c02562d/add-webhook.png)

## Trying it Out!

When we update content via Contentful, a new static Gatsby build is created. After a brief wait, our site is deployed and the updated content is live for us to see!

[Video: Configuring Vercel Deploy Hooks inside Contentful](//videos.ctfassets.net/e5382hct74si/76p4Jmizbe9gzitt2N7I74/d1bbfbed90e66b16141d5cac35dc8f54/hooks-video.mp4)

## Reliability and Robustness

In order to create a robust system, we have kept several checks in place:

- **Automatically debounced builds**. You can POST to the Deploy Hook multiple times, and our systems will intelligently discard duplicate deployments.

- **Straightforward revoking**. If you suspect that you may have accidentally leaked your Deploy Hook, you can easily swap the existing hook for a new one within your project settings.

- **Clear timeline of deployment activity**. Under the [Events](https://zeit.co/dashboard/events) tab, you can clearly identify deployments created via hooks.

![The Events timeline clearly showcases all the deployments, including their sources.](//images.ctfassets.net/e5382hct74si/7swmzM4otSXy0Ymrq5jqfn/7a942755f9d15a8062f9f18f3d64ecc5/magnifying-glass-02.png)

## Conclusion

With Deploy Hooks, you can now deploy based on *any* event.

In this post, we explored how Deploy Hooks can help you **automatically re-build and deploy** a static site based on content updates.

How do you intend on using Deploy Hooks? Let us know via [Twitter](https://twitter.com/vercel) or [Chat](https://zeit.co/contact)!

---

**More posts:** [View all blog posts](https://vercel.com/blog/sitemap.md) | [Changelog](https://vercel.com/changelog/sitemap.md)