News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
How to detect A2P SMS numbers
Tags: sms and text messaging
Sep 8, 2020 at 1:57pm   •   0 replies  •  0 likes
Phong Vu

In order to send text messages using the "a2p/batch" API, you need to have a phone number which has the A2P SMS feature enabled.

To detect programmatically if a user extension has phone numbers which have been provisioned for A2P SMS, implement the following steps in your app:

1/ Read the user's phone numbers

GET '/account/~/extension/~/phone-number

2/ Parse the response

var a2pSMSEnabledNumbers = []
for (var record of jsonObj.records){
  // detect A2P Toll Free SMS number
  if (record.paymentType == "TollFree") {
    if (record.type != "FaxOnly"){
      for (var feature of record.features){
        if (feature == "A2PSmsSender"){
          var item = {
                       "number": record.phoneNumber,
                       "type": "Toll-Free A2P SMS Number"
                     }
          a2pSMSEnabledNumbers.push(item)
          break;
        }
      }
    }
  // detect A2P 10-DLC SMS number
  }else if (record.paymentType == "Local"){
    if (record.usageType == "DirectNumber"){
      if (record.type != "FaxOnly" ){
        for (var feature of record.features){
          if (feature == "A2PSmsSender"){
            var item = {
                         "number": record.phoneNumber,
                         "type": "10-DLC A2P SMS Number"
                       }
            a2pSMSEnabledNumbers.push(item)
            break;
          }
        }
      }
    }
  }
}




A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us