Skip to content

Replace a phone number (user, pbx)

put /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.

HTTP: bearerAuth

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>
HTTP: IntegrationApiKey

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
id path · string · uuid *
Identifier of the phone number, which must belong to the caller's own PBX.
accept header · string
example: application/json

Request body · required · application/json

Request schema
namestring | null
Label of the number.
length: 2–64
is_activeboolean
Whether the number is active.
default_carrier_idstring | null · uuid
Default SIP carrier of this PBX (a carrier in the trash is refused).
fallback_carrier_idstring | null · uuid
Fallback SIP carrier of this PBX. Must differ from the default carrier.
languagestring | null
Announcement language for calls to this number: a code the PBX has under Configuration > Attributes > Languages, or `auto` / `null` for no override. Only available when announcement languages are enabled for the PBX; otherwise any value other than `auto` / `null` answers 422.
handling_strategyobject | null
How incoming calls to the number are handled. `null` clears it. Every id must belong to this PBX. The keys depend on `type`: - `default`: `default_callflow_id`, `no_ext_match_callflow_id` (call flows, optional) - `rewrite`: `prefix_to_add` and/or `prefix_to_remove` (at least one, up to 24 characters), optionally `default_callflow_id`, `no_ext_match_callflow_id` - `call_flow`: `call_flow_id` (required) - `extension`: `extension_id` (required) - `user`: `user_id` (required) - `sip_device`: `sip_device_id` (required) Keys that do not belong to the type are ignored.
typestring
enum: default rewrite call_flow extension user sip_device
default_callflow_idstring | null · uuid
no_ext_match_callflow_idstring | null · uuid
prefix_to_addstring | null
length: 0–24
prefix_to_removestring | null
length: 0–24
call_flow_idstring | null · uuid
extension_idstring | null · uuid
user_idstring | null · uuid
sip_device_idstring | null · uuid
usersarray<string>
Users (type `user`) of this PBX that get the number as an outgoing number. Replaces the whole set: send `[]` to remove them all. Left out on a PATCH, the set stays.
[]string · uuid
groupsarray<string>
Groups of this PBX assigned to the number. Replaces the whole set.
[]string · uuid
sip_devicesarray<string>
SIP devices of this PBX assigned to the number. Replaces the whole set.
[]string · uuid

Responses

OK. The phone number as saved, with its `users`, `groups` and `sip_devices`.
Response schema
id*string · uuid
Phone number identifier
read-only
example: 550e8400-e29b-41d4-a716-446655440000
pbx_id*string · uuid
Pbx identifier (tenant)
example: 550e8400-e29b-41d4-a716-446655440001
default_carrier_idstring | null · uuid
Default outbound SIP carrier for calls placed via this number
example: 550e8400-e29b-41d4-a716-446655440002
fallback_carrier_idstring | null · uuid
Fallback SIP carrier used when the default carrier is unreachable
example: 550e8400-e29b-41d4-a716-446655440003
namestring | null
Human-readable label for the number
length: 0–64
example: Support line
languagestring | null
Announcement language for calls to this number (channel language). `null` inherits the system default; ISO 639 code otherwise.
length: 0–10
example: fr
number*string
Phone number in E.164 (without leading +) or local format
length: 0–15
example: 12125550100
international_prefixstring | null
International dialling prefix associated with the number
length: 0–15
example: 1
is_rootboolean
Whether this DID is a root number (parent of suffixed CIDs)
example: 1
is_activeboolean
Whether the number is provisioned and routable
example: 1
sync_sourcestring
Provisioning origin of this number
enum: manual provision
example: manual
handling_strategyobject | null
Optional inbound routing configuration. `type` discriminates the shape of `config`.
typestring
enum: default rewrite call_flow extension user sip_device
example: call_flow
default_callflow_idstring | null · uuid
no_ext_match_callflow_idstring | null · uuid
prefix_to_removestring | null
prefix_to_addstring | null
call_flow_idstring | null · uuid
extension_idstring | null · uuid
user_idstring | null · uuid
sip_device_idstring | null · uuid
usersarray<string>
Ids of the users this number may be used by as an outgoing number (the "assigned to" lists of the number in Cockpit). Present on show and on a write, not on the list.
read-only
[]string · uuid
groupsarray<string>
Ids of the groups assigned to the number. Present on show and on a write, not on the list.
read-only
[]string · uuid
sip_devicesarray<string>
Ids of the SIP devices assigned to the number. Present on show and on a write, not on the list.
read-only
[]string · uuid
number_and_namestring
Convenience label combining the number and its name
read-only
example: 12125550100 (Support line)
number_without_international_prefixstring
The number with its international prefix stripped
read-only
example: 2125550100
created_atstring | null · date-time
read-only
example: 2024-03-01T08:29:07Z
updated_atstring | null · date-time
read-only
example: 2024-03-01T08:29:07Z
Authorization Token Missing. This error is returned when the authorization token is missing.
Response schema
errorstring
Error message
example: Authorization Token is missing
Forbidden. The bearer token authenticated successfully but does not carry the scope this endpoint requires. Re-create the Integrations API key with the missing scope selected (Integrations > New integration > API key). On a write with a user bearer token, the user lacks the Cockpit permission the same change needs (the message names it).
Response schema
messagestring
Not Found. No such record exists inside the caller's PBX. A record that belongs to another PBX returns exactly this response, so the API never reveals whether a foreign id exists.
Response schema
errorstring
Always `Resource not found`.
messagestring
Present on some answers only.
Unprocessable Entity. The change failed validation. `errors` maps each rejected field (or path into the body, such as `handling_strategy.call_flow_id` or `users.0`) to its messages and `message` repeats the first one. Nothing was written.
Response schema
messagestring
The first validation message, repeated for convenience.
errorsobject
Field name (or path into the body) to the list of messages for it.
Free-form object
Locked. A restore is running on the PBX, so changes to it are paused until the restore finishes. Nothing was saved. Retry after the number of seconds in the `Retry-After` header. Reads are not affected.
Response schema
messagestring
Too Many Requests. The rate limit for this action has been exceeded. Retry after the window indicated by the Retry-After header.
Response schema
messagestring
Server error. An unexpected condition was encountered on the server and the request could not be completed. The body is a generic JSON envelope with a `message` field. The response is logged on the server side; quote the request URL + timestamp when reporting an issue.
Response schema
messagestring
exceptionstring
Only present in non-production environments.
filestring
Only present in non-production environments.
lineinteger
Only present in non-production environments.
put https://cockpit.voxbi.com/api/v1/phone-numbers/{id}
Base URL
Request sample
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);
Sample request
{ … }
"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": []
}
{ … }
"id": "550e8400-e29b-41d4-a716-446655440000",
"pbx_id": "550e8400-e29b-41d4-a716-446655440001",
"default_carrier_id": "550e8400-e29b-41d4-a716-446655440002",
"fallback_carrier_id": null,
"name": "Reception",
"number": "35220000000",
"international_prefix": "352",
"is_root": false,
"is_active": true,
"sync_source": "manual",
"handling_strategy": { … },
"type": "call_flow",
"call_flow_id": "550e8400-e29b-41d4-a716-446655440020"
},
"number_and_name": "35220000000 (Reception)",
"number_without_international_prefix": "20000000",
"language": null,
"users": [ … ],
"550e8400-e29b-41d4-a716-446655440003"
],
"groups": [],
"sip_devices": [],
"created_at": "2024-03-01T08:29:07Z",
"updated_at": "2024-03-02T09:00:00Z"
}
Host string
example: cockpit.voxbi.com
Date string
example: Mon, 16 Oct 2023 14:08:48 GMT
Connection string
example: close
Cache-Control string
example: no-cache, private
Content-Type string
example: application/json
X-RateLimit-Limit integer
example: 60
X-RateLimit-Remaining integer
example: 59
Vary string
example: Origin
{ … }
"error": "Authorization Token is missing"
}
Cache-Control string
example: private, must-revalidate
Connection string
example: keep-alive
Content-Type string
example: application/json
Vary string
example: Origin
X-RateLimit-Limit integer
Max requests allowed in the current rate-limit window.
example: 60
X-RateLimit-Remaining integer
Requests remaining in the current rate-limit window.
example: 57
{ … }
"message": "Invalid ability provided."
}
Content-Type string
example: application/json
{ … }
"error": "Resource not found"
}
Content-Type string
example: application/json
{ … }
"message": "The number field cannot be changed through the API.",
"errors": { … }
"number": [ … ]
"The number field cannot be changed through the API."
]
}
}
Content-Type string
example: application/json
{ … }
"message": "A restore is running on this PBX. Changes are paused until it finishes."
}
Retry-After integer
Seconds to wait before retrying the write.
example: 30
{ … }
"message": "Too Many Attempts."
}
Retry-After integer
Seconds to wait before retrying.
example: 60
Content-Type string
example: application/json
{ … }
"message": "Server Error"
}