# Send Template API

## Send WhatsApp Template

This **Send WhatsApp Template API** helps you to send a message to end user using an API.

{% hint style="info" %}
This API requires an active WhatsApp Account on QuickReply.ai along with a non-negative WhatsApp Wallet Balance
{% endhint %}

**Pre-requisites**

* The WhatsApp Template is already approved
* You have Messaging Credits Wallet balance to send the template message
* You have not exceeded your daily [messaging limit](/overview/messaging-channels/whatsapp/concepts.md#messaging-limits) on your WhatsApp number

## Send WhatsApp Template Message by API

<mark style="color:green;">`POST`</mark> `https://app.quickreply.ai/api/whatsapp/send-template?templateId={{template_id}}`

Body is a JSON Object

#### Query Parameters

| Name                                         | Type   | Description                                                                                                           |
| -------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| templateId<mark style="color:red;">\*</mark> | String | You can find the template id by clicking on the 3 dots at the right of template block and clicking "Copy Template Id" |

#### Headers

| Name                                           | Type   | Description                                                                                                                                     |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| client-id<mark style="color:red;">\*</mark>    | String | You can find client-id of your account in [Settings > Developers > API credentials](https://app.quickreply.ai/v2/settings/dev/api-credentials)  |
| secret-key<mark style="color:red;">\*</mark>   | String | You can find secret-key of your account in [Settings > Developers > API credentials](https://app.quickreply.ai/v2/settings/dev/api-credentials) |
| Content-Type<mark style="color:red;">\*</mark> |        | application/json                                                                                                                                |

#### Request Body

| Name                                     | Type             | Description                                                                                                                                                                                                                                                                                                             |
| ---------------------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| params<mark style="color:red;">\*</mark> | Array of Strings | Comma-Separated Strings representing the values that will replace the variables template's body                                                                                                                                                                                                                         |
| button\_params                           | Array of Strings | <p>// Required - If Template has a Dynamic CTA URL</p><p>Comma-Separated Strings representing the variable part of dynamic url</p>                                                                                                                                                                                      |
| to<mark style="color:red;">\*</mark>     | String           | Phone number of the recipient                                                                                                                                                                                                                                                                                           |
| name                                     | String           | Name of recipient                                                                                                                                                                                                                                                                                                       |
| email                                    | String           | Email of recipient                                                                                                                                                                                                                                                                                                      |
| hook\_with\_playbook                     | String           | Playbook or a Custom bot to which the user should be hooked on their response on the QuickReply button. This works only for templates with QuickReply buttons.                                                                                                                                                          |
| link                                     | String           | <p>// Required - if the template is of type media</p><p>Public accessible media URL for Media Templates like an Image, Video, or Document.</p><p>IMAGE:<br>Supported types: image/jpeg, image/png</p><p>VIDEO:<br>Supported types: video/mp4, video/3gpp</p><p>DOCUMENT:</p><p>Supported types: Any valid MIME-type</p> |

{% tabs %}
{% tab title="200: OK On Success" %}

```javascript
{
  "id": "<message_id>",
  "status" : "SENT"
}
```

{% endtab %}

{% tab title="400: Bad Request When params are missing" %}

```json
{
    "error": "Bad Request: params are missing"
}
```

{% endtab %}

{% tab title="401: Unauthorized When client-id or secret-key is wrong" %}

```json
{
  "error": "Unauthorized"
}
```

{% endtab %}

{% tab title="400: Bad Request When Template id is wrong" %}

```json
{
    "error": "Bad Request: Template not found"
}
```

{% endtab %}

{% tab title="400: Bad Request When recipient" %}

```json
{
    "error": "Bad Request: Receiver not found"
}
```

{% endtab %}

{% tab title="400: Bad Request When Template id is missing" %}

```json
{
    "error": "Bad Request: Template id missing"
}
```

{% endtab %}

{% tab title="400: Bad Request When message fails at WhatsApp" %}

```json
{
    "id": "<message_id>",
    "state": "NOT_SENT",
    "reason": "<Error message recieved from Whatsapp>"
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Fields marked with [\*️](https://emojipedia.org/asterisk/) are Required.
{% endhint %}

### Sample CURL Request

```sh
curl --location --request POST 'https://app.quickreply.ai/api/whatsapp/send-template?templateId=1531b8a3-cacb-4141-b267-51b7d9637191' \
--header 'client-id: oLtaHhFFVapeELFro_c' \
--header 'secret-key: 2gqRDCxNFHoYawRFh' \
--header 'Content-Type: application/json' \
--data-raw '{
    "params": [
        "var_1",
        "var_2",
        "var_3"
    ],
    "button_params" : [
        "url_suffix/something"
    ],
    "to": "+919876543210",
    "name": "Utkarsh",
    "email": "test@yopmail.com",
    "link": "https:/some-public-domain/sample_image.jpeg",
    "hook_with_playbook": "61c01099380d7b33bf30d7cd"
}'
```

#### Simple Text Template

```sh
curl --location --request POST 'https://app.quickreply.ai/api/whatsapp/send-template?templateId=1531b8a3-cacb-4141-b267-51b7d9637191' \
--header 'client-id: oLtaHhFFVapeELFro_c' \
--header 'secret-key: 2gqRDCxNFHoYawRFh' \
--header 'Content-Type: application/json' \
--data-raw '{
    "params": [
        "var_1",
        "var_2",
        "var_3"
    ],
    "to": "+919876543210",
    "name": "Utkarsh",
    "email": "test@yopmail.com"
}'
```

#### Media with Text Template

```sh
curl --location --request POST 'https://app.quickreply.ai/api/whatsapp/send-template?templateId=1531b8a3-cacb-4141-b267-51b7d9637191' \
--header 'client-id: oLtaHhFFVapeELFro_c' \
--header 'secret-key: 2gqRDCxNFHoYawRFh' \
--header 'Content-Type: application/json' \
--data-raw '{
    "params": [
        "var_1",
        "var_2",
        "var_3"
    ],
    "to": "+919876543210",
    "name": "Utkarsh",
    "email": "test@yopmail.com",
    "link": "https:/some-public-domain/sample_image.jpeg"
}'
```

#### Template with a Dynamic CTA Button

```sh
curl --location --request POST 'https://app.quickreply.ai/api/whatsapp/send-template?templateId=1531b8a3-cacb-4141-b267-51b7d9637191' \
--header 'client-id: oLtaHhFFVapeELFro_c' \
--header 'secret-key: 2gqRDCxNFHoYawRFh' \
--header 'Content-Type: application/json' \
--data-raw '{
    "params": [
        "var_1",
        "var_2",
        "var_3"
    ],
    "button_params" : [
        "url_suffix/something"
    ],
    "to": "+919876543210",
    "name": "Utkarsh",
    "email": "test@yopmail.com",
    "link": "https:/some-public-domain/sample_image.jpeg"
}'
```

#### Template with a QuickReply Button

```sh
curl --location --request POST 'https://app.quickreply.ai/api/whatsapp/send-template?templateId=1531b8a3-cacb-4141-b267-51b7d9637191' \
--header 'client-id: oLtaHhFFVapeELFro_c' \
--header 'secret-key: 2gqRDCxNFHoYawRFh' \
--header 'Content-Type: application/json' \
--data-raw '{
    "params": [
        "var_1",
        "var_2",
        "var_3"
    ],
    "to": "+919876543210",
    "name": "Utkarsh",
    "email": "test@yopmail.com",
    "link": "https:/some-public-domain/sample_image.jpeg",
    "hook_with_playbook": "61c01099380d7b33bf30d7cd"
}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.quickreply.ai/developer/apis/send-template-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
