Phone numbers
Put a number on a trunk, point it at an agent, and route different callers to different agents.
A phone number lives on an active trunk. Inbound, it decides which agent answers. Outbound, it's the caller ID.
{
"trunk_id": "TRUNK_ID",
"e164": "+14155550123",
"label": "Claims line",
"agent_id": "AGENT_ID",
"direction": "both"
}Over the API: POST /v1/phone-numbers.
| Field | Values |
|---|---|
direction | inbound (default), outbound, or both |
agent_id | The agent that answers. Leave it out for an unassigned number |
label | A name for your own benefit |
transport | livekit_sip (default), or twilio_media_streams on an automated Twilio trunk |
The number, trunk, and transport are fixed once created. Like trunks, numbers
provision in the background — poll GET /v1/phone-numbers/{id} until
active.
A number can only be live in one place. If it's already active on another
trunk or in another workspace, you get 409 number_in_use — we won't say
who has it, so archive the other entry or talk to support.
Changing which agent answers
Point the number somewhere else:
{
"agent_id": "OTHER_AGENT_ID"
}Over the API: PATCH /v1/phone-numbers/{id}.
Send null to unassign. The change applies to the next call in; calls
already connected keep the agent they got.
Route by SIP header
One number can send different callers to different agents based on a SIP
header your PBX sets. The usual case is language: X-Language: ar goes to
your Arabic agent, en to your English one.
In the dashboard: SIP trunks → your trunk → edit a number, pick a default inbound agent, and add SIP header routing routes. Routes run in order — the first match wins, and the default answers if nothing matches. Drag to reorder.
{
"agent_id": "DEFAULT_AGENT_UUID",
"inbound_routing_rules": [
{
"match": "all",
"conditions": [
{
"header": "X-Language",
"operator": "contains",
"value": "ar"
},
{
"header": "X-Language",
"operator": "not_contains",
"value": "blocked"
}
],
"agent_id": "ARABIC_AGENT_UUID"
},
{
"match": "any",
"conditions": [
{
"header": "X-Language",
"operator": "contains",
"value": "en"
},
{
"header": "X-English-Caller",
"operator": "exists"
}
],
"agent_id": "ENGLISH_AGENT_UUID"
}
]
}Over the API: PATCH /v1/phone-numbers/{id}.
match is all (AND) or any (OR), and defaults to all.
| Operator | Matches when |
|---|---|
equals / not_equals | The whole value is / isn't the text |
contains / not_contains | The value includes / doesn't include the text |
starts_with / ends_with | The value begins / ends with the text |
exists / not_exists | The header is present / absent |
Header names ignore case. Values ignore case unless you set
case_sensitive: true. Values are compared as received, with no trimming or
list parsing — so contains: ar also matches ar-AE; use equals if you
want only ar. A missing header does not match not_equals or
not_contains.
Up to 32 routes per number, 8 conditions each. A default agent is required while any route exists, and if a route's agent is later archived the default answers rather than the next route.
A PATCH replaces the whole ordered list; omit the field to keep it, send
[] to clear it. Saving routes provisions the header mappings for you — wait
for the number to be active before testing.
Routing happens before the agent's greeting or tools load, so it costs the caller nothing. Twilio Media Streams has no SIP headers, so these rules don't apply there.
Outbound settings
When this number is used as caller ID:
| Field | What it does |
|---|---|
outbound_capacity_mode | inherit (the trunk's limits), fixed, or unlimited |
max_concurrent_outbound | Simultaneous outbound calls, in fixed mode |
outbound_weight | Its relative share when it's in a caller-ID pool |
outbound_draining | Stop giving this number new outbound calls, without unconfiguring it |
Draining is the clean way to retire a number: set it, let the calls in flight finish, then archive.
Finding a number
GET /v1/phone-numbers filters by search, status, direction, transport,
trunk, agent, whether it's assigned, and whether it's draining.
Calls that never connected
Calls to or from this number that were refused before becoming calls — see Calls that never became calls for what the stages mean.
Over the API: GET /v1/phone-numbers/{id}/rejections.
Archiving
Archiving takes the number out of inbound routing and outbound allocation immediately. Past calls keep the number they recorded.
Repair and recovery
POST /v1/phone-numbers/{id}/reconcile (no body; Idempotency-Key and
the point-read ETag) retries failed provisioning or repairs drifted provider
routing. A recent in-flight operation returns 409 with Retry-After; an
accepted 202 follows the creation polling contract.
A crash mid-provisioning leaves the number visible as provisioning;
background recovery reclaims it, typically within about three and a half
minutes of the last progress, without changing the public representation or
rotating the ETag — only a real status or error transition does.