Skip to content

client.phone_numbers

Phone numbers on your account. These methods are on client.phone_numbers, where client is a MoreVoice client (see the Python SDK). On AsyncMoreVoice the same methods are awaited. Each one returns the response object and raises an exception when the API answers with an error.

Buy a number, or create a sandbox number (test mode). With a live key: buys number (or available_id), one of GET /v1/phone_numbers/available, and routes it to assistant_id, flow_id or the target of inbound_route_id (none: your most recently updated assistant). It is billed monthly at the listed price from today. Errors: 409 number_unavailable (taken meanwhile: pick another), 402 balance_exhausted (a prepaid balance that doesn’t cover the first month), 402 plan_limit (your plan’s number limit), 403 feature_unavailable (number purchases are not enabled for the organisation, or the plan lacks them). status is active, or pending while the line is being set up. Send an Idempotency-Key: a retry with the same key never buys twice.

With a test key: allocates a sandbox number (source: sandbox) in the +972 50 999 range, at no cost and with no carrier, at most 5 per organisation. Dial it with POST /v1/test_helpers/inbound_calls. A sandbox number never receives real calls.

client.phone_numbers
def create(self, body: _m.PhoneNumberCreateParamsInput | Mapping[str, Any] | Unset = UNSET, *, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.PhoneNumber

client.phone_numbers.create() · await async_client.phone_numbers.create() · POST /phone_numbers · API reference

Field Type Required Description
assistant_id string no Inbound calls to the number reach this assistant.
available_id string no Live keys: the id of a number from GET /v1/phone_numbers/available (avn_…). Send this or number.
flow_id string no Inbound calls to the number run this published flow.
inbound_route_id string no Test keys: inbound test calls to the number follow this inbound route. Live keys: the number gets its own route with this route’s target (its flow, queue, person or assistant).
label string no A name for the number, shown in lists.
number string no Live keys: the number to buy, in E.164 (one of GET /v1/phone_numbers/available). Send this or available_id.

PhoneNumber:

Field Type Description
id string The number’s ID (stable).
object "phone_number" Always phone_number.
livemode boolean true in live mode, false in test mode.
e164 string The number in E.164.
country string | null ISO 3166-1 alpha-2, when known.
source "provisioned" | "connection" | "sandbox" provisioned: bought through the platform. connection: a number of your own SIP connection (its caller IDs and the numbers your inbound routes match). sandbox: a test-mode number.
provider string | null The carrier of a provisioned number; null for your own connections.
status string active; provisioned numbers can also be pending, pending_kyc, porting_in, suspended, releasing or released.
connection_id string | null conn_… ID.
inbound_route_id string | null rte_… ID.
label string | null —
inbound boolean Calls to the number are answered here (a route or connection matches it).
outbound_caller_id boolean The number can be presented as caller ID on outbound calls.
created string | null When the number was added (null for numbers derived from a connection).
from morevoice import MoreVoice
client = MoreVoice() # MOREVOICE_API_KEY from the environment
phone_number = client.phone_numbers.create({
"assistant_id": "asst_4Gk2LmN9pQ4rS6tV8wX0yZ",
"label": "Support line (test)",
})
print(phone_number)

Release a phone number. With a live key: releases one of your numbers (when number releases are enabled for the organisation; otherwise 501). The number stops answering calls: its inbound route goes with it. A number bought through the platform goes back to the platform (a MoreVoice Telephony number returns to the stock) and 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 its exact inbound routes are deleted. Fires number.released.

While campaigns present the number 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 with details.uses; force=true detaches it from all of them first (campaigns and phones fall back to the line’s default caller ID). Releasing a released number again answers 200. Releasing cannot be undone: the number may go to another customer.

With a test key: releases a sandbox number.

client.phone_numbers
def delete(self, id: str, *, force: _m.PhoneNumbersDeleteForce | Unset = UNSET, more_voice_version: str | Unset = UNSET, idempotency_key: str | Unset = UNSET) -> _m.DeletedPhoneNumber

client.phone_numbers.delete() · await async_client.phone_numbers.delete() · DELETE /phone_numbers/{id} · API reference

Name Type Required Description
id str yes A phone number ID (pn_…).
force "true" | "false" no Live keys: true releases the number even while campaigns, caller-ID pools, desk phones or other inbound routes use it, and detaches it from them. Default false (409 number_in_use with details.uses).

DeletedPhoneNumber:

Field Type Description
id string The released number’s ID.
object "phone_number" Always phone_number.
deleted true —
from morevoice import MoreVoice
client = MoreVoice() # MOREVOICE_API_KEY from the environment
deleted_phone_number = client.phone_numbers.delete("pn_7Hk2Lm9Qp")
print(deleted_phone_number)

List phone numbers. Numbers bought through the platform, then the numbers of your own SIP connections (their caller IDs and the numbers your inbound routes match exactly). Test-mode keys list sandbox numbers.

client.phone_numbers
def list(self, *, limit: int | Unset = 20, starting_after: str | Unset = UNSET, ending_before: str | Unset = UNSET, more_voice_version: str | Unset = UNSET) -> AsyncPage[_m.PhoneNumber]

client.phone_numbers.list() · await async_client.phone_numbers.list() · GET /phone_numbers · API reference

Name Type Required Description
limit integer no How many objects to return, 1–100 (default 20).
starting_after string no A cursor (next_cursor) or object ID: return the objects after it (older).
ending_before string no A cursor or object ID: return the objects before it (newer).

A page of results (PhoneNumberList): data, has_more and next_cursor.

from morevoice import MoreVoice
client = MoreVoice() # MOREVOICE_API_KEY from the environment
for phone_number in client.phone_numbers.list():
print(phone_number)

List numbers you can buy. The numbers on offer to your organisation, in number order, with your monthly price (and a setup fee, if any). Buy one with POST /v1/phone_numbers and its id as available_id (or its number). Needs a live key, and number purchases enabled for the organisation (otherwise 403 feature_unavailable). An empty list means nothing matches right now.

client.phone_numbers
def list_available(self, *, limit: int | Unset = 20, starting_after: str | Unset = UNSET, ending_before: str | Unset = UNSET, country: str | Unset = UNSET, area_code: str | Unset = UNSET, contains: str | Unset = UNSET, more_voice_version: str | Unset = UNSET) -> AsyncPage[_m.AvailablePhoneNumber]

client.phone_numbers.list_available() · await async_client.phone_numbers.list_available() · GET /phone_numbers/available · API reference

Name Type Required Description
limit integer no How many objects to return, 1–100 (default 20).
starting_after string no A cursor (next_cursor) or object ID: return the objects after it (older).
ending_before string no A cursor or object ID: return the objects before it (newer).
country string no ISO 3166-1 alpha-2, e.g. IL.
area_code string no Only numbers with this area code (073, 03; the leading 0 is optional).
contains string no Only numbers whose digits contain this sequence.

A page of results (AvailablePhoneNumberList): data, has_more and next_cursor.

from morevoice import MoreVoice
client = MoreVoice() # MOREVOICE_API_KEY from the environment
for phone_number in client.phone_numbers.list_available():
print(phone_number)

Retrieve a phone number. Returns a phone number: its E.164 form, where it comes from (source: a number of one of your SIP connections, a number provisioned through the platform, or a test-mode sandbox number), whether it answers inbound calls (and the route that answers them) and whether it can be the caller ID of outbound calls.

client.phone_numbers
def retrieve(self, id: str, *, more_voice_version: str | Unset = UNSET) -> _m.PhoneNumber

client.phone_numbers.retrieve() · await async_client.phone_numbers.retrieve() · GET /phone_numbers/{id} · API reference

Name Type Required Description
id str yes A phone number ID (pn_…).

PhoneNumber:

Field Type Description
id string The number’s ID (stable).
object "phone_number" Always phone_number.
livemode boolean true in live mode, false in test mode.
e164 string The number in E.164.
country string | null ISO 3166-1 alpha-2, when known.
source "provisioned" | "connection" | "sandbox" provisioned: bought through the platform. connection: a number of your own SIP connection (its caller IDs and the numbers your inbound routes match). sandbox: a test-mode number.
provider string | null The carrier of a provisioned number; null for your own connections.
status string active; provisioned numbers can also be pending, pending_kyc, porting_in, suspended, releasing or released.
connection_id string | null conn_… ID.
inbound_route_id string | null rte_… ID.
label string | null —
inbound boolean Calls to the number are answered here (a route or connection matches it).
outbound_caller_id boolean The number can be presented as caller ID on outbound calls.
created string | null When the number was added (null for numbers derived from a connection).
from morevoice import MoreVoice
client = MoreVoice() # MOREVOICE_API_KEY from the environment
phone_number = client.phone_numbers.retrieve("pn_7Hk2Lm9Qp")
print(phone_number)