# Voice OTP Broadcast

`POST /api/broadcasts/otp`

Send OTP (One-Time Password) voice messages to a single phone number. The voice must contain at least one dynamic part with digit mode to read the OTP code.

## Request Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| request_id | string | Yes | Unique request identifier (16-64 chars) to prevent duplicate requests. Use UUID or random string. |
| voice | string | Yes | Name of your approved voice with digit mode |
| sender | string | Yes | Your active caller sender number |
| phone_number | string | Yes | Single Bangladeshi phone number (01XXXXXXXXX format) |
| otp_code | string | Yes | OTP code (4-6 digits) |

## Request Example

```bash
curl -X POST https://api.awajdigital.com/api/broadcasts/otp \
  -H "Authorization: Bearer your_api_token_here" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "unique_request_id_123",
    "voice": "your_voice_name",
    "sender": "8801234567890",
    "phone_number": "019XXXXXXXX",
    "otp_code": "1234"
  }'
```

```javascript
// Browser JavaScript (Fetch API)
const response = await fetch('https://api.awajdigital.com/api/broadcasts/otp', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_api_token_here',
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    request_id: 'unique_request_id_123',
    voice: 'your_voice_name',
    sender: '8801234567890',
    phone_number: '019XXXXXXXX',
    otp_code: '1234'
  })
});

const data = await response.json();
console.log(data);
```

```javascript
// Node.js with axios
const axios = require('axios');

async function sendOtpBroadcast() {
  try {
    const response = await axios.post('https://api.awajdigital.com/api/broadcasts/otp', {
      request_id: 'unique_request_id_123',
      voice: 'your_voice_name',
      sender: '8801234567890',
      phone_number: '019XXXXXXXX',
      otp_code: '1234'
    }, {
      headers: {
        'Authorization': 'Bearer your_api_token_here',
        'Accept': 'application/json',
        'Content-Type': 'application/json'
      }
    });

    console.log(response.data);
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

sendOtpBroadcast();
```

```python
# Python with requests
import requests

def send_otp_broadcast():
    url = 'https://api.awajdigital.com/api/broadcasts/otp'
    headers = {
        'Authorization': 'Bearer your_api_token_here',
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    }
    data = {
        'request_id': 'unique_request_id_123',
        'voice': 'your_voice_name',
        'sender': '8801234567890',
        'phone_number': '019XXXXXXXX',
        'otp_code': '1234'
    }

    try:
        response = requests.post(url, json=data, headers=headers)
        print(response.json())
    except requests.exceptions.RequestException as e:
        print(f'Error: {e}')

send_otp_broadcast()
```

```php
<?php
// PHP with cURL
$url = 'https://api.awajdigital.com/api/broadcasts/otp';
$token = 'your_api_token_here';

$data = [
    'request_id' => 'unique_request_id_123',
    'voice' => 'your_voice_name',
    'sender' => '8801234567890',
    'phone_number' => '019XXXXXXXX',
    'otp_code' => '1234'
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $token,
    'Accept: application/json',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);
?>
```

## Success Response Example

```json
{
  "success": true,
  "broadcast": {
    "id": 123,
    "name": "otp_api_1_your_voice_019XXXXXXXX",
    "status": "broadcasting",
    "createdAt": "2025-12-29T10:30:00.000Z"
  }
}
```

:::note
Use a unique `request_id` for each request to prevent duplicate processing. Requests with the same `request_id` within 15 minutes will be rejected.
:::