Dharmendra Yadav February 2016

How to validate alphanumeric sender id for Twilio

I am trying to figure out how can I validate an alphanumeric sender id for sending SMS via Twilio? I tried sending SMS with only numeric sender(not Twilio verified number, a random numeric sender id) and Twilio accepted that message. So I am not sure what exactly Twilio support in alphanumeric sender Id.

It would be helpful if Twilio API provides some Regular Expression for pattern matching or I could validate sender using api ?

Any help in this regard would be highly appreciated.

Answers


Marcos Placona February 2016

Twilio developer evangelist here.

You will be able to find documentation about alphanumeric sender id's on the What is Alphanumeric Sender ID and how do I get started? page. Specifically, if you look under What characters can I use as the sender ID? you will find the following:

You may use any combination of 1 to 11 letters, A-Z and numbers, 0-9. Both lowercase and uppercase characters are supported as well as spaces. 1 letter and no more than 11 alphanumeric characters may be used.

A regular expression for this will vary depending on the programming language you're using, and in many cases you will find the language will have helpers for those things.

Also have a look at the list of countries where this functionality is supported.

Depending on the language you're using, the following pattern should do what you want, but like I said before you may wanna add limitations to the string using your language of choice.

/^(?=.*[a-zA-Z])(?=.*[a-zA-Z0-9])([a-zA-Z0-9 ]{1,11})$/m

A live version can be seen here.

Hope this helps you

Post Status

Asked in February 2016
Viewed 2,338 times
Voted 8
Answered 1 times

Search




Leave an answer