Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i see a list of my Twilio account phone numbers by Twilio API?

Tags:

twilio

I have a twilio account for sending SMS. However, i need guidance on how to see a list of my account phone numbers by calling its API. I have tried to navigate through the different menus in API but i dont see any option to get list of my account phone numbers. Thank you in advance for your guidance.

like image 249
Snow Fox Avatar asked Jun 29 '15 19:06

Snow Fox


1 Answers

Twilio developer evangelist here.

If you want to list the phone numbers you have in your Twilio account through the API you need the Incoming Phone Numbers list resource.

You can access this easily with the Twilio rubygem like so:

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
like image 190
philnash Avatar answered Sep 20 '22 07:09

philnash