Webhooks allow you to execute your own business logic an event occurs. Read more about webhooks in Webhooks concepts.
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.
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.
First, inside of Netlify navigate to a site you’ve already imported.
Build and Deploy>
Add build hook, name it, and select which branch to deploy. In our case, we will be deploying the master.
Now inside of the GraphCMS web app, navigate to the webhooks tab
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.