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;
}
}
}
}
}
}