Skip to main content

phone_numbers

Creates, updates, deletes, gets or lists a phone_numbers resource.

Overview

Namephone_numbers
TypeResource
Idazure.communication_phone_numbers.phone_numbers

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
assignmentTypestringPhone number's assignment type. Required. Known values are: "person" and "application".
capabilitiesobjectCapabilities of a phone number. Required.
costobjectThe incurred cost for a single phone number. Required.
errorstringMapping Error Messages to Codes. Known values are: "NoError", "UnknownErrorCode", "OutOfStock", "AuthorizationDenied", "MissingAddress", "InvalidAddress", "InvalidOfferModel", "NotEnoughLicenses", "NoWallet", "NotEnoughCredit", "NumbersPartiallyAcquired", "AllNumbersNotAcquired", "ReservationExpired", "PurchaseFailed", "BillingUnavailable", "ProvisioningFailed", and "UnknownSearchError".
errorCodeintegerThe error code of the search.
isAgreementToNotResellRequiredbooleanIndicates if do not resell agreement is required. If true, the phone numbers cannot be acquired unless the customer provides explicit agreement to not resell them.
phoneNumberTypestringThe phone number's type, e.g. geographic, tollFree, mobile. Required. Known values are: "geographic", "tollFree", and "mobile".
phoneNumbersarrayThe phone numbers that are available. Can be fewer than the desired search quantity. Required.
searchExpiresBystring (date-time)The date that this search result expires and phone numbers are no longer on hold. A search result expires in less than 15min, e.g. 2020-11-19T16:31:49.048Z. Required.
searchIdstringThe search id. Required.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
search_available_phone_numbersselectcountry_code, endpointSearch for available phone numbers to purchase. Search for available phone numbers to purchase.
list_area_codesselectcountry_code, phoneNumberType, endpointskip, maxPageSize, assignmentType, locality, administrativeDivision, accept-languageGets the list of available area codes. Gets the list of available area codes.
list_available_localitiesselectcountry_code, endpointskip, maxPageSize, administrativeDivision, accept-language, phoneNumberTypeGets the list of cities or towns with available phone numbers. Gets the list of cities or towns with available phone numbers.
get_by_numberselectphone_number, endpointGets the details of the given purchased phone number. Gets the details of the given purchased phone number.
get_reservationselectreservation_id, endpointGets a reservation by its ID. Retrieves the reservation with the given ID, including all of the phone numbers associated with it.
get_search_resultselectsearch_id, endpointGets a phone number search result by search id. Gets a phone number search result by search id.
get_operationselectoperation_id, endpointGets an operation by its id. Gets an operation by its id.
list_available_countriesselectendpointskip, maxPageSize, accept-languageGets the list of supported countries. Gets the list of supported countries.
release_phone_numberdeletephone_number, endpointReleases a purchased phone number. Releases a purchased phone number.
cancel_operationdeleteoperation_id, endpointCancels an operation by its id. Cancels an operation by its id.
list_offeringsexeccountry_code, endpointskip, maxPageSize, phoneNumberType, assignmentType, accept-languageList available offerings of capabilities with rates for the given country. List available offerings of capabilities with rates for the given country.
list_reservationsexecendpointmaxPageSizeLists all reservations. Retrieves a paginated list of all phone number reservations. Note that the reservations will not be populated with the phone numbers associated with them.
list_phone_numbersexecendpointskip, topGets the list of all purchased phone numbers. Gets the list of all purchased phone numbers.
create_or_update_reservationexecreservation_id, endpointCreates or updates a reservation by its ID. Adds and removes phone numbers from the reservation with the given ID. The response will be the updated state of the reservation. Phone numbers can be reserved by including them in the payload. If a number is already in the reservation, it will be ignored. To remove a phone number, set it explicitly to null in the request payload. This operation is idempotent. If a reservation with the same ID already exists, it will be updated, otherwise a new one is created. Only reservations with 'active' status can be updated. Updating a reservation will extend the expiration time of the reservation to 15 minutes after the last change, up to a maximum of 2 hours from creation time. Partial success is possible, in which case the response will have a 207 status code.
delete_reservationexecreservation_id, endpointDeletes a reservation by its ID. Deletes the reservation with the given ID. Any phone number in the reservation will be released and made available for others to purchase. Only reservations with 'active' status can be deleted.
browse_available_numbersexeccountry_code, endpoint, phoneNumberTypeBrowses for available phone numbers to purchase. Browses for available phone numbers to purchase. The response will be a randomized list of phone numbers available to purchase matching the browsing criteria. This operation is not paginated. Since the results are randomized, repeating the same request will not guarantee the same results.
purchase_reservationexecreservation_id, endpointStarts the purchase of all phone numbers in the reservation. Starts a long running operation to purchase all of the phone numbers in the reservation. Purchase can only be started for active reservations that at least one phone number. If any of the phone numbers in the reservation is from a country where reselling is not permitted, do not resell agreement is required. The response will include an 'Operation-Location' header that can be used to query the status of the operation.
purchase_phone_numbersexecendpointPurchases phone numbers. Purchases phone numbers.
update_capabilitiesexecphone_number, endpointUpdates the capabilities of a phone number. Updates the capabilities of a phone number.
operator_information_searchexecendpoint, phoneNumbersSearches for number format and operator information for a given list of phone numbers. Searches for number format and operator information for a given list of phone numbers.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
country_codestringThe ISO 3166-2 country code, e.g. US. Required.
endpointstringThe service endpoint host (no scheme), e.g. myaccount.table.cosmos.azure.com:443 - value of the client endpoint parameter. (default: )
operation_idstringThe id of the operation. Required.
phoneNumberTypestringFilter by numberType, e.g. Geographic, TollFree, Mobile. Known values are: "geographic", "tollFree", and "mobile". Required.
phone_numberstringThe phone number id in E.164 format. The leading plus can be either + or encoded as %2B, e.g. +11234567890. Required.
reservation_idstringThe id of the reservation. Required.
search_idstringThe search Id. Required.
accept-languagestringThe locale to display in the localized fields in the response. e.g. 'en-US'. Default value is None.
administrativeDivisionstringAn optional parameter for the name of the state or province in which to search for the area code. Default value is None.
assignmentTypestringFilter by assignmentType, e.g. Person, Application. Known values are: "person" and "application". Default value is None.
localitystringThe name of locality or town in which to search for the area code. This is required if the number type is Geographic. Default value is None.
maxPageSizeintegerAn optional parameter for how many entries to return, for pagination purposes. The default value is 100. Default value is 100.
phoneNumberTypestringFilter by numberType, e.g. Geographic, TollFree, Mobile. Known values are: "geographic", "tollFree", and "mobile". Default value is None.
skipintegerAn optional parameter for how many entries to skip, for pagination purposes. The default value is 0. Default value is 0.
topintegerAn optional parameter for how many entries to return, for pagination purposes. The default value is 100. Default value is 100.

SELECT examples

Search for available phone numbers to purchase. Search for available phone numbers to purchase.

SELECT
assignmentType,
capabilities,
cost,
error,
errorCode,
isAgreementToNotResellRequired,
phoneNumberType,
phoneNumbers,
searchExpiresBy,
searchId
FROM azure.communication_phone_numbers.phone_numbers
WHERE country_code = '{{ country_code }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

DELETE examples

Releases a purchased phone number. Releases a purchased phone number.

DELETE FROM azure.communication_phone_numbers.phone_numbers
WHERE phone_number = '{{ phone_number }}' --required
AND endpoint = '{{ endpoint }}' --required
;

Lifecycle Methods

List available offerings of capabilities with rates for the given country. List available offerings of capabilities with rates for the given country.

EXEC azure.communication_phone_numbers.phone_numbers.list_offerings 
@country_code='{{ country_code }}' --required,
@endpoint='{{ endpoint }}' --required,
@skip='{{ skip }}',
@maxPageSize='{{ maxPageSize }}',
@phoneNumberType='{{ phoneNumberType }}',
@assignmentType='{{ assignmentType }}',
@accept-language='{{ accept-language }}'
;