Skip to main content

Phone Numbers

Bring your own account or SIP carrier through Carriers. That Lane A resource is a local implementation awaiting deployment and account acceptance; its imported numbers reuse the binding endpoint described here.

Verified against backend/internal/publicapi/builder_dto.go, phonenumbers_handler.go, phonenumbers_acquire.go, phonenumbers_outbound.go, outbound_agents_core.go, and routes.go.

MethodPathScope
GET/phone-numbersphone_numbers:read
POST/phone-numbersphone_numbers:write
POST/agents/:id/phone-numberphone_numbers:write
DELETE/agents/:id/phone-numberphone_numbers:write
GET/phone-numbers/:id/outbound-agentsphone_numbers:read
PUT/phone-numbers/:id/outbound-agentsphone_numbers:write

Acquiring a number

bash
curl -X POST https://api.voicematrix.ai/api/v1/ext/phone-numbers \
  -H "X-API-Key: vm_live_..." \
  -H "Idempotency-Key: acquire-number-1"

Acquisition is bounded on purpose, not open-ended: numbers are drawn from a pool first, one number per organization, under a hard platform-wide cap, guarded by an advisory lock around both the cap check and the purchase itself, plus a kill switch. Concretely: if you retry this endpoint after a success, the org cap is what stops the second call from also succeeding — not your Twilio account balance. Send the Idempotency-Key anyway; it's the difference between "the retry returns my first number" and "the retry fails cleanly at the org cap," and the former is a much less confusing integration experience.

Binding a number to an agent

bash
curl -X POST https://api.voicematrix.ai/api/v1/ext/agents/<agent-id>/phone-number \
  -H "X-API-Key: vm_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "phone_number_id": "550e8400-e29b-41d4-a716-446655440000" }'
json
{ "agent_id": "...", "phone_number": "+97233822555", "routing_live": true }

routing_live is the field worth reading, not just the 200 status. Binding writes the database row and then updates a LiveKit SIP dispatch rule — internally, that second step can fail silently (logged, not surfaced) on some code paths. This endpoint performs it synchronously and reports the true outcome: if routing_live is false (accompanied by a warning), the database says bound but calls will not actually reach the agent yet. Don't treat a bare 200 as "the line is live" — check the field.

Unbind

text
DELETE /agents/:id/phone-number

List numbers

text
GET /phone-numbers
json
{ "data": [ { "id": "...", "phone_number": "+97233822555", "inbound_agent_id": "...", "bound": true,
              "outbound_agent_ids": ["...", "..."] } ] }

outbound_agent_ids is always an array ([] when no agent calls out from the number).

Inbound binding vs. outbound agents

These are two different links, and changing one never changes the other:

  • Inbound (bound, inbound_agent_id): the one agent that answers calls to the number. A number has at most one. Set it with POST /agents/:id/phone-number; a number already bound to another agent answers 409 PHONE_NUMBER_ALREADY_BOUND.
  • Outbound (outbound_agent_ids): the agents that call out from the number, presenting it as their caller ID. A number can have any number of them (up to 50 per request), and the same agent can be linked to several numbers.

POST /calls takes no from field. It picks the caller ID from your organization's own numbers in this order: a number linked to the calling agent (outbound agents), then a number in the destination's country, then your default number, then your oldest. So once an agent is linked here, its outbound calls present this number. With no number of your own the call is refused (422 NO_OUTBOUND_NUMBER).

Outbound agents

Read

bash
curl https://api.voicematrix.ai/api/v1/ext/phone-numbers/<phone-number-id>/outbound-agents \
  -H "X-API-Key: vm_live_..."
json
{
  "phone_number_id": "550e8400-e29b-41d4-a716-446655440000",
  "phone_number": "+97233822555",
  "outbound_agent_ids": ["3f6c2a3e-8a4b-4c55-9d2e-0a1b2c3d4e5f"],
  "outbound_agents": [ { "id": "3f6c2a3e-8a4b-4c55-9d2e-0a1b2c3d4e5f", "name": "Sales" } ]
}

Replace

bash
curl -X PUT https://api.voicematrix.ai/api/v1/ext/phone-numbers/<phone-number-id>/outbound-agents \
  -H "X-API-Key: vm_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: outbound-agents-1" \
  -d '{ "agent_ids": ["3f6c2a3e-8a4b-4c55-9d2e-0a1b2c3d4e5f", "9b1d4c2e-1f3a-4b5c-8d6e-7f8a9b0c1d2e"] }'

The response has the same shape as the read. The list replaces the current one: agents you leave out are unlinked, and {"agent_ids": []} unlinks every agent. The field is required — a body without agent_ids is refused rather than read as "clear".

Every agent must be a live (not deleted) agent of the number's organization. If any one is not, nothing is changed and the response names the ones that failed. Inbound routing is never touched.

StatusCodeWhen
400VALIDATION_ERRORagent_ids missing, an entry is not a UUID (details.invalid_agent_ids), or more than 50 agents
403INSUFFICIENT_SCOPE · ORGANIZATION_REQUIREDThe key lacks the scope, or is not scoped to one organization
404NOT_FOUNDNo such number in your organization
422AGENT_NOT_IN_ORGANIZATIONOne or more agents are not yours, or were deleted (details.agent_ids). Nothing was written

Each successful change is recorded in your organization's audit log with the agent list before and after, the API key that made it, and the key's user.

Over MCP, the same operations are the list_phone_numbers, get_outbound_agents and set_outbound_agents tools — see MCP Server.

Next