Replace a phone number (user, pbx)
/phone-numbers/{id}
Full write of a phone number's settable fields: a field left out is cleared (name, carriers, handling_strategy, language) or emptied (users, groups, sip_devices); is_active stays as it is when left out.
Only edit: phone numbers come from orders, so there is no create and no delete here, and number, international_prefix, is_root, sync_source and pbx_id are refused with 422. The assignments users, groups and sip_devices are lists of ids; each one replaces that whole set. The incoming handling_strategy is validated by the same rules as the cockpit form and the configuration import: a type that needs a target is refused without it, and every id must belong to this PBX.
Required scope. An API key needs the phone-numbers:write scope. A user bearer token passes only for a user with the write phone numbers permission (as in Cockpit), otherwise 403. A key that only holds phone-numbers 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, and a carrier, user, group, SIP device or call flow of another PBX answers 422. 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 · application/json
handling_strategyobject | null
default rewrite call_flow extension user sip_deviceusersarray<string>
groupsarray<string>
sip_devicesarray<string>
Responses
550e8400-e29b-41d4-a716-446655440000550e8400-e29b-41d4-a716-446655440001550e8400-e29b-41d4-a716-446655440002550e8400-e29b-41d4-a716-446655440003Support linefr12125550100111manual provisionmanualhandling_strategyobject | null
default rewrite call_flow extension user sip_devicecall_flowusersarray<string>
groupsarray<string>
sip_devicesarray<string>
12125550100 (Support line)21255501002024-03-01T08:29:07Z2024-03-01T08:29:07ZAuthorization Token is missingerrorsobject
https://cockpit.voxbi.com/api/v1/phone-numbers/{id}
curl -X PUT 'https://cockpit.voxbi.com/api/v1/phone-numbers/{id}' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
--data '{"name":"Reception","default_carrier_id":"550e8400-e29b-41d4-a716-446655440002","handling_strategy":{"type":"call_flow","call_flow_id":"550e8400-e29b-41d4-a716-446655440020"},"users":["550e8400-e29b-41d4-a716-446655440003"],"groups":[],"sip_devices":[]}'
const response = await fetch('https://cockpit.voxbi.com/api/v1/phone-numbers/{id}', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${YOUR_TOKEN}`,
},
body: JSON.stringify({
"name": "Reception",
"default_carrier_id": "550e8400-e29b-41d4-a716-446655440002",
"handling_strategy": {
"type": "call_flow",
"call_flow_id": "550e8400-e29b-41d4-a716-446655440020"
},
"users": [
"550e8400-e29b-41d4-a716-446655440003"
],
"groups": [],
"sip_devices": []
}),
});
const data = await response.json();
console.log(data);
import requests
response = requests.put('https://cockpit.voxbi.com/api/v1/phone-numbers/{id}',
headers={'Authorization': f'Bearer {YOUR_TOKEN}'},
json={
"name": "Reception",
"default_carrier_id": "550e8400-e29b-41d4-a716-446655440002",
"handling_strategy": {
"type": "call_flow",
"call_flow_id": "550e8400-e29b-41d4-a716-446655440020"
},
"users": [
"550e8400-e29b-41d4-a716-446655440003"
],
"groups": [],
"sip_devices": []
}
)
response.raise_for_status()
data = response.json()
print(data)
<?php
$context = stream_context_create([
'http' => [
'method' => 'PUT',
'header' => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_TOKEN",
'content' => '{
\"name\": \"Reception\",
\"default_carrier_id\": \"550e8400-e29b-41d4-a716-446655440002\",
\"handling_strategy\": {
\"type\": \"call_flow\",
\"call_flow_id\": \"550e8400-e29b-41d4-a716-446655440020\"
},
\"users\": [
\"550e8400-e29b-41d4-a716-446655440003\"
],
\"groups\": [],
\"sip_devices\": []
}',
],
]);
$response = file_get_contents('https://cockpit.voxbi.com/api/v1/phone-numbers/{id}', false, $context);
$data = json_decode($response, true);
print_r($data);
{ … }
"handling_strategy": { … },
"users": [ … ],
{ … }
"handling_strategy": { … },
"users": [ … ],
cockpit.voxbi.comMon, 16 Oct 2023 14:08:48 GMTcloseno-cache, privateapplication/json6059Origin{ … }
private, must-revalidatekeep-aliveapplication/jsonOrigin6057{ … }
application/json{ … }
application/json{ … }
"errors": { … }
"number": [ … ]
application/json{ … }
30{ … }
60application/json