0

is there any way to check if a phone number's Messaging Active Configuration is configured or not, through the API?

enter image description here

Thank you!

jruivo
  • 447
  • 1
  • 8
  • 22

1 Answers1

0

Yes, you can use the IncomingPhoneNumbers resource to do so.

IncomingPhoneNumber resource

See the code examples (Fetch/List)

For a Messaging Service (to see if a number is in a messaging service):

  1. Read Service Example. This will list all the Messaging Services in the given Account SID Service Resource

https://www.twilio.com/docs/messaging/services/api

Example:

client.messaging.services
                .list({limit: 20})
                .then(services => services.forEach(s => console.log(s.sid)));
  1. Fetch Service For each Messaging Service, you need to fetch the numbers it contains, You need to do this for each Messaging Service SID (#1 above)

PhoneNumber Resource

https://www.twilio.com/docs/messaging/services/api/phonenumber-resource

Example:

client.messaging.services('MGxxx')
      .phoneNumbers
      .list({limit: 20})
      .then(phoneNumbers => phoneNumbers.forEach(p => console.log(p.phoneNumber)));
Alan
  • 10,465
  • 2
  • 8
  • 9
  • I tried that but it doesn't show the Messaging Service: Default Conversations Service, – jruivo May 06 '21 at 16:20
  • For the second number, it shows the configured Hooks, however, I was more interested in knowing that the first number is using the Messaging Service: Default Conversations Service. That information is not returned – jruivo May 06 '21 at 16:52