API Documentation

Send a single message

This method allows you to send a single text message to a cell phone. Any replies made to the number will be sent to the default reply path set up on the username provided.

URL

http://api.mercurysend.com/1.0/send

Arguments

  • Username - the MercurySend portal username allocated to your account
  • Password - the MercurySend portal password allocated to your account
  • Recipients - the cell phone number the message is to be sent to. The number should include the country code
  • Message – the message text to be sent to the cell phone. Messages longer than 160 characters will be split into multiple messages
  • ReplyType (optional) – how any replies made from the cell phone should be handled. Valid values for this parameter are: EMAIL, HTTPPOST and HTTPGET
  • ReplyPath (optional) – where any replies made from the cell phone should be sent to
    • EMAIL - Email address of where the reply will be emailed to
    • HTTPPOST - URL of where the reply will be sent to. This reply type will do a HTTP POST to the URL
    • HTTPGET - URL of where the reply will be sent to. This reply type will do a HTTP GET to the URL

HTTPPOST/HTTPGET Reply Types

Any query string parameters provided on the reply path will be included on the reply call. The following placeholders will be replaced by MercurySend if provided:

  • #FROMCELL# - will be replaced with the senders cell phone
  • #TOCELL# - will be replaced with the MercurySend gateway number the recipient sent the reply to
  • #MSG# - will be replaced with the message the recipient replied with
  • #RECVTIME# - will be replaced with the time the MercurySend gateway received the reply

An example of a HTTPPOST/HTTPGET reply path is: http://www.yourdomain.com/Receive.aspx?From=#FROMCELL#&To=#TOCELL#&Message=#MSG#&ReceivedTime=#RECVTIME#

Sample code

C#
string username = "[USERNAME]";
string password = "[PASSWORD]";
string recipients = "[RECIPIENTS]";
string message = "[MESSAGE]";
string replyType = null; // Can be EMAIL, HTTPPOST and HTTPGET
string replyPath = null; // Can be email address for ReplyType = EMAIL, or URL for HTTPPOST/HTTPGET
// For HTTPPOST/HTTPGET replyPath = "http://www.yoururl.com/Receive.aspx?From=#FROMCELL#&To=#TOCELL#&Message=#MSG#&ReceivedTime=#RECVTIME#"
StringBuilder sb = new StringBuilder();
sb.Append("Username=" + HttpUtility.UrlEncode(username));
sb.Append("&Password=" + HttpUtility.UrlEncode(password));
sb.Append("&Recipients=" + HttpUtility.UrlEncode(recipients));
sb.Append("&Message=" + HttpUtility.UrlEncode(message));
if (!string.IsNullOrEmpty(replyType))
{
	sb.Append("&ReplyType=" + replyType);
}
if (!string.IsNullOrEmpty(replyPath))
{
	sb.Append("&ReplyPath=" + HttpUtility.UrlEncode(replyPath));
}
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api.mercurysend.com/1.0/send?" + sb.ToString());
string jsonResponse = null;
request.Method = "GET";
request.Accept = "application/json";
using (HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse())
{
	using (StreamReader reader = new StreamReader(httpResponse.GetResponseStream()))
	{
		jsonResponse = reader.ReadToEnd();
	}
}
						

Responses

Successful JSON Response
{
	"Result": {
		"Success":true,
		"Code":0
	},
	"MessageIds":[]
}
					
  • Result.Success - true/false
  • Result.Code - error code associated with a failed transaction
  • MessageIds - array of integers
Failed JSON Response
{
	"Result": {
		"Success":false,
		"Description":"Error description",
		"Code":1
	}
}
					
  • Result.Success - true/false
  • Result.Description - Description of error
  • Result.Code - error code associated with a failed transaction

Result codes

1 - Message lodged OK

Indicates that the message was lodged succesfully

2 - No credits

Indicates that the message failed due to insufficient credits on the account

3 - No daily credits

Indicates that the message failed due to insufficient daily credits remaining on the senders login

4 - Invalid arguments

Indicates that the message failed due to invalid arguments being sent in

5 - Not verified

Indicates that the message failed due to the senders account not yet being verified

6 - Outstanding orders

Indicates that the message failed due to the senders account having outstanding orders