Skip to content

Instantly share code, notes, and snippets.

@acamino
Created February 3, 2016 01:40
Show Gist options
  • Save acamino/4db7e7c9ab02716808f1 to your computer and use it in GitHub Desktop.
Save acamino/4db7e7c9ab02716808f1 to your computer and use it in GitHub Desktop.
Releasing Twilio Numbers
# The numbers will be pulled in groups of 50, so if you
# have more than 50 numbers then you'll have to run this
# script more than once.
require 'twilio-ruby'
# Get your Account Sid and Auth Token from twilio.com/user/account
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
client = Twilio::REST::Client.new(account_sid, auth_token)
# A delightful explanation can be found here:
# https://www.twilio.com/docs/api/rest/incoming-phone-numbers#list-post
client.account.incoming_phone_numbers.list.each do |number|
# Tracking which numbers will be released
p number.phone_number
# Release your twilio number
number.delete
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment