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

# OTT Messaging

> Send messages via WhatsApp, Viber, and Telegram

## Supported Channels

NativeMessage supports:

* **WhatsApp Business API** (template and session messages)
* **Viber Business** (promotional and transactional)
* **Telegram Bot API**

## Channel Setup

Create an OTT channel linked to a provider:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-message.nativehub.live/api/v1/ott/channels \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "provider_id": "prov_abc123",
      "channel_type": "whatsapp",
      "config": {
        "phone_number_id": "123456789",
        "business_account_id": "987654321"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api-message.nativehub.live/api/v1/ott/channels', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      provider_id: 'prov_abc123',
      channel_type: 'whatsapp',
      config: {
        phone_number_id: '123456789',
        business_account_id: '987654321'
      }
    })
  });
  const channel = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api-message.nativehub.live/api/v1/ott/channels',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'provider_id': 'prov_abc123',
          'channel_type': 'whatsapp',
          'config': {
              'phone_number_id': '123456789',
              'business_account_id': '987654321'
          }
      }
  )
  channel = response.json()
  ```
</CodeGroup>

## Template Management

### Create Template

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-message.nativehub.live/api/v1/ott/templates \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "channel_id": "chan_abc123",
      "name": "order_confirmation",
      "language": "en",
      "category": "transactional",
      "body": "Your order {{1}} is confirmed. Total: ${{2}}"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api-message.nativehub.live/api/v1/ott/templates', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      channel_id: 'chan_abc123',
      name: 'order_confirmation',
      language: 'en',
      category: 'transactional',
      body: 'Your order {{1}} is confirmed. Total: ${{2}}'
    })
  });
  const template = await response.json();
  ```

  ```python Python theme={null}
  response = requests.post(
      'https://api-message.nativehub.live/api/v1/ott/templates',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'channel_id': 'chan_abc123',
          'name': 'order_confirmation',
          'language': 'en',
          'category': 'transactional',
          'body': 'Your order {{1}} is confirmed. Total: ${{2}}'
      }
  )
  template = response.json()
  ```
</CodeGroup>

<Warning>
  WhatsApp templates require Meta approval before use. Approval typically takes 24-48 hours.
</Warning>

### Template Status

Templates have these states:

* `pending` — Awaiting approval
* `approved` — Ready to use
* `rejected` — Failed approval

## Sending OTT Messages

### Template-Based Message

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-message.nativehub.live/api/v1/ott/messages \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "channel_id": "chan_abc123",
      "destination": "+1234567890",
      "template_id": "tmpl_xyz789",
      "parameters": ["ORD-12345", "49.99"]
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api-message.nativehub.live/api/v1/ott/messages', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      channel_id: 'chan_abc123',
      destination: '+1234567890',
      template_id: 'tmpl_xyz789',
      parameters: ['ORD-12345', '49.99']
    })
  });
  const message = await response.json();
  ```

  ```python Python theme={null}
  response = requests.post(
      'https://api-message.nativehub.live/api/v1/ott/messages',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'channel_id': 'chan_abc123',
          'destination': '+1234567890',
          'template_id': 'tmpl_xyz789',
          'parameters': ['ORD-12345', '49.99']
      }
  )
  message = response.json()
  ```
</CodeGroup>

### Session Message (Freeform)

Session messages can be sent within 24 hours of user reply (WhatsApp):

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-message.nativehub.live/api/v1/ott/messages \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "channel_id": "chan_abc123",
      "destination": "+1234567890",
      "content": {
        "type": "text",
        "text": "Thank you for your inquiry!"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch('https://api-message.nativehub.live/api/v1/ott/messages', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      channel_id: 'chan_abc123',
      destination: '+1234567890',
      content: {
        type: 'text',
        text: 'Thank you for your inquiry!'
      }
    })
  });
  ```

  ```python Python theme={null}
  requests.post(
      'https://api-message.nativehub.live/api/v1/ott/messages',
      headers={
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
      },
      json={
          'channel_id': 'chan_abc123',
          'destination': '+1234567890',
          'content': {
              'type': 'text',
              'text': 'Thank you for your inquiry!'
          }
      }
  )
  ```
</CodeGroup>

<Info>
  Session windows vary by platform:

  * WhatsApp: 24 hours from last user message
  * Viber: No session window
  * Telegram: No session window
</Info>

## Retry Failed Messages

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api-message.nativehub.live/api/v1/ott/messages/msg_abc123/retry \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```

  ```javascript Node.js theme={null}
  await fetch('https://api-message.nativehub.live/api/v1/ott/messages/msg_abc123/retry', {
    method: 'POST',
    headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
  });
  ```

  ```python Python theme={null}
  requests.post(
      'https://api-message.nativehub.live/api/v1/ott/messages/msg_abc123/retry',
      headers={'Authorization': 'Bearer YOUR_TOKEN'}
  )
  ```
</CodeGroup>
