# Sending Interactive Lists

🔒 WhatsApp 24-Hour Session Rule

> Before sending interactive lists, make sure the WhatsApp session with the user is **active**.
>
> **If the user has not messaged your business within the last 24 hours, WhatsApp requires the first message to be a&#x20;*****template message***.
>
> After the customer replies, the 24-hour session opens and you may send interactive lists using this API.\
> **For sandbox testing**, send your join code to the sandbox number to activate your session.\
> [Learn more](https://app.gitbook.com/o/rJyj7TfON4zeW56KoQjM/s/2JHt6V4YwZLX6ZUdLqMy/~/changes/87/guides/joincodes)

WhatsApp offers an API to send lists.

![](https://4060499158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2JHt6V4YwZLX6ZUdLqMy%2Fuploads%2FXux5hqtAJV8bGPAaVpQX%2FWhatsApp%20Image%202024-09-15%20at%2019.01.50.jpeg?alt=media\&token=b6e8c75a-290e-4d65-9845-e23343230dbb)![](https://4060499158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2JHt6V4YwZLX6ZUdLqMy%2Fuploads%2FxfrEfQ9UmeHfHY5be62n%2FWhatsApp%20Image%202024-09-15%20at%2019.01.39.jpeg?alt=media\&token=f1ace6f6-cb7d-417e-9289-efcd08411de0)&#x20;

<mark style="color:green;">`POST`</mark> [https://gateway.lipachat.com/api/v1/whatsapp/interactive](https://gateway.lipachat.com/api/v1/whatsapp/interactive/buttons)<mark style="color:blue;">/list</mark>

**Headers**

| Name         | Value                                                                          |
| ------------ | ------------------------------------------------------------------------------ |
| Content-Type | `application/json`                                                             |
| apiKey       | Get apiKey from App portal settings tab<https://app.lipachat.com/app/settings> |

**Body**

<table><thead><tr><th width="348">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>messageId</td><td>string</td><td>A unique identifier for the message. This will be used to track the message status and for deduplication purposes.</td></tr><tr><td>message</td><td>string</td><td>The message being sent.</td></tr><tr><td>from</td><td>string</td><td>Sandbox number +254110090747 or your own WABA phone number.</td></tr><tr><td>to</td><td>string</td><td>Receiver phone number. It should start with a country code.</td></tr><tr><td>buttons[0].sectionTitle</td><td>string</td><td></td></tr><tr><td>buttons[0].sectionItems[0].id</td><td>string</td><td>Unique identifier of button in your app. eg 1 or YES_BTN</td></tr><tr><td>buttons[0].sectionItems[0].title</td><td>string</td><td>Text to be displayed to user.</td></tr><tr><td>buttons[0].sectionItems[0].description</td><td>string</td><td>Optional description</td></tr></tbody></table>

{% hint style="info" %}
For interactive list messages, WhatsApp allows up to 10 sections, with a maximum of 10 rows across all sections combined.
{% endhint %}

{% tabs %}
{% tab title="Curl" %}

```sh
curl --location 'https://gateway.lipachat.com/api/v1/whatsapp/interactive/list' \
--header 'apiKey: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "headerText": "Welcome to Lipachat",
  "body": "Please choose a product you would like below",
  "buttonText": "Click Here",
  "buttons": [
    {
      "sectionTitle": "Airtime",
      "sectionItems": [
        {
          "id": "SAFARICOM_AIRTIME",
          "title": "Safaricom",
          "description": "mpesa network"
        },
        {
          "id": "AIRTEL_AIRTIME",
          "title": "Airtel",
          "description": "airtel money"
        }
      ]
    },
    {
      "sectionTitle": "Bill Payment",
      "sectionItems": [
        {
          "id": "KPLC",
          "title": "KPLC",
          "description": "electricity"
        },
        {
          "id": "NAIROBI_WATER",
          "title": "Nairobi Water",
          "description": "county gov water"
        }
      ]
    }
  ],
  "messageId": "ca739107-4b0d-4581-acb1-4c4af70555de",
  "to": "2547XXXX",
  "from": "254110090747"
}'
```

{% endtab %}

{% tab title="Java" %}

```java
// Create an instance of OkHttpClient
OkHttpClient client = new OkHttpClient().newBuilder()
    .build();

// Define the media type for the request
MediaType mediaType = MediaType.parse("application/json");

// Create the request body with the necessary JSON payload using a text block
RequestBody body = RequestBody.create(mediaType, """
{
  "headerText": "Welcome to Lipachat",
  "body": "Please choose a product you would like below",
  "buttonText": "Click Here",
  "buttons": [
    {
      "sectionTitle": "Airtime",
      "sectionItems": [
        {
          "id": "SAFARICOM_AIRTIME",
          "title": "Safaricom",
          "description": "mpesa network"
        },
        {
          "id": "AIRTEL_AIRTIME",
          "title": "Airtel",
          "description": "airtel money"
        }
      ]
    },
    {
      "sectionTitle": "Bill Payment",
      "sectionItems": [
        {
          "id": "KPLC",
          "title": "KPLC",
          "description": "electricity"
        },
        {
          "id": "NAIROBI_WATER",
          "title": "Nairobi Water",
          "description": "county gov water"
        }
      ]
    }
  ],
  "messageId": "ca739107-4b0d-4581-acb1-4c4af70555de",
  "to": "254XXXXX",
  "from": "254110090747"
}
""");

// Build the request with the required headers
Request request = new Request.Builder()
    .url("https://gateway.lipachat.com/api/v1/whatsapp/interactive/list")
    .method("POST", body)
    .addHeader("apiKey", "YOUR_API_KEY")
    .addHeader("Content-Type", "application/json")
    .build();

// Execute the request and get the response
Response response = client.newCall(request).execute();



```

{% endtab %}

{% tab title="Javascript" %}

```ruby
const axios = require('axios');
let data = JSON.stringify({
  "headerText": "Welcome to Lipachat",
  "body": "Please choose a product you would like below",
  "buttonText": "Click Here",
  "buttons": [
    {
      "sectionTitle": "Airtime",
      "sectionItems": [
        {
          "id": "SAFARICOM_AIRTIME",
          "title": "Safaricom",
          "description": "mpesa network"
        },
        {
          "id": "AIRTEL_AIRTIME",
          "title": "Airtel",
          "description": "airtel money"
        }
      ]
    },
    {
      "sectionTitle": "Bill Payment",
      "sectionItems": [
        {
          "id": "KPLC",
          "title": "KPLC",
          "description": "electricity"
        },
        {
          "id": "NAIROBI_WATER",
          "title": "Nairobi Water",
          "description": "county gov water"
        }
      ]
    }
  ],
  "messageId": "ca739107-4b0d-4581-acb1-4c4af70555de",
  "to": "254XXXXX",
  "from": "254110090747"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://gateway.lipachat.com/api/v1/whatsapp/interactive/list',
  headers: { 
    'apiKey': 'YOUR_API_KEY', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}
{% endtabs %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
      "timestamp": "2023-08-06T01:27:56.825898971",
      "data": {
            "messageId": "7addc006-07db-4fae-aac5-b285903b41d4",
            "waId": "wamid.HBgMMjU0NzE3NzQ2NTY1FQIAEnRgSRjJGRkMzNkQ0QUVENTIxQ0NBAA==",
            "status": "SENT",
            "statusDesc": "Message sent successfully"
      },
      "status": "success",
      "message": "",
      "errors": null
}
```

{% endtab %}

{% tab title="400" %}

```json
{
      "timestamp": "2023-08-06T17:50:35.701+00:00",
      "status": 400,
      "error": "Bad Request",
      "path": "/api/v1/whatsapp/message/text"
}
```

{% endtab %}

{% tab title="401" %}

```json
{
      "timestamp": "2023-08-06T20:49:48.455464058",
      "data": null,
      "status": "success",
      "message": "Invalid credentials",
      "errors": null
}
```

{% endtab %}
{% endtabs %}
