Search code examples
c#twiliosmsintegration

Is it possible to Validate programmatically if Twilio sender phone number belongs to active numbers not using preview api?


I'm working on integration application and I need to know how to programmatically validate Twilio sender phone number. I've already found in the documentation actuve number resource that in preview api we will be able to do it. But Preview API wasn't release so I can't use it.

Do they have the relased API call which can send me back the information if the phone number belongs to Acitve numbers?

Update 1: In my case I'm going to use the following code:

 TwilioClient.Init(accountSid, authToken);

 var incomingPhoneNumbers = IncomingPhoneNumberResource.Read(limit: 20);

 foreach (var record in incomingPhoneNumbers)
 {
     // do some magic here
 }

Update 2: this code will allow to get rid of static client and make it thread safety

 var phoneNumbers = await IncomingPhoneNumberResource.ReadAsync(limit: 50, client: new TwilioRestClient(integration.AccountSid, integration.AuthToken));

Solution

  • I'd also recommend fetching the incomingPhoneNumber resource.

    I just double-checked and it doesn't include number that are released. Or is there another reason why you don't want to use this API?