Setting up Webhooks

What are Webhooks?

'Webhooks'

Webhooks allow you to execute your own business logic an event occurs. Read more about webhooks in Webhooks concepts.

What can you do with Webhooks?

The most common use case for webhooks is in the context of a CMS is to trigger a static site build. After content is updated, a build tool is notified and it triggers a new build of the website. But webhooks have endless possibilities. A webhook could update a calendar entry that new content is ready for review, could publish new content into the CMS itself, could update an external search index and many more possibilities.

Creating a Webhook

For this example, we will use the static site host, Netlify as an example of a webhook triggering a static site build.

Please note that webhooks in GraphCMS are currently global, meaning that any Create, Read, Edit, Delete (CRUD) operation will trigger a build.

3rd party destination

'Build Hook Netlify'

First, inside of Netlify navigate to a site you’ve already imported.

  • Then Settings > Build and Deploy > Continuous Development > Build Hooks.
  • Click on Add build hook, name it, and select which branch to deploy. In our case, we will be deploying the master.

Inside of GraphCMS

'Build Hook Netlify'

Now inside of the GraphCMS web app, navigate to the webhooks tab

  • Click Create
  • Add a memorable name and description of your choice
  • Enter your build hook URL from Netlify
  • Note that the Headers: Section with Key and Value is optional and not needed for this configuration of webhooks. If you are working with authenticated APIs, this is where you would add that data.

Although Webhooks are global now, we are currently working on granularly triggered Webhooks. Stay up to date on the status of this on our Feedback Board.