Voice APIOutbound Call with Audio Playback

Outbound Call with Audio Playback

Lê Đức Tuệ·6/2/2026

API to make an outbound call and play a pre-recorded audio file for the customer to listen to. Suitable for automatic notification situations: appointment reminders, order confirmations, debt reminders, surveys, etc.

Authentication: Request needs to send header X-Api-Key. Contact Alohub to obtain an API Key.

Requirements: The audio file must be pre-configured in the campaign ( campaignId). If there is no file, contact the technical team to upload the audio file into the campaign before calling the API.


Endpoint

POST {{base_url}}/v1/voice/play-file

Headers

Header

Required

Description

X-Api-Key

Yes

API Key for authentication

Content-Type

Yes

application/json

Request Body

Parameter

Type

Required

Description

phone

string

Yes

Customer's phone number

campaignId

number

Yes

Campaign ID (contains the pre-configured audio file)

transactionId

string

No

Transaction ID generated by the client to match results via webhook

Sample Code

curl --location -g '{{base_url}}/v1/voice/play-file' \
  --header 'X-Api-Key: {{api_key}}' \
  --header 'Content-Type: application/json' \
  --data '{
    "phone": "0123456789",
    "campaignId": 1,
    "transactionId": "TXN_002"
  }'
const axios = require('axios')

const response = await axios.post('{{base_url}}/v1/voice/play-file', {
  phone: '0123456789',
  campaignId: 1,
  transactionId: 'TXN_002'
}, {
  headers: {
    'X-Api-Key': '{{api_key}}',
    'Content-Type': 'application/json'
  }
})

console.log(response.data)
import requests

response = requests.post('{{base_url}}/v1/voice/play-file',
  json={
    'phone': '0123456789',
    'campaignId': 1,
    'transactionId': 'TXN_002'
  },
  headers={
    'X-Api-Key': '{{api_key}}',
    'Content-Type': 'application/json'
  }
)

print(response.json())

Compare with Text-to-Speech: Use Audio Playback when the content is fixed and requires good voice quality (pre-recorded). Use Text-to-Speech when the content is dynamic (OTP code, amount, customer name, etc.) that cannot be pre-recorded.

Was this article helpful?
Updated: 6/2/2026
để chuyển bài