Easily integrate SMS sending functionality to your app or website using Message Hero’s RESTful SMS API.
![]()
Signup for a free Message Hero account, create a from tag and top up.
![]()
You need to call our API to get an authentication token before you can send an SMS.
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);
}
});
![]()
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); } });
| 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 |
![]()
Enter your Message Hero username and password into our test harness below to try our API.
| or
|