---
title: "[How-to Guides and Knowledgebase articles] - Add Algolia Search to Contentstack-powered Websites using AWS Lambda"
description: Add Algolia Search to Contentstack-powered Websites using AWS Lambda.
url: https://www.contentstack.com/docs/developers/how-to-guides/add-algolia-search-to-contentstack-powered-websites-using-aws-lambda
product: Contentstack
doc_type: how-to-guide
audience:
  - developers
version: unknown
last_updated: 2026-03-25
---

# [How-to Guides and Knowledgebase articles] - Add Algolia Search to Contentstack-powered Websites using AWS Lambda

This page explains how to integrate Algolia search with a Contentstack-powered website using AWS Lambda, including setting up Algolia, creating a Lambda function, configuring API Gateway, and configuring Contentstack webhooks. It is intended for developers implementing search indexing and query capabilities and should be used when you want Contentstack publish/unpublish/delete events to update an Algolia index.

## Add Algolia Search to Contentstack-powered Websites using AWS Lambda

**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 use the [Algolia](/docs/developers/marketplace-apps/algolia) app, refer to the [Marketplace](/docs/developers/marketplace-apps) documentation.

Algolia is a search-as-a-service platform that lets you add powerful search capabilities to your Contentstack-powered websites. It allows businesses to display highly-relevant and accurate search results, thereby reducing dependencies on support and cut down costs.

Apart from providing powerful search capabilities, Algolia also helps in capturing important user behavior analytics such as links clicked, queries performed, and so on.

In this guide, we will discuss how to add Algolia Search to your Contentstack-powered website using AWS Lambda.

**Additional Resource:** We also have other documents that cover the integration of [Swiftype](/docs/developers/integrations/swiftype-search), [Elasticsearch](/docs/developers/how-to-guides/perform-indexing-using-elasticsearch-and-contentstack-webhooks#install-and-set-up-elasticsearch), and [Lucidworks](/docs/developers/how-to-guides/add-lucidworks-search-to-contentstack-powered-websites) with your Contentstack-powered website.

## Prerequisites

- Basic understanding of Node.js and Algolia
- [Contentstack](https://app.contentstack.com/#!/login) and [Algolia](https://www.algolia.com/users/sign_in) account
- [AWS account ](https://signin.aws.amazon.com/)and basic understanding of AWS Lambda

## Setting up the Search

To use Algolia with Contentstack, you need to follow the steps given below:

- [Create an account in Algolia](#create-an-account-in-algolia)
- [Create an AWS Lambda function](#create-an-aws-lambda-function)
- [Set up API gateway](#set-up-api-gateway)
- [Set up webhooks in Contentstack](#set-up-webhooks-in-contentstack)
- [Create and publish an entry](#create-and-publish-entry)

### Create an Account in Algolia

Algolia provides an interactive dashboard for managing searches and analytics. You can also manage indexes in your account. So whenever any content ([entries](/docs/content-managers/working-with-entries/about-entries) or [assets](/docs/content-managers/working-with-assets/about-assets)) is [published](/docs/content-managers/publish-content) or [unpublished](/docs/content-managers/working-with-entries/unpublish-an-entry) or deleted in Contentstack, the data object gets created or deleted, respectively, in your Algolia index.

So let's create an account in Algolia by using the following steps:

Log in to [Algolia](https://www.algolia.com/users/sign_in) and create your account.

**Note**: You get a 14-day trial account. You can upgrade your account by subscribing to any of the plans it offers

- After you log in to Algolia, Click on the **Overview **button in the left navigation.
- On your **Algolia dashboard** screen, scroll down to the **Top Indices** section and click on **See all. **Now on the **Indices **page click on **Create Index**.
- In the **Create index** model that opens, provide a name to your index inside the **Index name** field and click on **Create**. Make note of the index name that you just created, we will need it while creating the environment variables for our lambda function.**Note: **To publish content across different environments, you must create unique indices for each environment.
- Click on the **Settings** button in the left navigation bar, under **Team and Access **open **API Keys **option.
- On the** API Keys **page, you will get an** Application ID**, copy the Application ID and note it down you'll need it in the next step.
- Now, move to the **All API Keys** section and click on the **New API Key** button.
- A new window titled **Create API Key** will pop-up, select your** Index name** and add other suitable details. Under **ACL **option, select the set of operations you want your API key to be able to perform. Finally, click on the **Create** button.
- Click on the copy button and note down your **Admin API Key**. You'll need to provide the Admin API Key in your website configuration code, so make a note of these.

### Create an AWS Lambda Function

Create an AWS Lambda function that sends the data (received from Contentstack via [webhooks](/docs/developers/set-up-webhooks/about-webhooks)) to Algolia.

Login to your [AWS Management Console](https://aws.amazon.com/console/), select **Lambda **from the **Services** list.

- Click on the **Create Function** button, and then the **Author from Scratch** option.
- Provide a name to your lambda function inside the **Function name** field, select **Node.js 14.x** as your **Runtime** language, and click on the **Create function** button.
- You will get a success message on creation of the lambda function. For this exercise, we have created the sample code for the lambda functions. Contact our [Support](mailto:support@contentstack.com) team to get the code. Once you get the code, download and unzip it in your system.
- Then, fire up your terminal and move inside the project root directory that you just downloaded.
- Install the npm modules by using the following command:

```
npm install
```

- Now, run the following command to create a zip file:

```
npm run build
```

After running the above command, you'll get the **index.zip** folder. This is the zipped file that we will use in our lambda function.

**Note**: The npm build command we discussed above will work for Mac and Linux systems. If you are using Windows, the npm build command may not work. In that case, after installing the node modules, you will have to manually zip the code files and name it **index.zip** as shown in the following screenshot:

- Now go back to the AWS console and in the **Code source** section, click on the **Upload from** dropdown and select **.zip file**.
- In the **Upload a .zip file** modal, click on the **Upload** button, move to the folder where you have saved the compressed file, and select it. Then, click on **Save**.
- In the **Runtime settings** option, keep **Handler** as **index.handler**.
- Scroll up and select the **Configuration** tab.
- In **General Configuration**, the default **Timeout **is 3 sec. Change it to **30 sec**.
- Now, click on the **Environment Variable** option on the left and add the following variables inside it by clicking on **Edit** and then **Add environment variable**.

**ADMIN_API_KEY**: <<Your Algolia Admin API Key you generated in the above step>>  
**APPLICATION ID**: <<Your Algolia Application ID generated in the above step>>  
**INDEX_NAME**: <<The name of the Algolia index you created in the above step>>

- After adding these details, click on the **Save** button.

Now that you have configured your lambda, let's move on and configure the AWS API Gateways.

### Set up API Gateway

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. Follow the steps given below set up the API gateway.

Scroll up to the **Function overview** section and click on **+ Add trigger**.

- On the **Add trigger** screen, from the **Select a trigger** dropdown, select **API Gateway**.
- From the **API** dropdown, select **Create an API**. Then, select **REST API** inside the **API type** block, select **Open** from the **Security** dropdown. Your settings after performing the above steps should look similar to the following:
- Click on **Add** to save your settings.
- An API for your lambda function is now created. Inside the **Triggers** section, you will see the **Details** link. Click on it and you will find your API endpoint. Make a note of it as we will need it while setting up our webhook in Contentstack.

### Set up Webhooks in Contentstack

To create and set up a webhook in log in to your [Contentstack account](https://app.contentstack.com/#!/login) and perform the following steps:

Click the “Settings” icon on the left navigation panel and click on **Webhooks.** You can also use the shortcut keys “alt + W” for Windows OS users, and “option + W” for Mac OS users to access webhooks.

- On the **Webhook** page, click on **+ New Webhook**.
- On the **Create Webhook** page, fill up the **Name **field (for example: **Algolia**). In the **URL to notify** field, enter the URL that you generated when you deployed your APIs, in the previous step.
- Scroll down to the **Conditional View **section for creating a trigger for the webhook as shown below:
- Select the **Enable Webhook** checkbox option and **Save** your settings.

With this, we have set up the webhooks for triggering notifications. Let's move on to setting up Algolia.

### Create and Publish Entry

Now that the setup is ready, you can [publish an entry](https://www.contentstack.com/docs/content-managers/working-with-entries/publish-an-entry/) in Contentstack. Once the entry is published, go to the Algolia dashboard and scroll down to the **Top Indices **section.

- You will see that the index you specified in your configuration has your entry that you just published. In the search bar of your Algolia dashboard, you can search for any word of your entry and get the suitable results.
- Now, open your **Index **and click on **+ Add Query Parameter** button. In the **Advanced Search **window, add your desired **Tag filters**, **Facet filters** and **Numeric filters.**
We have added the following sample filters as shown below:
- Click on the **Apply **button. The filtered results can be seen with the respective attributes.

Additionally, you make search API requests from your website to your app server to perform search operations using the API gateway that you created in step 3.

## Common questions

1. **Is this guide still supported?**  
   This page is no longer maintained, and the underlying code may be outdated or unsupported.

2. **What triggers updates to Algolia from Contentstack?**  
   Contentstack events such as content being published, unpublished, or deleted trigger webhook notifications that send data to Algolia.

3. **What AWS services are used in this setup?**  
   AWS Lambda is used to process webhook payloads and AWS API Gateway is used to expose the Lambda function publicly through an HTTP POST.

4. **Which Algolia credentials are required for the Lambda environment variables?**  
   **ADMIN_API_KEY**, **APPLICATION ID**, and **INDEX_NAME** are required as environment variables.