A webhook is an action that runs when the application providing the webhook is notified. The webhook has a URL which can receive HTTP requests (usually POST). A request sent to this URL lets the application know that an event has happened and it may or may not contain a message.
For every site, Gatsby Cloud provides two webhooks:
- a Build Webhook which triggers a Deploy Build
- and a Preview Webhook which triggers a CMS Preview build
These webhooks can be found by going to Site Settings then clicking General > Webhook in the sidebar menu.
When you connect a content management system (CMS) to your site (manually or via Quick Connect), it uses these webhooks to trigger your builds.
You can use any tool (Postman, Zapier, etc.) to send a POST request to either of the webhooks. For example, here's the structure for a
curl request to some site's Preview Webhook:
curl -X POST https://webhook.gatsbyjs.com/hooks/data_source/<site id>
How Do You Know a Webhook Worked?
You can tell when a build is triggered via webhook by inspecting the build card. For example, a build triggered via the Build Webhook will say "Triggered by Gatsby Build Webhook."
However, if the build is triggered by one of the officially supported CMSs, the build card will indicate the name of the CMS that triggered it.