1

I need to show a list of my purchased phone numbers inside my flex app in order to let the agent choose which number to call from.

I've been checking both REST and flex/manager docs and I can't find a resource that let me request the list of purchased numbers.

Edit after an answer: There's this REST API endpoint which may look like what I need: https://www.twilio.com/docs/phone-numbers/global-catalog/api/active-numbers

curl -G https://preview.twilio.com/Numbers/ActiveNumbers/PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.json \
    -u '<ACCOUNT_SID:AUTH_TOKEN>'

But as I see it, it needs the phone number id as a parameter in the URL? (PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy)

I've tried to request the root resource: https://preview.twilio.com/Numbers/ActiveNumbers/ but the I get an error: The requested resource /Numbers/ActiveNumbers was not found

Some help would be much appreciated

Charlie
  • 22,886
  • 11
  • 59
  • 90
Manel
  • 33
  • 4

2 Answers2

2

List all IncomingPhoneNumber resources for your account

curl -X GET 'https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IncomingPhoneNumbers.json?PageSize=20' \
-u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token

Source: https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource

Alan
  • 10,465
  • 2
  • 8
  • 9
0

You can do this with Active Numbers API. The API is still in the developer preview (August, 2020).

$ curl -G https://preview.twilio.com/Numbers/ActiveNumbers/PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.json \
    -u '<ACCOUNT_SID:AUTH_TOKEN>'

The API returns the set of active telephone numbers along with their capabilities

[{
    "phone_number": "+18559728742",
    "url": "https://preview.twilio.com/Numbers/ActiveNumbers/PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
    "capabilities": {
        "voice": {
            "inbound_connectivity": true,
            "outbound_connectivity": true,
            "e911": false,
            "fax": true,
            "calls_per_second": 20,
            "concurrent_calls_limit": 40,
            "long_record_length": 30,
            "inbound_called_dtmf": true,
            "inbound_caller_dtmf": true,
            "sip_trunking": true,
            "inbound_caller_id_preservation": "international",
            "inbound_reachability": "global"
        },
        "sms": {
            ....
]
Charlie
  • 22,886
  • 11
  • 59
  • 90
  • I've seen this but looks like I've to pass the phone number id as a URL parameter, no? (PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.json) How can I know the phone number ID before hand? Sorry, Im a bit confused – Manel Aug 07 '20 at 07:51
  • 1
    Also tried to get: https://preview.twilio.com/Numbers/ActiveNumbers But then I get: "The requested resource /Numbers/ActiveNumbers was not found" – Manel Aug 07 '20 at 08:27
  • Ypou just need to pass the account sid and the token – Charlie Aug 07 '20 at 10:03
  • 1
    Of course I did that, but still I get: "The requested resource /Numbers/ActiveNumbers was not found". In case I don't provide auth then I get: "Your AccountSid or AuthToken was incorrect", but I'm providing credentials. – Manel Aug 07 '20 at 10:14