Skip to Content
Phone numbers

Connect a phone number

Permissionphone-numbers:createRetriesIdempotency-Key requiredAuthentication
POST
/phone-numbers

Creates a durable phone-number row and schedules provider routing after commit. Poll resource_url until status is active or error. Use Idempotency-Key so a retry cannot connect the same intent twice.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Use a Voice API key or connected-app OAuth access token. Authentication.

Header Parameters

Idempotency-Key*string

Required. Reuse the same key to retry this write safely. Retries and idempotency.

Match^[A-Za-z0-9!#$%&'*+.^_`|~-]+$
Length1 <= length <= 255

Request Body

application/json
  1. body

Connects a purchased or BYO number to an active SIP trunk. livekit_sip is the default transport. twilio_media_streams is available only on an active twilio_automated trunk and configures Twilio Programmable Voice instead of LiveKit SIP.

direction defaults to inbound. outbound_capacity_mode defaults to inherit; fixed requires max_concurrent_outbound, while that limit is forbidden for inherit and unlimited. agent_id may be omitted to create an unassigned route. At most one of agent_id, flow_id and group_id may be set.

inbound_routing_rules?array<|>

Ordered SIP-header routes. First matching route wins; agent_id on the phone number is the required default. A route may use one legacy condition or a conditions group matched with all (AND) or any (OR). At most 8 conditions are allowed per route and 64 across the number. Requires livekit_sip transport and inbound or both direction. Omit on PATCH to preserve; [] removes all routes; null is invalid. Changes provision header mappings automatically and return provisioning until reconciled. Values ignore case unless case_sensitive is true. Missing headers match only not_exists, never negative comparisons. An archived matching agent falls back to the default agent. Only new calls use changes; existing calls continue with their selected agent.

Itemsitems <= 32
trunk_id*string
Formatuuid
e164*E164PhoneNumber

An E.164 number with a non-zero country code and 7 to 15 digits, or a bare internal number/extension of 1 to 20 [0-9*#] characters (e.g. 103, 2770124).

Match^(\+[1-9][0-9]{7,14}|[0-9*#]{1,20})$
label?string
Lengthlength <= 160
agent_id?string
Formatuuid
flow_id?string

Answer inbound calls with a flow instead of a single agent. The flow's start agent takes the call and the graph's handoffs take over. Mutually exclusive with agent_id, and rejected with 422 unless the flow is dispatchable now (un-archived, at least one agent on the canvas, and a start agent with a published version). Requires the flows entitlement.

Formatuuid
group_id?string

Answer inbound calls with a group of agents. The group's routing strategy picks a member for the caller's number. Mutually exclusive with agent_id, flow_id and inbound_routing_rules (422 conflict). Rejected on twilio_media_streams numbers (422 unsupported_transport) and unless the group exists (not_found), is not archived (archived) and has a member that can take calls now (no_members). Requires the groups entitlement (403 entitlement_required).

Formatuuid
direction?PhoneNumberDirection
Value in"inbound""outbound""both"
transport?PhoneNumberTransport
Value in"livekit_sip""twilio_media_streams"
outbound_capacity_mode?PhoneNumberOutboundCapacityMode
Value in"inherit""fixed""unlimited"
max_concurrent_outbound?integer
Range1 <= value
outbound_weight?integer
Range1 <= value <= 10000
Default1
outbound_draining?boolean
Defaultfalse

Response Body

The phone number was created and provider provisioning was scheduled.

application/json
  1. response
id*string
Formatuuid
status*string
resource_url*string
Match^/v1/phone-numbers/[0-9a-f-]+$
poll_after_seconds*integer
Range1 <= value
provisioning_async*boolean
Example Request
curl -X POST 'https://api.kejue.co/v1/phone-numbers' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "trunk_id": "d1c0247b-6570-4df5-9107-7986a22149d1",  "e164": "string"}'
Example Response
{  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",  "status": "provisioning",  "resource_url": "string",  "poll_after_seconds": 1,  "provisioning_async": true}