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

# Send Transactional Message

> Dispatches a transactional WhatsApp message (like Invoice PDFs or Account Alerts) with dynamic variables and attachments.

## Request Body

<ParamField body="to" type="string" required>
  The recipient's phone number in strict E.164 format (e.g., `+919876543210`).
</ParamField>

<ParamField body="template" type="string" required>
  The exact name of the WhatsApp template you created in your Meta Business account (e.g., `invoice_receipt`).
</ParamField>

<ParamField body="language" type="string">
  The language code of the template. Defaults to `en_US`.
</ParamField>

<ParamField body="variables" type="object">
  An object containing the dynamic data to inject into the template.

  <Expandable title="properties">
    <ParamField body="header" type="object">
      Used if your template has a media header (Document, Image, or Video).

      * `type`: Must be `text`, `document`, `image`, or `video`.
      * `link`: The absolute URL to the media file (required for media types).
      * `filename`: The name of the file to display (e.g., `invoice.pdf`).
      * `text`: The text content (if type is `text`).
    </ParamField>

    <ParamField body="body" type="array of strings">
      An array of strings corresponding to the `{{1}}`, `{{2}}` placeholders in your template body.
    </ParamField>

    <ParamField body="button" type="array of strings">
      An array of strings to inject into dynamic URL buttons.
    </ParamField>
  </Expandable>
</ParamField>

### Request Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://otpedge.com/api/v1/send-message \
       -H "Authorization: Bearer your_api_key_here" \
       -H "Content-Type: application/json" \
       -d '{
         "to": "+919876543210",
         "template": "invoice_receipt",
         "language": "en_US",
         "variables": {
           "header": {
             "type": "document",
             "link": "https://your-site.com/invoices/INV-123.pdf",
             "filename": "Monthly_Invoice.pdf"
           },
           "body": [
             "John Doe",
             "$49.99"
           ],
           "button": [
             "INV-123"
           ]
         }
       }'
  ```

  ```javascript JavaScript (Fetch) theme={null}
  const response = await fetch('https://otpedge.com/api/v1/send-message', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      to: "+919876543210",
      template: "invoice_receipt",
      language: "en_US",
      variables: {
        header: {
          type: "document",
          link: "https://your-site.com/invoices/INV-123.pdf",
          filename: "Monthly_Invoice.pdf"
        },
        body: ["John Doe", "$49.99"],
        button: ["INV-123"]
      }
    })
  });

  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

### Response Examples

<ResponseExample>
  ```json 200 OK (Dispatched) theme={null}
  {
    "success": true,
    "req_id": "msg_a1b2c3d4e5f6",
    "status": "dispatched",
    "template": "invoice_receipt",
    "usage": "14/1000"
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": "Configuration Error: No Meta WhatsApp integration found for this workspace."
  }
  ```
</ResponseExample>
