Search code examples
javascriptreactjstwiliotwilio-apitwilio-flex

List my phone number inventory inside Twilio flex


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


Solution

  • 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