Reputation: 350
Hello and thank you for reading. Is it possible to change the Messaging URL callback with the Twilio API?
Upvotes: 2
Views: 706
Reputation: 9
You can do so using the twilio api
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
client.incomingPhoneNumbers('PN2a0747eba6abf96b7e3c3ff0b4530f6e')
.update({
accountSid: 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
smsUrl: 'http://demo.twilio.com/docs/sms.xml',
voiceUrl: 'http://demo.twilio.com/docs/voice.xml'
})
.then(incoming_phone_number => console.log(incoming_phone_number.friendlyName))
.done();
Upvotes: 0
Reputation: 11732
You need to POST
to an IncomingPhoneNumber
instance resource.
You can do it with curl
, or if you're using another language read these docs,
https://www.twilio.com/docs/api/rest/incoming-phone-numbers?code-sample=code-update-an-incomingphonenumber&code-language=curl&code-sdk-version=json (and select another language for the sample code).
You will need to know:
SUB-ACCOUNT-SID
\\ the sid for the account where the phone number belongs to
PHONE-NUMBER-SID
\\ the sid of the phone number you want to change the URL
MASTER-ACCOUNT-SID
\\ your Twilio master account sid
MASTER-ACCOUNT-TOKEN
\\ your Twilio master account token
If you're not using sub-accounts SUB-ACCOUNT-SID
and MASTER-ACCOUNT-SID
are the same thing.
The command to change the URL to http://demo.twilio.com/docs/sms.xml
(replace with your values):
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/SUB-ACCOUNT-SID/IncomingPhoneNumbers/PHONE-NUMBER-SID.json -d "SmsUrl=http://demo.twilio.com/docs/sms.xml" -u "MASTER-ACCOUNT-SID:MASTER-ACCOUNT-TOKEN"
Note: when you replace the values it looks something like this
curl -XPOST https://api.twilio.com/2010-04-01/Accounts/AC0123456789abcdefabcdefabcdefabcd/IncomingPhoneNumbers/PN0123456789abcdefabcdefabcdefabcd.json -d "SmsUrl=http://demo.twilio.com/docs/sms.xml" -u "ACabcdefabcdefabcdefabcd0123456789:0123456789abcdefabcdefabcdefabcd"
Upvotes: 4