> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sheetdb

## Introduction

[Sheetdb](https://sheetsu.com/) turns a Google Spreadsheet into a JSON API. It allows you to connect your sheets to CRM, API, Website, any application or tool.

## MoEngage and Sheetdb

The MoEngage and Sheetdb integration allows you to read and write data to your Google spreadsheet.

## Use cases

1. You have a spreadsheet with different campaign messages for different users with slight tweaks. You can want to send the exact message (from this spreadsheet) to your users. Using the integration, you can reference the spreadsheet from the MoEngage campaigns to send right messages to your users.
2. You have some attributes that are very specific to a campaign that needs to be sent out. This is just a one-time campaign, so you don't want to store these details on MoEngage. You can simply add these attributes to a Google spreadsheet. Now reference the sheet using MoEngage Content APIs.
3. You want to keep updating (in near real time) a spreadsheet to keep track of users who perform a specific action on MoEngage. Using the integration, you can set up your Sheetdb spreadsheet endpoints in a MoEngage Connector Campaign.

## Integration

<Info>
  **Prerequisites**

  * Ensure you have access to your Sheetdb account.
</Info>

Using the integration, you can:

1. Fetch details from a spreadsheet at the run time and use them in your MoEngage campaigns using Content APIs.
2. Update a spreadsheet in near real-time with the details for a specific user segment or as soon as the user performs a specific event.

### A) Use data from a spreadsheet in MoEngage campaigns

Let's say your file has detail on the Message title, message and button name for your users.

<img src="https://mintcdn.com/moengage/syqICryKE0qygh49/images/partner_21979659923732.png?fit=max&auto=format&n=syqICryKE0qygh49&q=85&s=ab0f62df2636accf528aa27ef221275b" alt="Sample spreadsheet with message title, message, and button name columns" width="956" height="182" data-path="images/partner_21979659923732.png" />

In this example, we are using ID to search users. You can use any other attribute such as email id or mobile number to identify a user.

#### Step 1: Upload a sheet on Sheetdb

On your Sheetdb dashboard homepage:

1. Click *Create new* on top right.
   <img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401327382036.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=7270638e0189641cad2dab33264f1462" alt="Create new button on the Sheetdb dashboard" width="2626" height="706" data-path="images/partner_7401327382036.png" />
2. Add your spreadsheet URL.
   <img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401381763220.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=14adddbc1d32e8f190ffae7043b45e39" alt="Adding a spreadsheet URL in Sheetdb" width="2546" height="590" data-path="images/partner_7401381763220.png" />
3. Click *Create API*.
4. You can now test if your API is working fine by clicking on *Go to API URL*.
   <img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401397437204.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=78d66cecfe5c4ccdc50ef3578d75b577" alt="Testing the Sheetdb API by clicking Go to API URL" width="2492" height="526" data-path="images/partner_7401397437204.png" />
5. Copy your sheets API URL. It should look like this:
   ```text theme={null}
   https://sheetdb.io/api/v1/2ru3wpxjfdc2s
   ```

#### Step 2: Add Sheetdb as Content API on MoEngage

Perform the following steps:

1. Navigate to **Settings** > **Advanced settings** > **Content API**. Click **+ Add content API** at the top right corner of the Content API screen.
   <img src="https://mintcdn.com/moengage/syqICryKE0qygh49/images/partner_21979659930388.png?fit=max&auto=format&n=syqICryKE0qygh49&q=85&s=39e66ee233a3277e3716f5d592818f58" alt="Adding a Content API from the Advanced settings page" width="2706" height="1344" data-path="images/partner_21979659930388.png" />
2. Add your Sheetdb name and API URL.
   <img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401438488980.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=b8c30365d16741a27903b80723c6630d" alt="Configuring Sheetdb name and API URL as a Content API" width="1448" height="982" data-path="images/partner_7401438488980.png" />
   **API URL**
   Enter the following URL. Please note that *your Sheetdb API URL* should be the same as copied from the previous step.
   ```text wrap theme={null}
   https://sheetdb.io/apis/v1/<your sheetdb API url>/search?ID={{UserAttribute['ID']}}
   ```
3. Click Save. You will see your Sheetdb API added in MoEngage.
   <img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401480179732.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=3ee61353d1f25bb26adc1624003ea809" alt="Sheetdb API listed in MoEngage Content APIs" width="2266" height="684" data-path="images/partner_7401480179732.png" />

You can also test your APIs. Provide a sample ID and click Test. You can view the API response and validate.

<img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401479515924.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=ce06e49e1ac5f846fd3cd84ac6d6d3a9" alt="Testing the Sheetdb Content API with a sample ID" width="1400" height="1194" data-path="images/partner_7401479515924.png" />

#### Step 3: Use Content API's data in MoEngage campaigns

You can now use these content APIs in your campaigns. [Read here](https://www.moengage.com/docs/user-guide/campaigns-and-channels/getting-started/campaign-content/content-apis) to know more about Content APIs.

1. On step 2 on your campaign creation, enter @.
2. In the pop up, you can select the Sheetdb Content API configured in Step 2.
   <img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401483557652.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=56e7488af8ad64b2a24ab70cb8be7880" alt="Selecting the Sheetdb Content API while creating a campaign" width="1388" height="1162" data-path="images/partner_7401483557652.png" />
3. Click done to include the response in your campaigns.
4. You can use MoEngage templating language to parse through the API response and use the content in your campaigns.

### B) Write data to spreadsheet using MoEngage Connectors

#### Step 1: Upload a sheet on Sheetdb

Make your sheet available for Sheetdb APIs. You can follow the same steps as in A. Step 1 in the previous example.

#### Step 2: Add your Sheetdb endpoint in MoEngage Connector Campaigns

To create a connector campaign on MoEngage:

1. Navigate to Create Campaign > Connectors > Custom and choose delivery type most suitable to your needs.
   <img src="https://mintcdn.com/moengage/7iGV38YjgdBKSU0B/images/partner_21979659934356.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=92d7ac89028923921eba5eb340d1fda9" alt="Selecting Custom connector and delivery type in MoEngage" width="1104" height="1238" data-path="images/partner_21979659934356.png" />
2. On step 2 of the campaign:
   * Select method as `POST`.
   * Add Webhook URL as:
     ```text theme={null}
     https://sheetdb.io/apis/v1/<your sheetdb API URL>
     ```
     <img src="https://mintcdn.com/moengage/skVB8Wto_b8UCyhm/images/partner_7401499731732.png?fit=max&auto=format&n=skVB8Wto_b8UCyhm&q=85&s=aa85d6e8988a4d2f3090137f992ca29d" alt="Connector campaign webhook configuration for Sheetdb" width="2166" height="1260" data-path="images/partner_7401499731732.png" />
   * In Body, define the keys in your spreadsheet and the values that you want to send out.
3. At this point, your campaign should be ready to test and send. You can also test your connector configuration using the Test functionality available on Step 2 of Create Connector Campaign.
   <img src="https://mintcdn.com/moengage/7iGV38YjgdBKSU0B/images/partner_21979691834388.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=3f73ea8d4a1f5c54e09d1a9890665fe3" alt="Testing the Connector Campaign configuration before publishing" width="2464" height="270" data-path="images/partner_21979691834388.png" />

If the data is updated successfully on your spreadsheet, your set-up is good to go. You can go ahead and Publish the campaign.
