Skip to main content

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.
For the built-in Modawer sender, use Send OTP Message. This page is only for sending OTPs through a customer’s connected WhatsApp Business account.

Endpoint

FieldValue
MethodPOST
Path/api/messages/send/raw
Content-Typeapplication/json

Required header

X-API-KEY: your-app-token

Request body

{
  "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"
            }
          ]
        }
      ]
    }
  }
}
FieldTypeRequiredDescription
whatsappBusinessIdstringYesConnected WhatsApp Business Account ID (WABA ID) that owns the sender phone number and template.
phoneNumberIdstringYesWhatsApp phone number ID that should send the OTP message.
channelsMessageChannel[]NoOptional message flow. Only applicable when the selected template is AUTHENTICATION.
payloadobjectYesRaw WhatsApp template payload to queue.
payload.recipientstringYesPhone number that receives the OTP.
payload.tostringYesWhatsApp recipient phone number. Usually the same value as payload.recipient.
payload.typestringYesUse "template".
payload.template.namestringYesName of an approved WhatsApp template with category AUTHENTICATION.
payload.template.language.codestringYesTemplate language code, such as "ar" or "en_US".
payload.template.componentsobject[]YesTemplate 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.
Marketing, Utility, and other non-authentication templates are valid for normal WhatsApp template sending, but they should not be used for this OTP flow.

Message Flow / Channels

channels controls the message flow. It is optional and only applicable when using AUTHENTICATION templates. Supported values:
ValueDescription
"WhatsApp"Send through WhatsApp.
"Telegram"Use Telegram as part of flow.
Examples:
["WhatsApp"]
["WhatsApp", "Telegram"]
["Telegram", "WhatsApp"]
If channels is omitted, the backend defaults to WhatsApp.
Do not include channels for non-AUTHENTICATION templates. For normal Marketing or Utility template messages, use the regular Send WhatsApp template page.

Success response

{
  "queued": true
}

cURL example

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.