How can I view a list of my Twilio phone numbers using the Twilio API?

I have a twilio account to send SMS. However, I need guidance on how to view the list of my account numbers by calling its API. I've tried navigating the various menus in the API, but I don't see a way to get a list of my phone numbers. Thank you in advance for your guidance.

+3


source to share


1 answer


Twilio developer evangelist is here.

If you want to list the phone numbers you have in your Twilio account through the API, you need a list of inbound numbers resources .



You can easily access Twilio rubygem like this:

require 'twilio-ruby'

@client = Twilio::REST::Client.new YOUR_ACCOUNT_SID, YOUR_AUTH_TOKEN
numbers = @client.account.incoming_phone_numbers.list
numbers.each do |number|
  # do something with the number
  puts number.phone_number
end

      

+4


source







All Articles