Phone numbers and SIP
MoreVoice reaches the phone network over SIP: you bring the lines your carrier gives you, and MoreVoice answers and places calls on them. A connection is one such line. The phone numbers of your account are the numbers those connections answer and call from. Once a line is connected, inbound routes decide who answers each number.
Connections
Section titled “Connections”There are two kinds:
Kind (type) |
How calls reach MoreVoice |
|---|---|
SIP trunk (trunk) |
Your carrier sends calls straight to MoreVoice’s address. It usually trusts IP addresses, so a username is only needed when the trunk uses digest authentication. |
Registration account (registration) |
MoreVoice registers to your provider like a desk phone, with a username and a password, and the provider sends calls to that registration. A cloud PBX extension is a registration account. |
Connections speak plain SIP over UDP with G.711 audio: A-law (pcma, the standard in Israel and Europe) and μ-law (pcmu, the standard in the US). Every connection runs through the same engine: AI agents, routing, recordings and limits work the same way. backend: "freeswitch" runs a connection through the optional FreeSWITCH front end instead of the built-in SIP stack; nothing else changes.
Connect a SIP trunk
Section titled “Connect a SIP trunk”Give your carrier MoreVoice’s SIP address (the dashboard shows it under SettingsSIP / Phone, in the Phone system card), then create the connection with the carrier’s host and the addresses it sends calls from:
# Connect a SIP trunk: your carrier sends calls to MoreVoice, from these IP addresses only. Live keys only.curl https://api.morevoice.ai/v1/connections \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "name": "Main trunk", "type": "trunk", "host": "sip.carrier.example.com", "inbound_acl": ["198.51.100.0/24"], "caller_ids": ["+97231234567", "+97231234568"], "default_caller_id": "+97231234567", "max_channels": 30, "inbound_reserve_pct": 20, "max_cps": 5, "overflow_policy": "unavailable" }'import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY (a live key: connections are live-only)
// Connect a SIP trunk: your carrier sends calls to MoreVoice, from these IP addresses only.const connection = await mv.connections.create({ name: "Main trunk", type: "trunk", host: "sip.carrier.example.com", inbound_acl: ["198.51.100.0/24"], caller_ids: ["+97231234567", "+97231234568"], default_caller_id: "+97231234567", max_channels: 30, inbound_reserve_pct: 20, // 6 of the 30 channels stay free for inbound calls max_cps: 5, overflow_policy: "unavailable", // 503 when full: the carrier can fail over to its backup route});console.log(connection.id, connection.status.state);import osimport uuid
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"} # a live key: connections are live-only
# Connect a SIP trunk: your carrier sends calls to MoreVoice, from these IP addresses only.response = requests.post( f"{API}/connections", headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())}, json={ "name": "Main trunk", "type": "trunk", "host": "sip.carrier.example.com", "inbound_acl": ["198.51.100.0/24"], "caller_ids": ["+97231234567", "+97231234568"], "default_caller_id": "+97231234567", "max_channels": 30, "inbound_reserve_pct": 20, # 6 of the 30 channels stay free for inbound calls "max_cps": 5, "overflow_policy": "unavailable", # 503 when full: the carrier can fail over to its backup route }, timeout=30,)response.raise_for_status()connection = response.json()print(connection["id"], connection["status"]["state"])| Field | What it does |
|---|---|
host, port |
The carrier’s SIP host and port (5060 by default). |
inbound_acl |
The addresses, single or CIDR ranges, that may send calls on this connection besides host. |
caller_ids |
The numbers the carrier lets you present on outbound calls. They also become phone numbers of your account. |
default_caller_id |
The caller ID of an outbound call that names none. |
max_channels |
Calls in progress at once on the connection; 0 means no limit. |
inbound_reserve_pct |
A share of the channels outbound calls can’t take, so customers can always get through. |
max_cps |
New outbound calls per second. |
overflow_policy |
The answer when no channel is free: busy (486 Busy) or unavailable (503, which lets a carrier with a backup route fail over). |
answer_inbound |
false refuses every inbound call on the connection with 486 Busy. |
inbound_assistant_id |
The assistant that answers when no inbound route matches a call. |
Register to a provider
Section titled “Register to a provider”A registration account needs the provider’s host, the account’s username and its password. register: true keeps the registration alive, renewing it every register_expires_seconds (300 by default):
# A registration account: MoreVoice registers to your provider like a desk phone. The password is write-only.curl https://api.morevoice.ai/v1/connections \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "name": "Office line", "type": "registration", "host": "pbx.provider.example.com", "username": "0312345670", "password": "'"$SIP_PASSWORD"'", "register": true, "max_channels": 4 }'
# After you change the account at the provider, register again now and read the result.curl -X POST https://api.morevoice.ai/v1/connections/$CONNECTION_ID/register \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Idempotency-Key: $(uuidgen)"import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY (a live key)
// A registration account: MoreVoice registers to your provider like a desk phone. The password is write-only.const line = await mv.connections.create({ name: "Office line", type: "registration", host: "pbx.provider.example.com", username: "0312345670", password: process.env.SIP_PASSWORD!, register: true, max_channels: 4,});
// After you change the account at the provider, register again now and read the result.const registration = await mv.connections.register(line.id);console.log(registration.status.state, registration.status.error ?? "");import osimport uuid
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"} # a live key
# A registration account: MoreVoice registers to your provider like a desk phone. The password is write-only.response = requests.post( f"{API}/connections", headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())}, json={ "name": "Office line", "type": "registration", "host": "pbx.provider.example.com", "username": "0312345670", "password": os.environ["SIP_PASSWORD"], "register": True, "max_channels": 4, }, timeout=30,)response.raise_for_status()line = response.json()
# After you change the account at the provider, register again now and read the result.response = requests.post(f"{API}/connections/{line['id']}/register", headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())}, timeout=30)response.raise_for_status()status = response.json()["status"]print(status["state"], status["error"] or "")The password is write-only: no answer ever contains it, and password_set says whether one is stored. To change it, send a new password; to remove it, send null. POST /v1/connections/{id}/register registers again at once, for example after you changed the account at the provider, and answers with the state right after the attempt.
Who may send calls
Section titled “Who may send calls”MoreVoice accepts a new inbound call (INVITE) only when it comes from the connection’s host or from an address in its inbound_acl. Anything else is refused with 403 Forbidden, so nobody can reach your assistants by sending calls to MoreVoice’s address directly. When several connections could own a call (two extensions of the same PBX, for example), MoreVoice picks the one whose username or caller IDs match the dialled number.
Connection status
Section titled “Connection status”Every connection carries its live status:
status.state |
Meaning |
|---|---|
registered |
A registration account is registered and ready. |
listening |
A trunk is ready to receive calls. |
registering |
A registration is in progress. |
incomplete |
Settings are missing (a host, a username). |
failed |
The last registration failed: status.error says why. |
disabled |
The connection is switched off (enabled: false). |
active_calls counts the calls on the connection right now. Subscribe to the connection.status_changed event to hear when a registration goes up or down.
Changes to a connection apply to the next call; calls in progress are not affected. A connection that carries calls can’t be deleted (409).
Phone numbers
Section titled “Phone numbers”GET /v1/phone_numbers lists the numbers of your account, whatever their source:
source |
Where the number comes from |
|---|---|
connection |
A number of one of your SIP connections: its caller_ids, and the numbers your inbound routes match exactly. |
provisioned |
A number bought through MoreVoice. |
sandbox |
A test-mode number on the virtual carrier (test keys list only these). |
# The numbers on your account: their source, whether they answer inbound calls, and whether they can be a caller ID.curl "https://api.morevoice.ai/v1/phone_numbers?limit=100" \ -H "Authorization: Bearer $MOREVOICE_API_KEY"import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY
// The numbers on your account: their source, whether they answer inbound calls, and whether they can be a caller ID.for await (const n of mv.phoneNumbers.list({ limit: 100 })) { console.log(n.e164, n.source, n.inbound ? "inbound" : "", n.outbound_caller_id ? "caller ID" : "");}import os
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}
# The numbers on your account: their source, whether they answer inbound calls, and whether they can be a caller ID.params = {"limit": 100}while True: response = requests.get(f"{API}/phone_numbers", headers=HEADERS, params=params, timeout=30) response.raise_for_status() page = response.json() for n in page["data"]: print(n["e164"], n["source"], "inbound" if n["inbound"] else "", "caller ID" if n["outbound_caller_id"] else "") if not page["has_more"]: break params["starting_after"] = page["next_cursor"]inbound says whether calls to the number are answered, and inbound_route_id names the route that answers them. outbound_caller_id says whether the number can be presented on outbound calls. To call from a number, pass its ID as from_number_id when you create a call: it picks the connection and the caller ID together.
Numbers bought or ported through MoreVoice (source: provisioned) are ordered in the dashboard, on the SettingsPhone numbers tab (see the help centre), or bought with a live key (below), and your systems hear about them through the events number.provisioned, number.released, number.port_foc_scheduled, number.port_completed and number.port_rejected (see the event catalogue). In test mode, POST /v1/phone_numbers gives you a sandbox number to dial with POST /v1/test_helpers/inbound_calls.
Buy a number over the API
Section titled “Buy a number over the API”When number purchases are enabled for your organisation, a live key can buy a number itself:
GET /v1/phone_numbers/availablelists the numbers on offer, in number order, with yourmonthly_priceand anysetup_price. Filter witharea_code(for example03or073) orcontains.POST /v1/phone_numberswith the item’sidasavailable_id(or itsnumber), an optionallabel, and at most one ofassistant_id,flow_idorinbound_route_idfor its inbound calls (none: your most recently updated assistant). The answer is the new number (201), andnumber.provisionedfollows.
The number is billed monthly at its price from the next billing anniversary, plus the setup fee if it has one, exactly as when you buy it in the dashboard. Send an Idempotency-Key: a retry with the same key resumes the same order instead of buying a second number. A number someone else took meanwhile answers 409 number_unavailable (pick another one), and a plan limit or a prepaid balance that doesn’t cover the first month answers 402. Without purchases enabled, both operations answer 403 feature_unavailable; test keys get sandbox numbers as before.
Port your numbers over the API
Section titled “Port your numbers over the API”When number porting is enabled for your organisation, a live key can ask to move Israeli numbers you hold at another provider to MoreVoice Telephony. In Israel a port goes through the carriers by hand: you sign a letter of authorization (LOA), our staff check the request and send it to the carrier, and the carrier sets the date.
- Upload the signed LOA and the latest invoice from your current provider with
POST /v1/files(purpose: "port_document"; a PDF, JPEG or PNG of up to 10 MB, as a multipartfilepart or base64 JSON). Each answer is afile_…id. A file is used once, and an unused one is deleted after 7 days. POST /v1/portswith thenumbers(fixed-line, 07x or mobile, up to 50),current_carrier, theaccount_holder(nameand eitherid_numberorcompany_id), optionallyaccount_number,billing_addressandrequested_date, and the two file ids asloa_file_idandinvoice_file_id. The port is sent at once (201,status: "submitted").- Follow it with
GET /v1/ports/{id}or thenumber.port_updatedevent, which carriesprevious_statuson every change.POST /v1/ports/{id}/cancelwithdraws it whilecancellableistrue.
status |
Meaning |
|---|---|
submitted |
Sent, waiting for our review. |
in_review |
Our staff are checking the request and its documents. |
submitted_to_carrier |
The request is with the carrier, waiting for a date. |
scheduled |
The carrier set the date: port_date is when the numbers move. |
completed |
The numbers are phone numbers of your account (number.port_completed, one event per number), and their monthly fee starts. |
docs_required |
Another document is needed: the timeline note says which. Fix it in the dashboard. |
rejected |
Refused: rejection_reason says why (number.port_rejected). |
cancelled |
Withdrawn. |
Toll-free, shared-cost and premium numbers (1-800, 1-700 …) and foreign numbers can’t be ported (400, param: "numbers"). A number that is already on MoreVoice or in another open port answers 409 with details.reason, and so does a twenty-first port in progress. Ported numbers arrive routed like a new number; point them at an assistant with inbound routes. Without porting enabled every operation answers 403 feature_unavailable, and test keys get 403 live_only.
Release a number over the API
Section titled “Release a number over the API”When number releases are enabled for your organisation, a live key can release one of your numbers with DELETE /v1/phone_numbers/{id} (otherwise it answers 501; release numbers in the dashboard).
- The number stops answering calls: its inbound route goes with it, whatever it answered with (an assistant, a flow, a queue or a person).
- A number bought through MoreVoice goes back to the platform. Its monthly fee stops: no further month is billed, and the month already billed is not refunded. A number of your own SIP connection is removed from the connection’s caller IDs, and the inbound routes that match it exactly are deleted.
- While campaigns present it as caller ID, caller-ID pools hold it, desk phones present it or other inbound routes match it, the answer is
409 number_in_use, anddetails.useslists them.?force=truedetaches it from all of them first: the campaigns and phones fall back to the line’s default caller ID. number.releasedfollows. Releasing a released number again answers200. A release can’t be undone: the number may go to another customer.
# Release a number. While campaigns, caller-ID pools, desk phones or other routes use it, the answer is# 409 number_in_use with details.uses; add ?force=true to detach it from them and release it anyway.curl -X DELETE https://api.morevoice.ai/v1/phone_numbers/$PHONE_NUMBER_ID \ -H "Authorization: Bearer $MOREVOICE_API_KEY"import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEYconst numberId = process.env.PHONE_NUMBER_ID!;
// Release a number. While campaigns, caller-ID pools, desk phones or other routes use it, the answer is// 409 number_in_use with details.uses; release with force=true to detach it from them and release it anyway.const released = await mv.phoneNumbers.delete(numberId);console.log(released.id, released.deleted);import os
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}
# Release a number. While campaigns, caller-ID pools, desk phones or other routes use it, the answer is# 409 number_in_use with details.uses; add force=true to detach it from them and release it anyway.response = requests.delete(f"{API}/phone_numbers/{os.environ['PHONE_NUMBER_ID']}", headers=HEADERS, timeout=30)if response.status_code == 409: error = response.json()["error"] print(error["code"], error["message"], error.get("details"))else: response.raise_for_status() print(response.json()["id"], "released")Verified caller IDs
Section titled “Verified caller IDs”A call can present a number that isn’t on your account, such as your office line, once you prove you control it. When caller-ID verification is enabled for your organisation, POST /v1/caller_ids with the phone_number (E.164) starts a verification: we call the number and ask whoever answers to type the 6-digit verification_code from the answer on the phone’s keypad. Show them the code; the call never says it. The code works for 10 minutes and for one entry.
# Verify your office line as a caller ID: we call it, and whoever answers types the code on the phone's keypad.curl https://api.morevoice.ai/v1/caller_ids \ -H "Authorization: Bearer $MOREVOICE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"phone_number": "+97235550100", "friendly_name": "Head office"}'
# Show the answer's verification_code to the person at that phone. Then wait for caller_id.verified, or read it:curl https://api.morevoice.ai/v1/caller_ids/$CALLER_ID \ -H "Authorization: Bearer $MOREVOICE_API_KEY"import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // reads MOREVOICE_API_KEY
// Verify your office line as a caller ID: we call it, and whoever answers types the code on the phone's keypad.const pending = await mv.callerIds.create({ phone_number: "+97235550100", friendly_name: "Head office" });console.log(`Type ${pending.verification_code} on the phone that rings now.`);
// Then wait for caller_id.verified, or read it.const callerId = await mv.callerIds.retrieve(pending.id);console.log(callerId.status, callerId.failure_reason ?? "");import os
import requests
API = "https://api.morevoice.ai/v1"HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}
# Verify your office line as a caller ID: we call it, and whoever answers types the code on the phone's keypad.response = requests.post(f"{API}/caller_ids", headers=HEADERS, json={"phone_number": "+97235550100", "friendly_name": "Head office"}, timeout=30)response.raise_for_status()pending = response.json()print(f"Type {pending['verification_code']} on the phone that rings now.")
# Then wait for caller_id.verified, or read it.response = requests.get(f"{API}/caller_ids/{pending['id']}", headers=HEADERS, timeout=30)response.raise_for_status()caller_id = response.json()print(caller_id["status"], caller_id["failure_reason"] or "")The outcome arrives as caller_id.verified or caller_id.failed (with a failure_reason: wrong_code, no_answer, no_input, expired, call_failed or superseded). A verified number can be the caller_id of POST /v1/calls and of campaigns, on your own connections and on MoreVoice Telephony; an unverified one is still refused. GET /v1/caller_ids lists them, and DELETE /v1/caller_ids/{id} stops presenting one.
- Limits: 3 verification calls a day per number, and 10 a day and 3 in any 10 minutes per organisation (
429 rate_limited, withdetails.scope). - Refused: a number not in E.164, an emergency or premium-rate number (
400 parameter_invalid), and your own numbers, which need no verification, or one already verified (409 caller_id_exists). - Retries:
POST /v1/caller_idsisn’t replayed under anIdempotency-Key, because its answer holds the code. A retry starts a new verification, and the older one fails assuperseded. - Cost: the verification call isn’t billed to your organisation.
Set it up in the app
Section titled “Set it up in the app”-
Open SettingsSIP / Phone. The Phone system card turns the SIP stack on and shows its public address. Give this address to your carrier for a trunk.
-
Click New SIP trunk or New SIP account, fill in the host and the credentials from your carrier, set Max channels, Reserved for inbound, Max calls / second and Allowed inbound IPs, and click Save connection.
-
Add inbound routes for the numbers on the line, and call one of them.