diff --git a/enterprise/app/services/twilio/voice_teardown_service.rb b/enterprise/app/services/twilio/voice_teardown_service.rb index c6a897be9..b244ce4be 100644 --- a/enterprise/app/services/twilio/voice_teardown_service.rb +++ b/enterprise/app/services/twilio/voice_teardown_service.rb @@ -20,6 +20,10 @@ class Twilio::VoiceTeardownService end def twilio_client - @twilio_client ||= Twilio::REST::Client.new(channel.account_sid, channel.auth_token) + @twilio_client ||= if channel.api_key_sid.present? && channel.try(:api_key_secret).present? + ::Twilio::REST::Client.new(channel.api_key_sid, channel.api_key_secret, channel.account_sid) + else + ::Twilio::REST::Client.new(channel.account_sid, channel.auth_token) + end end end