# Send Campaign Message

## Send a WhatsApp Campaign Message

<mark style="color:green;">`POST`</mark> `https://api.oneroute.io/api/public/whatsapp/campaign`

This endpoint is designed for WhatsApp template campaigns with many recipients.&#x20;

Template messages can be delivered at any time. Each template needs to be registered and pre-approved by WhatsApp

We recommend sending the campaign in one request so that it can be grouped else it will be treated as an individual request. All recipients,  corresponding templates, and template parameters are included in an array as shown in the example request payload below

#### Headers

| Name   | Type   | Description                 |
| ------ | ------ | --------------------------- |
| apiKey | string | API Key for authentication. |

#### Request Body

| Name                      | Type    | Description                                               |
| ------------------------- | ------- | --------------------------------------------------------- |
| messages.\*.save          | boolean | To save the message as a conversation on OneRoute or not. |
| messages.\*.template      | object  | The template object                                       |
| messages                  | array   | An array of messages to send                              |
| from                      | string  |                                                           |
| messages.\*.to            | string  | Whatsapp number to send template message to.              |
| messages.\*.template.name | string  | the template name                                         |
| messages.\*.identifier    | string  | a unique id you want give each messages                   |

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

```
{
    "data": {
        "campaign_id": "868a4f7f-3e41-4cd2-aba5-655c8b2ae2bb"
    },
    "message": "Data received",
    "success": true
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "data": null,
    "success": false,
    "message": "\"template\" is required"
}
```

{% endtab %}

{% tab title="401 " %}

```
{
    "data": null,
    "message": "Invalid API Key",
    "success": false
}
```

{% endtab %}
{% endtabs %}

### Example Request Payload

```
{
    "messages": [
        {
            "identifier": "unique_id",
            "template": {
                "name": "first_welcome_messsage",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Michael"
                    }
                ] // leave the array empty if no placeholders in the template
            },
            "to": "234XXXXXXXX",
            "save": true
        },
         {
            "identifier": "unique_id",
            "template": {
                "name": "new_conversation",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Timothy"
                    }
                ] // leave the array empty if no placeholders in the template
            },
            "to": "234XXXXXXXX",
            "save": true
        }
    ],
    "from": "234XXXXXXXX"
}
```

Here is a diagram flow of the lifecycle of a campaign

<figure><img src="/files/mEn3C33L475b4LImxfnh" alt=""><figcaption></figcaption></figure>

To get the status of your campaign, you may call the [logs API](https://docs.oneroute.io/others/fetch-logs),  and pass the campaign ID. A request will also be pushed to your registered webhook upon campaign completion.\
\
You can also get the individual message status by passing the identifier to the url query. You can see more details [here](https://docs.oneroute.io/others/fetch-logs).


---

# 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.oneroute.io/whatsapp-api/endpoints/send-campaign-message.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.
