Set number routing
set_number_routingSet where a phone number should route incoming calls: to a voice agent (mode "agent" + agentId), to another phone number (mode "forward" + forwardTo), to your own SIP PBX (mode "sip" + sipUri, optionally with sipUsername/sipPassword), or turn routing off entirely (mode "none"). Mode "forward" needs at least one credit top-up first: on an account that has never topped up, turning forwarding on returns insufficient_credit (the agent and inbound calls keep working; a number that is already forwarded can change its target). For mode "sip": we first send an unauthenticated INVITE; if the target challenges it with 401/407 and rejects the call without credentials, set sipUsername and sipPassword - verified with a live call to Vapi's native SIP number, which challenges and accepts credentials regardless of their content, so this alone fixed a call that never rang. Exception: a Vapi BYO SIP trunk address (.sip.vapi.ai, or .sip.eu.vapi.ai for a Vapi organization in the EU region) takes NO credentials - Vapi recognises our calls by the source IP in the trunk's gateways (ip 81.31.45.0, netmask 24; the default netmask 32 lets in a single address only) and with a login the call never connects, so sipUsername/sipPassword together with such an address are rejected with validation. Whether your own PBX also connects the call is up to it; a target that never challenges, or challenges but rejects the credentials, still needs a different fix - allow our signalling by IP instead: 81.31.45.0/24, in practice 81.31.45.51 and 81.31.45.56. Leave both fields empty for an unauthenticated PBX (the current default). Each of sipUsername/sipPassword is retained independently when the field is omitted from the call (e.g. omitting both while only changing sipUri keeps the saved credentials unchanged; list_numbers returns sipUsername, and hasSipPassword tells you a password is stored). One exception: if the new sipUri points at a different server than the stored one (the host after the @ sign), the saved password is NOT reused and the call is rejected until you send sipPassword again - a stored password is never forwarded to a server the customer did not enter it for. Sending a field as an explicit empty string clears just that field - so to remove authentication entirely, send both sipUsername and sipPassword as empty strings. A non-empty sipUsername with no password saved (and no sipPassword sent) - or vice versa - is rejected: fill in both fields together the first time you set up authentication. Same data as PATCH /v1/numbers/{e164} (response schema in /openapi.json).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"e164": "<e164>",
"mode": "<mode>"
},
"name": "set_number_routing"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| e164 | Yes | Phone number to configure, in E.164 format with the country code, for example +420777123456. Must already belong to this account, from list_numbers. | |
| mode | Yes | Where calls to this number go: agent (an AI agent answers, needs agentId), forward (rings another number, needs forwardTo), sip (your own PBX, needs sipUri), none (unrouted). | |
| sipUri | No | SIP URI of your own PBX to route calls to, for example sip:100@pbx.example.com. Required when mode is sip, ignored otherwise. | |
| agentId | No | Id of the agent that should answer calls to this number, from list_agents. Required when mode is agent, ignored otherwise. | |
| forwardTo | No | Phone number to forward calls to, in E.164 format with the country code, for example +420777123456. Required when mode is forward, ignored otherwise. | |
| sipPassword | No | SIP digest password matching sipUsername. Send together with sipUsername; sending both as empty strings clears stored credentials, omitting both keeps them unchanged. Never returned by list_numbers. | |
| sipUsername | No | SIP digest username for the target in sipUri, only if it challenges the call with 401 or 407 - never for a Vapi BYO trunk address, which is rejected. Send together with sipPassword; sending both as empty strings clears stored credentials, omitting both keeps them unchanged. |