Note: This page is no longer maintained, and the underlying code may be outdated or unsupported. It may be removed in a future release. To learn how to automate workflows in Contentstack, refer to the Connectors documentation.
In this document, we will learn how to create an entry automatically in a content type, whenever an entry is created or updated in some other content types.
In our example, we will assume that there are three content types named “Books,” “Videos,” and “All”. We will set up a system such that whenever an entry is created or updated, the webhook will invoke a Lambda function that will create or update the corresponding entry, respectively, in the “All” content type.
Having such a system in place immensely enhances search queries operations. So instead of performing different search queries on “Books” and “Videos,” you can simply perform such queries in a single REST API request in “All” content type.
Note: The schema or the structure for the three content types (Books, Videos, and All) should be same. While creating the “All” content type, make sure to add an extra single line field and name it “Entry UID”. It will store the UID of the entries created in “Books” and “Videos” and the field should be “unique” to be set in the properties.
This is how the structure of the Books content type should like:

Below is the structure of the Videos content type:

And below is the structure of the All content type:

If you notice that in the All content type, we have added an extra single line field as discussed in the above note.
Setting up an AWS Lambda Webhook Listener is a four-step procedure:
To get notified when the event is triggered, you need to create the AWS Lambda function as shown below:
Note: You can use any language instead of Node.js. You can also add triggers to your lambda to push an event when the lambda is invoked.
Note: You can either write your lambda code here. Another option is to write the lambda code on your machine and then load it in the code editor. The inline editor has the basic code written, you can replace it with your own code.
Note: If your region is Europe, then the baseUrl is https://eu-api.contentstack.com/. Similarly, for Azure NA, the baseUrl is https://azure-na-api.contentstack.com/, and for Azure EU, the baseUrl is https://azure-eu-api.contentstack.com/.
managementToken : <Enter your stack management token here>
Now that you have configured your lambda, let's move on and configure the AWS API Gateways.
For your Lambda to be accessible publicly through an HTTP POST, you need to configure the AWS API Gateway using your function as the backend for the API as shown below:
Note: The region into which your Lambda is deployed isn’t easily identifiable when you’re deploying your Lambda, so you might have to do a little hunting.
To make your API ready to use, you need to deploy your API.
Your API is now deployed and you will get a URL, which you can use to invoke the APIs.
Now to trigger the event on any update on the entry, you will have to set up a Webhook in Contentstack. To set up a Webhook, log in to your Contentstack account and perform the following steps:


Now try creating or updating an entry in Books or Videos content types. You should see the corresponding changes in the “All” content type.
Additional Resource: We have various guides that document how you can integrate webhooks with AWS Lambda. Refer our Webhook Integrations page for more details