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

# Send OTP from Your WhatsApp Account

> Send OTP messages through a customer's connected WhatsApp Business account

## When to use this flow

Use this flow when you want OTP messages to be sent from your own connected WhatsApp Business account instead of Modawer's official WhatsApp sender.

This flow uses the raw WhatsApp template endpoint with an `AUTHENTICATION` template from your connected WABA.

<Info>
  For the built-in Modawer sender, use [Send OTP Message](/messages/send-otp).
  This page is only for sending OTPs through a customer's connected WhatsApp Business account.
</Info>

## Endpoint

| Field        | Value                    |
| ------------ | ------------------------ |
| Method       | `POST`                   |
| Path         | `/api/messages/send/raw` |
| Content-Type | `application/json`       |

## Required header

```http theme={null}
X-API-KEY: your-app-token
```

## Request body

```json theme={null}
{
  "whatsappBusinessId": "123456789012345",
  "phoneNumberId": "1058560794000297",
  "channels": ["WhatsApp"],
  "payload": {
    "recipient": "9647701234567",
    "to": "9647701234567",
    "type": "template",
    "template": {
      "name": "otp_code_login",
      "language": {
        "code": "ar"
      },
      "components": [
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "text": "123456",
              "parameter_name": "1"
            }
          ]
        }
      ]
    }
  }
}
```

| Field                            | Type               | Required | Description                                                                                      |
| -------------------------------- | ------------------ | -------- | ------------------------------------------------------------------------------------------------ |
| `whatsappBusinessId`             | `string`           | Yes      | Connected WhatsApp Business Account ID (WABA ID) that owns the sender phone number and template. |
| `phoneNumberId`                  | `string`           | Yes      | WhatsApp phone number ID that should send the OTP message.                                       |
| `channels`                       | `MessageChannel[]` | No       | Optional message flow. Only applicable when the selected template is `AUTHENTICATION`.           |
| `payload`                        | `object`           | Yes      | Raw WhatsApp template payload to queue.                                                          |
| `payload.recipient`              | `string`           | Yes      | Phone number that receives the OTP.                                                              |
| `payload.to`                     | `string`           | Yes      | WhatsApp recipient phone number. Usually the same value as `payload.recipient`.                  |
| `payload.type`                   | `string`           | Yes      | Use `"template"`.                                                                                |
| `payload.template.name`          | `string`           | Yes      | Name of an approved WhatsApp template with category `AUTHENTICATION`.                            |
| `payload.template.language.code` | `string`           | Yes      | Template language code, such as `"ar"` or `"en_US"`.                                             |
| `payload.template.components`    | `object[]`         | Yes      | Template components and OTP parameters required by your approved authentication template.        |

## Authentication template selection

The selected template must be an approved WhatsApp template with category `AUTHENTICATION`.

Use the Modawer Portal to:

1. Link your WhatsApp Business account.
2. Select the connected WhatsApp account.
3. Select the sender WhatsApp phone number.
4. Select an `AUTHENTICATION` template.
5. Copy the generated cURL from API Playground.

<Warning>
  Marketing, Utility, and other non-authentication templates are valid for normal WhatsApp template sending, but they should not be used for this OTP flow.
</Warning>

## Message Flow / Channels

`channels` controls the message flow. It is optional and only applicable when using `AUTHENTICATION` templates.

Supported values:

| Value        | Description                   |
| ------------ | ----------------------------- |
| `"WhatsApp"` | Send through WhatsApp.        |
| `"Telegram"` | Use Telegram as part of flow. |

Examples:

```json theme={null}
["WhatsApp"]
```

```json theme={null}
["WhatsApp", "Telegram"]
```

```json theme={null}
["Telegram", "WhatsApp"]
```

If `channels` is omitted, the backend defaults to WhatsApp.

<Note>
  Do not include `channels` for non-`AUTHENTICATION` templates. For normal Marketing or Utility template messages, use the regular [Send WhatsApp template](/messages/send-raw) page.
</Note>

## Success response

```json theme={null}
{
  "queued": true
}
```

## cURL example

```bash theme={null}
curl -X POST "https://modawer.com/api/messages/send/raw" \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: your-app-token" \
  -d '{
    "whatsappBusinessId": "123456789012345",
    "phoneNumberId": "1058560794000297",
    "channels": ["WhatsApp"],
    "payload": {
      "recipient": "9647701234567",
      "to": "9647701234567",
      "type": "template",
      "template": {
        "name": "otp_code_login",
        "language": {
          "code": "ar"
        },
        "components": [
          {
            "type": "body",
            "parameters": [
              {
                "type": "text",
                "text": "123456",
                "parameter_name": "1"
              }
            ]
          }
        ]
      }
    }
  }'
```

## End-to-end checklist

* Your app is linked to a WhatsApp Business account.
* `whatsappBusinessId` matches the connected WABA.
* `phoneNumberId` belongs to that WABA.
* The selected template category is `AUTHENTICATION`.
* `channels` is included only when using an `AUTHENTICATION` template.
* The OTP value is passed in the template component expected by your approved template.
