Voximplant has a dedicated A2P (Application to Person) SMS API for high-volume messaging needs. Oftentimes businesses need to send a single message to many users at the same time for notification and alert purposes without requiring a response from the receiver. Instead of looping through a list of numbers and risking being blocked by SMS SPAM protections, the A2P SMS API simplifies sending messages in bulk and improves delivery rates.
A2P vs. P2P
P2P
SMS started out as a person-to-person (P2P) oriented service for messaging between 2 individuals. Typically, there are many responses back and forth. As shown in our recent How to Send an SMS with Python article, this process is very easy -- just send a message from a Voximplant number to a specified user and wait for a HTTP webhook callback with any response which you can then relay back to the sender or otherwise process.
A2P
As SMS became more popular, businesses started using it as a convenient tool for communicating with customers. Rather than sending dozens, hundreds, thousands, or more messages to users individually, they used automated, computer-based services for handling bulk messaging needs. These kinds of messages are great for mass notification messages, such as service closures, emergency alerts, and event announcements. Recipients can respond to these messages, but typically most don’t. This form of messaging is known as Application to Person or A2P.
Stopping spammers from ruining everything
SMS messages have a much higher open rate than other forms of communication - up to 90% within 3 minutes according to one source. Unfortunately spammers caught on to this and started sending unsolicited messages in bulk. To stop this, many SMS carriers started to block bulk SMS messages which affected legitimate A2P messages that look a lot like these SPAM messages - a single message to a large base of users sent at the same time. To prevent blocking legitimate messages, carriers implemented dedicated A2P message API’s that allow high-volume traffic. However, unlike the P2P interfaces, these often have extra paperwork, added verification requirements, and different business arrangements that ensure only legitimate senders have access. These added requirements help filter spammers, but can also make A2P services harder to access.
Short Codes
The restricted nature of A2P opens some new possibilities. Rather than sending SMS from a standard phone number (what is known as a Long Code), some carriers let you send messages from shorter 5 or 6 digit codes. With these codes, a business could do something like “Text PIZZA (74992) for a 10% discount”. Short codes may be dedicated to a single business or shared across many businesses.
Alphanumeric Sender
Rather than sending a message from a random number a user might not be familiar with, many businesses would prefer to use their names. Alphanumeric sender ID lets a business use something like “VoxPizza” instead of “14388002812”. See an example from “A2PDEMO” below:
When to use A2P vs. P2P
Why not just set up a for loop and send all messages via the P2P method? Depending on your volume, that may not work. SMS carriers have send rate limits in addition to SMS SPAM handling.
In general, you should use A2P instead of P2P when:
- You are sending more than 10 to 20 messages at once
- You want to use a short code
- You want to use an alphanumeric sender
- You want to ensure the highest delivery rate possible
How to use the A2P SMS API
The procedure for using A2P SMS is identical to the P2P case covered here. The API is almost identical to SendSmsMessage, except A2PSendSms takes multiple recipient phone numbers instead of one in a dst_numbers
field:
Examples
curl
curl https://api.voximplant.com/platform_api/A2PSendSms?account_id=1&api_key=eec36d6c-a0eb-46b5-a006-1c2b65343bac&src_number=A2PDEMO&dst_numbers=14388002812;1442038083060;924902460004&text=’Hello again Voximplant A2P (testing)’ -H "$(bash jwt.sh credentials.json)"
Node.js
const VoximplantApiClient = require("@voximplant/apiclient-nodejs").default;
const client = new VoximplantApiClient("credentials.json");
client.onReady = function () {
client.SMS.a2PSendSms({
src_number: 'A2PDEMO',
dst_numbers: ‘14388002812;1442038083060;924902460004’,
text: 'Hello from Voximplant A2P'
})
.then(ev => console.log(ev))
.catch(err => console.error(err));
};
Python
from voximplant.apiclient import VoximplantAPI, VoximplantException
if __name__ == "__main__":
voxapi = VoximplantAPI("credentials.json")
try:
res = voxapi.a2p_send_sms('A2PDEMO',
‘14388002812;1442038083060;924902460004’,
'Hello from Voximplant A2P')
print(res)
except VoximplantException as e:
print("Error: {}".format(e.message))
Check the results
You can use A2PgetSmsHistory
to check the result. Here is a generic CURL example, but you can do the same in our supported libraries:
voximplant_python_sms % curl "https://api.voximplant.com/platform_api/A2PGetSmsHistory/?account_id=1&source_number=A2PDEMO" -H "$(bash jwt.sh credentials.json)" | jq
You should see something like:
{
"result":[
{
"transaction_id":986678140004,
"cost":0.015,
"status_id":"1",
"destination_number":"442038083060",
"fragments":1,
"processing_date":"2020-08-10 16:02:24",
"id":63628,
"source_number":"A2PDEMO",
"delivery_status":"DELIVERED"
},
{
"transaction_id":986678130004,
"cost":0.015,
"status_id":"1",
"destination_number":"14388002812",
"fragments":1,
"processing_date":"2020-08-10 16:02:24",
"id":63629,
"source_number":"A2PDEMO",
"delivery_status":"DELIVERED"
},
{
"transaction_id":986678120004,
"cost":0.015,
"status_id":"1",
"destination_number":"81345790139",
"fragments":1,
"processing_date":"2020-08-10 16:02:24",
"id":63630,
"source_number":"A2PDEMO",
"delivery_status":"DELIVERED"
}
],
"total_count":3
}
Response callback
Setup a webhook callback to look for any responses:
{
"callbacks":[
{
"account_email":[
"demo@voximplant.com"
],
"language_code":"en",
"account_id":329934,
"account_last_name":"",
"balance":6.848372,
"callback_id":1667204,
"account_name":"demo",
"sms_inbound":{
"destination_number":"14388002812",
"sms_body":"Response to your A2P message",
"source_number":"14388002812"
},
"currency":"USD",
"type":"sms_inbound",
"account_first_name":"",
"hash":"28ce61c89e9975d71b4b52fc32bd7942"
}
]
}
Additional Documentation
See our SMS documentation for full details.
A2P Pricing
Pricing varies by country, so please visit our pricing page to see A2P availability and rates for a given region. A2P pricing for the United States starts at $0.0125. Voximplant may also be able to provide you with a short code rental or Alphanumeric Sender ID depending on your country. Contact support@voximplant.com or your Voximplant sales representative for details.
Accessing Voximplant’s A2P SMS API
Voximplant provides a quick and convenient way to send either P2P or A2P SMS messages via its HTTP API and various control libraries for - node.js and Python today with support for our other libraries like PHP, .NET, and Go coming soon.
For the reasons mentioned above, access to Voximplant’s A2P SMS API is restricted and must be manually enabled by Voximplant. Legitimate accounts can contact support@voximplant.com or their Customer Success Manager to have access opened for your account.