SMS API

Simple SMS API for Developers

Easily integrate SMS sending functionality to your app or website using Message Hero’s RESTful SMS API.


Signup to use our SMS API

Step 1: Signup

Signup for a free Message Hero account, create a from tag and top up.





Pre-pay SMS API with secure credit card top up

Great-Value Pre-Pay SMS

Each SMS costs just 3.3p/SMS. No monthly fees or charges. Just sign up free, choose a message bundle to suit your needs, top up and send.
Use Custom From Labels with our SMS API

Create Custom 'From' Tag

Set your 'from' tag to a business name up to 11 characters long to personalise the sender name on the SMS your customers see on their phones.
Send longer SMS up to 459 characters through our API

Send Longer SMS

Message Hero's SMS API lets you send single SMS (up to 160 characters) or multi-part SMS (up to 459 characters long, 3 x 153 characters).
Receive real-time SMS replies online

Support for UK & Irish Numbers

Message Hero currently supports sending SMS to all UK & Irish mobile numbers. Support for sending International SMS coming soon.

Authenticate yourself with our SMS API

Step 2: Authenticate

You need to call our API to get an authentication token before you can send an SMS.

Your Token will last 24 hours after which you need to re-authenticate.


 jQuery example: var token = ''; var email = 'mhemail@domain.com'; var password = 'mhpassword'; $.ajax({ url: 'https://www.messagehero.com/api/token', type: 'post', data: { email: email, password: password, grant_type: 'password' }, success: function (response) { if (response.access_token != undefined) { token = response.access_token; } else { alert(response.responseMessage); } }, error: function($xhr) { alert($.parseJSON($xhr.responseText) .ResponseMessage); } }); 

Call our SMS API to Send SMS from your website or app

Step 3: Call the API

It's simple to send SMS through the Message Hero API once you are signed up and authenticated.



 jQuery example:
var message = JSON.stringify({ msisdn: '35386XXXXXXX', userFromTag: 'Business', messageText: 'Your Message Text' }); $.ajax({ url: 'https://www.messagehero.com/api/message/send', type: 'post', contentType: 'application/json', dataType: 'json', headers: { Authorization: 'bearer ' + token }, data: message, success: function (response) { alert(response.responseMessage); alert(response.responseCodeId); }, error: function($xhr) { alert($.parseJSON($xhr.responseText) .ResponseMessage); alert($.parseJSON($xhr.responseText) .ResponseCodeId); } });
 jQuery example:
var msisdn = '35386XXXXXXX'; var userFromTag = 'Business'; var messageText = 'Your Message Text'; $.ajax({ url: 'https://www.messagehero.com/api/message/send/' + msisdn + '/' + userFromTag + '/' + messageText, type: 'get', contentType: 'application/json', headers: { Authorization: 'bearer ' + token }, success: function (response) { alert(response.responseMessage); alert(response.responseCodeId); }, error: function($xhr) { alert($.parseJSON($xhr.responseText) .ResponseMessage); alert($.parseJSON($xhr.responseText) .ResponseCodeId); } });

Call our SMS API to Send SMS from your website or app

Response Codes

There are thirteen response codes you can receive from our API when you call it.



Number Response Code
0 Operation successful
1 The email address or password is incorrect
2 Invalid API token or no API token provided
3 Unsupported media type - Ensure Content-Type header is set to application/json
4 Operation failed: A system error occurred
5 Operation failed: No credit
6 Operation failed: Invalid From tag
7 Operation failed: Message is empty
8 Operation failed: Message is greater than 459 chars
9 Operation failed: The optout message must be included
10 Operation failed: Duplicate message detected
11 Operation failed: Invalid phone number
12 Operation failed: The contact is opted out

Test our SMS API

Test our SMS API

Enter your Message Hero username and password into our test harness below to try our API.