Skip to content

Twilio: List Available Phone Number Machine To Machine

Twilio machineToMachine.listAvailablePhoneNumberMachineToMachine: arguments, response, policy and SDK examples.

← Machine to machine operations · Get started

Operation twilio.listavailablephonenumbermachinetomachine

Provider route: GET /2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{CountryCode}/MachineToMachine.json. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/twilio with npm, or alter-sdk-twilio with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { TwilioIntegration } from "@alter-ai/twilio";
async function execute(input: Parameters<TwilioIntegration["machineToMachine"]["listAvailablePhoneNumberMachineToMachine"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new TwilioIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.machineToMachine.listAvailablePhoneNumberMachineToMachine(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_twilio import TwilioIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = TwilioIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.machine_to_machine.list_available_phone_number_machine_to_machine(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.AccountSidstringRequired within parentMaximum length: 34
Minimum length: 34
Pattern: ^AC[0-9a-fA-F]{32}$
path.CountryCodestringRequired within parentFormat: iso-country-code
queryModelOptionalExpand List Available Phone Number Voip — request body — query

Referenced models: List Available Phone Number Voip — request body — query

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$objectRoot
available_phone_numbersarrayOptional
available_phone_numbers[]ModelEach itemExpand List Available Phone Number Voip — response body — available phone numbers item
endJSONOptional
end (anyOf 1)integerAlternative
end (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
first_page_uristringOptionalFormat: uri
next_page_uriJSONOptional
next_page_uri (anyOf 1)stringAlternativeFormat: uri
next_page_uri (anyOf 2)nullAlternative
pageJSONOptional
page (anyOf 1)integerAlternative
page (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
page_sizeJSONOptional
page_size (anyOf 1)integerAlternative
page_size (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
previous_page_uriJSONOptional
previous_page_uri (anyOf 1)stringAlternativeFormat: uri
previous_page_uri (anyOf 2)nullAlternative
startJSONOptional
start (anyOf 1)integerAlternative
start (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
uristringOptionalFormat: uri

Referenced models: List Available Phone Number Voip — response body — available phone numbers item

List Available Phone Number Voip — response body — available phone numbers item
FieldTypePresenceDescription and constraints
$objectRoot
address_requirementsJSONOptional
address_requirements (anyOf 1)stringAlternativeThe type of [Address](https://www.twilio.com/docs/usage/api/address) resource the phone number requires. Can be: `none`, `any`, `local`, or `foreign`. `none` means no address is required. `any` means an address is required, but it can be anywhere in the world. `local` means an address in the phone number's country is required. `foreign` means an address outside of the phone number's country is required.
address_requirements (anyOf 2)nullAlternative
betaJSONOptional
beta (anyOf 1)booleanAlternativeWhether the phone number is new to the Twilio platform. Can be: `true` or `false`.
beta (anyOf 2)nullAlternative
capabilitiesJSONOptional
capabilities (anyOf 1)objectAlternativeThe set of Boolean properties that indicate whether a phone number can receive calls or messages. Capabilities are: `Voice`, `SMS`, and `MMS` and each capability can be: `true` or `false`.
Format: phone-number-capabilities
capabilities (anyOf 1).faxbooleanOptional
capabilities (anyOf 1).mmsbooleanOptional
capabilities (anyOf 1).smsbooleanOptional
capabilities (anyOf 1).voicebooleanOptional
capabilities (anyOf 2)nullAlternative
friendly_nameJSONOptional
friendly_name (anyOf 1)stringAlternativeA formatted version of the phone number.
Format: phone-number
friendly_name (anyOf 2)nullAlternative
iso_countryJSONOptional
iso_country (anyOf 1)stringAlternativeThe [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of this phone number.
Format: iso-country-code
iso_country (anyOf 2)nullAlternative
lataJSONOptional
lata (anyOf 1)stringAlternativeThe [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) of this phone number. Available for only phone numbers from the US and Canada.
lata (anyOf 2)nullAlternative
latitudeJSONOptional
latitude (anyOf 1)JSONAlternative
latitude (anyOf 1) (anyOf 1)numberAlternativeThe latitude of this phone number's location. Available for only phone numbers from the US and Canada.
latitude (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
latitude (anyOf 2)nullAlternative
localityJSONOptional
locality (anyOf 1)stringAlternativeThe locality or city of this phone number's location.
locality (anyOf 2)nullAlternative
longitudeJSONOptional
longitude (anyOf 1)JSONAlternative
longitude (anyOf 1) (anyOf 1)numberAlternativeThe longitude of this phone number's location. Available for only phone numbers from the US and Canada.
longitude (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
longitude (anyOf 2)nullAlternative
phone_numberJSONOptional
phone_number (anyOf 1)stringAlternativeThe phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists of a + followed by the country code and subscriber number.
Format: phone-number
phone_number (anyOf 2)nullAlternative
postal_codeJSONOptional
postal_code (anyOf 1)stringAlternativeThe postal or ZIP code of this phone number's location. Available for only phone numbers from the US and Canada.
postal_code (anyOf 2)nullAlternative
rate_centerJSONOptional
rate_center (anyOf 1)stringAlternativeThe [rate center](https://en.wikipedia.org/wiki/Telephone_exchange) of this phone number. Available for only phone numbers from the US and Canada.
rate_center (anyOf 2)nullAlternative
regionJSONOptional
region (anyOf 1)stringAlternativeThe two-letter state or province abbreviation of this phone number's location. Available for only phone numbers from the US and Canada.
region (anyOf 2)nullAlternative
List Available Phone Number Voip — request body — query
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
AreaCodeintegerOptional
ContainsstringOptional
SmsEnabledbooleanOptional
MmsEnabledbooleanOptional
VoiceEnabledbooleanOptional
ExcludeAllAddressRequiredbooleanOptional
ExcludeLocalAddressRequiredbooleanOptional
ExcludeForeignAddressRequiredbooleanOptional
BetabooleanOptional
NearNumberstringOptionalFormat: phone-number
NearLatLongstringOptional
DistanceintegerOptional
InPostalCodestringOptional
InRegionstringOptional
InRateCenterstringOptional
InLatastringOptional
InLocalitystringOptional
FaxEnabledbooleanOptional
PageSizeintegerOptionalFormat: int64
Maximum: 1000
Minimum: 1
PageintegerOptionalMinimum: 0
PageTokenstringOptional

SDK function policy ID: twilio.listavailablephonenumbermachinetomachine. Catalog operation: ListAvailablePhoneNumberMachineToMachine. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand how our website, product, and documentation are used.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

Advertising

Shares visits and sign-ups with Meta, Reddit, and X so we can measure which of our ads work.

You can change these choices at any time from Cookie settings.