Upload a sound file (user, pbx)
/sound-files
Upload an announcement or music on hold. Send a multipart/form-data body with name, type and the audio in the audio file part. The file is stored the same way as an upload in the cockpit: wav, flac and aac audio is converted to mp3 in the background, so the file can be used at once and its audio is replaced by the mp3 shortly after. Audio that cannot be read answers 422. Responds 201 with the sound file; the audio itself is never inlined (use audio_url).
Required scope. An API key needs the sound-files:write scope. A user bearer token passes only for a user with the write sound files permission (as in Cockpit), otherwise 403. A key that only holds sound-files can read but not write: 403.
Tenancy. The PBX is the caller's. An id of another PBX answers 404, the same as an id that does not exist. A write marks the PBX for a configuration push and is recorded in the change log under the API key.
Text fields. A name, label, prefix or announcement text that holds ${, $[, a line break or another control character (below 0x20, a tab excepted) is refused with 422 on that field, because the PBX dialplan would evaluate it. Free text such as comment, description and notes may hold line breaks.
User bearer token. Default authentication for customer-facing endpoints.
Obtain a token by calling POST /login with your credentials, then send it
on every subsequent request as Authorization: Bearer <token>. The token
inherits the permissions and PBX scope of the authenticated user.
- HTTP Authorization Scheme
bearer- Bearer format
Bearer <token>
API key created on the Cockpit Integrations page (an "API key" integration).
It is a bearer token owned by the customer's PBX and limited to the scopes
selected when the key was created (e.g. phone-numbers, push-configuration).
Send it in the Authorization header:
Authorization: Bearer <api_key>
Manage keys (create / reveal / revoke) from Integrations → New integration → API key.
- HTTP Authorization Scheme
bearer
application/jsonRequest body · required · multipart/form-data
GreetingOpening hoursannouncement musicannouncementResponses
550e8400-e29b-41d4-a716-446655440000550e8400-e29b-41d4-a716-446655440001550e8400-e29b-41d4-a716-446655440002Welcome announcementPlayed at the start of the main IVRWelcome to Customer Support. Press 1 for sales, 2 for support.voice_en_us_female_1{"stability":0.75,"similarity_boost":0.5}ai_generated uploaded_fileuploaded_fileannouncement musicannouncementenhttps://api.example.com/sound-files/550e8400-e29b-41d4-a716-446655440000/audio?signature=abc123&expires=17092800002024-03-01T08:29:07Z2024-03-01T08:29:07ZAuthorization Token is missingerrorsobject
https://cockpit.voxbi.com/api/v1/sound-files
curl -X POST 'https://cockpit.voxbi.com/api/v1/sound-files' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-F 'name=Greeting' \
-F 'comment=Opening hours' \
-F 'type=announcement' \
-F 'audio=@/path/to/audio'
const body = new FormData();
body.append('name', 'Greeting');
body.append('comment', 'Opening hours');
body.append('type', 'announcement');
body.append('audio', fileInput.files[0]); // /path/to/audio
const response = await fetch('https://cockpit.voxbi.com/api/v1/sound-files', {
method: 'POST',
headers: { Authorization: `Bearer ${YOUR_TOKEN}` },
body,
});
const data = await response.json();
console.log(data);
import requests
response = requests.post(
'https://cockpit.voxbi.com/api/v1/sound-files',
headers={'Authorization': f'Bearer {YOUR_TOKEN}'},
data={
'name': 'Greeting',
'comment': 'Opening hours',
'type': 'announcement',
},
files={
'audio': open('/path/to/audio', 'rb'),
},
)
response.raise_for_status()
data = response.json()
print(data)
<?php
$ch = curl_init('https://cockpit.voxbi.com/api/v1/sound-files');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_TOKEN']);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'name' => 'Greeting',
'comment' => 'Opening hours',
'type' => 'announcement',
'audio' => new CURLFile('/path/to/audio'),
]);
$data = json_decode(curl_exec($ch), true);
print_r($data);
{ … }
{ … }
{ … }
private, must-revalidatekeep-aliveapplication/jsonOrigin6057{ … }
application/json{ … }
"errors": { … }
"name": [ … ],
"type": [ … ],
"audio": [ … ]
application/json{ … }
30{ … }
60application/json