Skip to content

mv.phoneNumbers

Phone numbers on your account. These methods are on mv.phoneNumbers, where mv is your client (see the Node.js SDK). Each one returns the response object and throws when the API answers with an error.

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.

mv.phoneNumbers.list(query?: NonNullable<PhoneNumbersListData["query"]>, options?: RequestOptions): PagedList<PhoneNumbersListResponse["data"][number], NonNullable<PhoneNumbersListData["query"]>>

GET /phone_numbers · API reference

Name Type Required Description
query.limit integer no How many objects to return, 1–100 (default 20).
query.starting_after string no A cursor (next_cursor) or object ID: return the objects after it (older).
query.ending_before string no A cursor or object ID: return the objects before it (newer).
options.headers["MoreVoice-Version"] string no The API version to use for this request. Defaults to the version the API key is pinned to.
options RequestOptions no idempotencyKey, extra headers and an abort signal: see retries and idempotency.

A PagedList: await it for the first page, for await it for every item.

import { createClient, createResources } from "@morevoice/sdk";
const mv = createResources({
client: createClient({ baseUrl: "https://api.morevoice.ai/v1", auth: process.env.MOREVOICE_API_KEY }),
});
for await (const phoneNumber of mv.phoneNumbers.list()) {
console.log(phoneNumber);
}

Retrieve a phone number.

mv.phoneNumbers.retrieve(id: PhoneNumbersRetrieveData["path"]["id"], options?: RequestOptions): Promise<PhoneNumbersRetrieveResponse>

GET /phone_numbers/{id} · API reference

Name Type Required Description
id string yes A phone number ID (pn_…).
options.headers["MoreVoice-Version"] string no The API version to use for this request. Defaults to the version the API key is pinned to.
options RequestOptions no idempotencyKey, extra headers and an abort signal: see retries and idempotency.

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).
import { createClient, createResources } from "@morevoice/sdk";
const mv = createResources({
client: createClient({ baseUrl: "https://api.morevoice.ai/v1", auth: process.env.MOREVOICE_API_KEY }),
});
const phoneNumber = await mv.phoneNumbers.retrieve("pn_M4UyqWfNvEtH41s0p5iGIn");
console.log(phoneNumber);