Create a phone number
curl --request POST \
--url https://voice-api.onclarity.com/v1/projects/{projectId}/phone-numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"e164": "14155550123",
"sip_trunk_id": "2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f",
"voice_inbound": true,
"voice_outbound": true,
"outbound_trunk_ids": [
"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"
]
}
'import requests
url = "https://voice-api.onclarity.com/v1/projects/{projectId}/phone-numbers"
payload = {
"e164": "14155550123",
"sip_trunk_id": "2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f",
"voice_inbound": True,
"voice_outbound": True,
"outbound_trunk_ids": ["9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
e164: '14155550123',
sip_trunk_id: '2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f',
voice_inbound: true,
voice_outbound: true,
outbound_trunk_ids: ['9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d']
})
};
fetch('https://voice-api.onclarity.com/v1/projects/{projectId}/phone-numbers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"phone_number": {
"id": "7b0e2c4a-1f3d-4e8a-9c21-5d6f7a8b9c01",
"project_id": "3f6c1a52-8d0e-4b8f-9a51-2c7d4e0b9f13",
"e164": "14155550123",
"provider": null,
"voice_inbound": true,
"voice_outbound": true,
"sip_trunk_id": "2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f",
"outbound_trunk_ids": [
"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"
],
"outbound_agents": [],
"outbound_agents_inherited": [],
"max_calls_per_second": 1,
"abuse_protection_exempt": false,
"max_calls_per_second_updated_by": null,
"max_calls_per_second_updated_at": null,
"created_at": "Wed Nov 11 2026 09:30:00 GMT+0000 (Coordinated Universal Time)",
"updated_at": "Wed Nov 11 2026 09:30:00 GMT+0000 (Coordinated Universal Time)"
}
}{
"error": "Invalid or revoked token"
}{
"error": "publish_capability_required",
"code": "PUBLISH_CAPABILITY_REQUIRED"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "Phone number 14155550123 is already registered"
}{
"error": "provider: A phone number cannot belong to both a provider and a SIP trunk",
"issues": [
{
"path": "provider",
"code": "custom",
"message": "A phone number cannot belong to both a provider and a SIP trunk"
}
]
}{
"error": "<string>",
"code": "<string>"
}Phone numbers
Create a phone number
Adds a number to the project. It belongs either to a carrier (provider) or to one of your inbound SIP trunks (sip_trunk_id), never both, and a number can be in only one project. Adding a number to an active inbound SIP trunk updates the trunk so it takes calls on the new number. Needs the publish permission, which organization API keys carry.
POST
/
v1
/
projects
/
{projectId}
/
phone-numbers
Create a phone number
curl --request POST \
--url https://voice-api.onclarity.com/v1/projects/{projectId}/phone-numbers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"e164": "14155550123",
"sip_trunk_id": "2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f",
"voice_inbound": true,
"voice_outbound": true,
"outbound_trunk_ids": [
"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"
]
}
'import requests
url = "https://voice-api.onclarity.com/v1/projects/{projectId}/phone-numbers"
payload = {
"e164": "14155550123",
"sip_trunk_id": "2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f",
"voice_inbound": True,
"voice_outbound": True,
"outbound_trunk_ids": ["9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
e164: '14155550123',
sip_trunk_id: '2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f',
voice_inbound: true,
voice_outbound: true,
outbound_trunk_ids: ['9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d']
})
};
fetch('https://voice-api.onclarity.com/v1/projects/{projectId}/phone-numbers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"phone_number": {
"id": "7b0e2c4a-1f3d-4e8a-9c21-5d6f7a8b9c01",
"project_id": "3f6c1a52-8d0e-4b8f-9a51-2c7d4e0b9f13",
"e164": "14155550123",
"provider": null,
"voice_inbound": true,
"voice_outbound": true,
"sip_trunk_id": "2d4f6a8c-0e1b-4c3d-8e5f-7a9b1c2d3e4f",
"outbound_trunk_ids": [
"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"
],
"outbound_agents": [],
"outbound_agents_inherited": [],
"max_calls_per_second": 1,
"abuse_protection_exempt": false,
"max_calls_per_second_updated_by": null,
"max_calls_per_second_updated_at": null,
"created_at": "Wed Nov 11 2026 09:30:00 GMT+0000 (Coordinated Universal Time)",
"updated_at": "Wed Nov 11 2026 09:30:00 GMT+0000 (Coordinated Universal Time)"
}
}{
"error": "Invalid or revoked token"
}{
"error": "publish_capability_required",
"code": "PUBLISH_CAPABILITY_REQUIRED"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "Phone number 14155550123 is already registered"
}{
"error": "provider: A phone number cannot belong to both a provider and a SIP trunk",
"issues": [
{
"path": "provider",
"code": "custom",
"message": "A phone number cannot belong to both a provider and a SIP trunk"
}
]
}{
"error": "<string>",
"code": "<string>"
}Authorizations
Your organization API key (it starts with anek_org_). The same key works on the Voice API and the Support API. See Authentication.
Body
application/json
Send exactly one of provider and sip_trunk_id. Fields not listed here are ignored.
Response
The number was created. outbound_agents and outbound_agents_inherited are always empty here; read the number to see which agents present it.