Contentstack for Developers
Webhooks
Contentstack's webhook system is a powerful tool that allows developers to automate the process of receiving real-time notifications of changes made to content within the CMS. A webhook is an HTTP callback that sends a notification to a specified URL whenever a specific event occurs. In the case of Contentstack, the event could be when content is created, updated, deleted, or published.
Developers can create webhooks in Contentstack and specify which events should trigger them. When an event occurs, Contentstack sends an HTTP POST request to the specified URL, containing information about the event and the associated content.
With this information, developers can automate processes such as updating search indexes, notifying team members of content changes, or triggering other third-party services. Additionally, Contentstack allows developers to set up conditional logic to filter webhooks based on specific criteria, such as content types, allowing for even more granular control over webhook behavior.
Exercise: Using a webhook to call an endpoint on the webhook.site service
Step 1: Go to webhook.site in your web browser.
Step 2: Click on the "Create a webhook" button on the top right corner of the webpage.
Step 3: In the "Create a new webhook" modal, you'll see a unique webhook URL that you can use to send HTTP requests. Copy this URL to your clipboard.
Step 4: Log in to your Contentstack account and go to the Settings section of your stack.
Step 5: Click on the "Webhooks" tab.

Step 6: Click on the "Add New Webhook" button.
Step 7: In the "Create Webhook" modal, enter a name for your webhook, such as "Webhook.site Test".
Step 8: In the "URL" field, paste the webhook URL that you copied from webhook.site in step 3.

Step 9: Under "Webhook Triggers", select "Publish" as the trigger event.

Step 10: Click on the "Save" button to save the webhook.
Step 11: Now, whenever you publish content in Contentstack, a webhook notification will be sent to the URL you specified in step 8.
Step 12: To test the webhook, publish a new piece of content in Contentstack.
Step 13: Return to webhook.site and click on the "Inspect" button next to the webhook that you just created. You should see the webhook notification data from Contentstack, including the published content.
Congratulations! You have successfully tested a Contentstack webhook using webhook.site. You can now use webhook.site to test your webhook implementations or receive webhook notifications from other services.