API

Audio API

Generate TTS audio, upload files, and manage audio assets for IVR and voicemail.

The Audio API manages audio assets used across IVR trees and voicemail drops. Generate speech from text using ElevenLabs TTS, or upload your own audio files. All audio is automatically transcoded and staged to the Asterisk server for zero-latency playback.


Generate TTS audio

POST /audio

Generate audio from text using ElevenLabs TTS. The resulting file is automatically staged to Asterisk for IVR playback.

Request body

FieldTypeRequiredDescription
namestringYesHuman-readable name for the audio asset
textstringYesText to synthesize into speech
voicestringNoElevenLabs voice ID (uses default if omitted)
curl -X POST "https://api.trunx.io/audio" \
  -H "Authorization: Bearer tk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Welcome Greeting",
    "text": "Thank you for calling. Please hold while we connect you.",
    "voice": "EXAVITQu4vr4xnSDxMaL"
  }'
const res = await fetch("https://api.trunx.io/audio", {
  method: "POST",
  headers: {
    "Authorization": "Bearer tk_live_...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Welcome Greeting",
    text: "Thank you for calling. Please hold while we connect you.",
    voice: "EXAVITQu4vr4xnSDxMaL",
  }),
});
const data = await res.json();
import requests

res = requests.post(
    "https://api.trunx.io/audio",
    headers={
        "Authorization": "Bearer tk_live_...",
        "Content-Type": "application/json",
    },
    json={
        "name": "Welcome Greeting",
        "text": "Thank you for calling. Please hold while we connect you.",
        "voice": "EXAVITQu4vr4xnSDxMaL",
    },
)
data = res.json()

Response

{
  "id": "aud_abc123",
  "name": "Welcome Greeting",
  "url": "https://api.trunx.io/audio/aud_abc123/file",
  "durationSeconds": 3.2
}

Generated audio is automatically transcoded to the format required by Asterisk and staged via SCP for zero-latency IVR playback.


Upload audio file

POST /audio/upload

Upload a pre-recorded audio file. Accepts common audio formats (mp3, wav, ogg). The file is transcoded and staged to Asterisk automatically.

Request body

Multipart form data:

FieldTypeRequiredDescription
filefileYesAudio file to upload
namestringNoDisplay name (defaults to filename)
curl -X POST "https://api.trunx.io/audio/upload" \
  -H "Authorization: Bearer tk_live_..." \
  -F "file=@greeting.mp3" \
  -F "name=After Hours Greeting"
const formData = new FormData();
formData.append("file", audioFile);
formData.append("name", "After Hours Greeting");

const res = await fetch("https://api.trunx.io/audio/upload", {
  method: "POST",
  headers: { "Authorization": "Bearer tk_live_..." },
  body: formData,
});
const data = await res.json();
import requests

with open("greeting.mp3", "rb") as f:
    res = requests.post(
        "https://api.trunx.io/audio/upload",
        headers={"Authorization": "Bearer tk_live_..."},
        files={"file": f},
        data={"name": "After Hours Greeting"},
    )
data = res.json()

Response

{
  "id": "aud_def456",
  "name": "After Hours Greeting",
  "url": "https://api.trunx.io/audio/aud_def456/file",
  "durationSeconds": 8.5
}

List audio files

GET /audio

Returns all audio assets for the authenticated account.

curl "https://api.trunx.io/audio" \
  -H "Authorization: Bearer tk_live_..."
const res = await fetch("https://api.trunx.io/audio", {
  headers: { "Authorization": "Bearer tk_live_..." },
});
const data = await res.json();
import requests

res = requests.get(
    "https://api.trunx.io/audio",
    headers={"Authorization": "Bearer tk_live_..."},
)
data = res.json()

Response

{
  "audio": [
    {
      "id": "aud_abc123",
      "name": "Welcome Greeting",
      "url": "https://api.trunx.io/audio/aud_abc123/file",
      "durationSeconds": 3.2
    },
    {
      "id": "aud_def456",
      "name": "After Hours Greeting",
      "url": "https://api.trunx.io/audio/aud_def456/file",
      "durationSeconds": 8.5
    }
  ]
}

Delete audio file

DELETE /audio/{id}

Permanently deletes an audio asset. If the audio is currently referenced by an IVR node, you should update the IVR before deleting.

curl -X DELETE "https://api.trunx.io/audio/aud_abc123" \
  -H "Authorization: Bearer tk_live_..."
const res = await fetch("https://api.trunx.io/audio/aud_abc123", {
  method: "DELETE",
  headers: { "Authorization": "Bearer tk_live_..." },
});
const data = await res.json();
import requests

res = requests.delete(
    "https://api.trunx.io/audio/aud_abc123",
    headers={"Authorization": "Bearer tk_live_..."},
)
data = res.json()

Response

{
  "deleted": true
}

On this page