# Direct Broadcast

`POST /api/broadcasts/direct`

Send a broadcast without a pre-approved voice by providing CDN audio URLs. Files are downloaded and validated, then played in sequence on each call. Same idea as a direct survey, for announcements.

:::caution[Permission required]
This endpoint requires extra permission on your account. Contact support to enable it. Requests without it receive `403`.
:::

## 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. |
| sender | string | Yes | Your active caller sender number |
| phone_numbers | array | Yes | Array of Bangladeshi phone numbers (01XXXXXXXXX format, 1-999 numbers). No duplicates allowed. |
| voices | array | Yes | CDN audio URLs (1-10), played in sequence. A single file is a one-item array. |
| metadata | object | No | Custom data to associate with the broadcast. |

## Audio format

WAV, 8000 Hz, mono, `pcm_s16le` (G.711-compatible). Every URL is downloaded and validated before the broadcast is queued. Invalid files are rejected with `400`.

## Request Example

```bash
curl -X POST https://api.awajdigital.com/api/broadcasts/direct \
  -H "Authorization: Bearer your_api_token_here" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "unique_direct_broadcast_123",
    "sender": "8801234567890",
    "phone_numbers": ["019XXXXXXXX", "018XXXXXXXX"],
    "voices": ["https://cdn.example.com/audio/announcement.wav"],
    "metadata": { "campaign_id": "direct_broadcast_2026" }
  }'
```

```javascript
// Browser JavaScript (Fetch API)
const response = await fetch('https://api.awajdigital.com/api/broadcasts/direct', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_api_token_here',
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    request_id: 'unique_direct_broadcast_123',
    sender: '8801234567890',
    phone_numbers: ['019XXXXXXXX', '018XXXXXXXX'],
    voices: ['https://cdn.example.com/audio/announcement.wav'],
    metadata: { campaign_id: 'direct_broadcast_2026' }
  })
});

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

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

async function sendDirectBroadcast() {
  try {
    const response = await axios.post('https://api.awajdigital.com/api/broadcasts/direct', {
      request_id: 'unique_direct_broadcast_123',
      sender: '8801234567890',
      phone_numbers: ['019XXXXXXXX', '018XXXXXXXX'],
      voices: ['https://cdn.example.com/audio/announcement.wav'],
      metadata: { campaign_id: 'direct_broadcast_2026' }
    }, {
      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);
  }
}

sendDirectBroadcast();
```

```python
# Python with requests
import requests

def send_direct_broadcast():
    url = 'https://api.awajdigital.com/api/broadcasts/direct'
    headers = {
        'Authorization': 'Bearer your_api_token_here',
        'Accept': 'application/json',
        'Content-Type': 'application/json'
    }
    data = {
        'request_id': 'unique_direct_broadcast_123',
        'sender': '8801234567890',
        'phone_numbers': ['019XXXXXXXX', '018XXXXXXXX'],
        'voices': ['https://cdn.example.com/audio/announcement.wav'],
        'metadata': { 'campaign_id': 'direct_broadcast_2026' }
    }

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

send_direct_broadcast()
```

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

$data = [
    'request_id' => 'unique_direct_broadcast_123',
    'sender' => '8801234567890',
    'phone_numbers' => ['019XXXXXXXX', '018XXXXXXXX'],
    'voices' => ['https://cdn.example.com/audio/announcement.wav'],
    'metadata' => ['campaign_id' => 'direct_broadcast_2026']
];

$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": "direct_1_1705312800000",
    "status": "broadcasting",
    "createdAt": "2026-08-31T10:30:00.000Z"
  }
}
```

Poll [Get Broadcast Result](/api-docs/broadcasts/result) for per-number call outcomes.

## Error Responses

| Status | Description |
| --- | --- |
| 400 | Duplicate phone numbers, or audio files not in G.711-compatible format |
| 402 | Insufficient account balance |
| 403 | Extra permission not enabled, or sender not found / not active |
| 409 | `request_id` already used within 15 minutes |
| 422 | Invalid request parameters (`request_id` length, phone format, URL, array size) |

:::note
Use a unique `request_id` for each request. The same `request_id` within 15 minutes is rejected with `409`. This endpoint does not create a Voice row — host the WAV files on a CDN you control.
:::