Web Services API (Legacy)

📘

Important: API Channel Activation for New Accounts and Sub-Accounts

When you create a new Account or Sub-Account, please be aware that by default, no API channels will be active. To enable API access and manage your Accounts and Sub-Accounts' API credentials and settings, please follow the steps outlined in the "API Keys" page.

Note for Accounts Created Before 6 June 2023: If you have an Account that was created before 6 June 2023, the API channels would have been automatically enabled. However, if you wish to switch to an alternative API or use additional APIs, you will need to create an API Key for the desired API.

Overview

The web service can be referenced at https://api.smsportal.com/api5/api.asmx
The naming convention describes what the function accepts and returns. E.g.: Reply_STR_DS will accept an XML string and return a data set (.net object).
Most of the functions follow a common thread: accept 3 parameters, return XML or dataset.
The returned data will always contain the following:

</api_result>
	<call_result>
		<result>True</result>
		<error/>
	</call_result>
</api_result>

The result will be either “True” or “False”.
If “False” the error will be displayed with the “error” tag.

Sending Messages (Web Services)

To send is relatively easy, but due to the various options it can seem confusing.
In a nutshell:
If you specify a default then it will only be utilised if the entry data does not exist. If neither exists then it will throw an error.
There are 5 methods for sending your messages:

  1. Send_DS_DS (Accepts data set, returns data set)
  2. Send_STR_DS (Accepts XML string, returns data set)
  3. Send_STR_STR (Accepts XML string, returns XML string)
  4. Send_DS_STR (Accepts data set, returns XML string)
  5. Send _ZIP_ZIP (Accepts zipped stream, returns zipped stream)

Each function accepts 3 parameters

  • Username (string)
  • Password (string)
  • XML string or data set or compressed byte array (depending on the function you choose).

The XML objects looks like this:

<senddata>
	<settings>
		<live>True</live>
		<return_credits>True</return_credits>
		<return_msgs_credits_used>True</return_msgs_credits_used>
		<return_msgs_success_count>True</return_msgs_success_count>
		<return_msgs_failed_count>True</return_msgs_failed_count>
		<return_entries_success_status>True</return_entries_success_status>
		<return_entries_failed_status>True</return_entries_failed_status>
		<default_senderid/>
		<default_date>01/Jan/2018</default_date>
		<default_time>11:15</default_time>
		<default_curdate>01/Jan/2018</default_curdate>
		<default_curtime>11:15</default_curtime>
		<default_data1>This is a default msg</default_data1>
		<default_data2/>
		<default_flash>False</default_flash>
		<default_type>SMS</default_type>
		<default_costcentre>NA</default_costcentre>
		<default_validityperiod>0</default_validityperiod>
	</settings>
	<entries>
		<numto>082*******</numto>
		<customerid>UnqiueValue1</customerid>
		<senderid>Test me</senderid>
		<time>11:15</time>
		<data1>This is a test message 1!</data1>
		<data2/>
		<flash>False</flash>
		<type>SMS</type>
		<costcentre>NA</costcentre>
		<validityperiod>0</validityperiod>
	</entries>
</senddata>

XML Tag Table

The following table determines how the result is formatted, as well as defining the defaults.

liveIf Live = false then it will return the result but won’t send the data. It won’t appear in your sent report.True
return_creditsIf True then the current credits count will be returned.False
return_msgs_credits_used If True then the amount of credits used will be returnedFalse
return_msgs_success_countIf True then the total success data count will appear in the result.False
returnentries
failed_status
If True then the total failed data count will appear in the result.False
return_entries_success_status If True then the data that is accepted will be returned in the result.False
return_entries_failed_statusIf True then the data that is rejected will be returned in the result.False
default_senderid This is the default setting for the call but can be overridden by the individual entries. Only certain accounts can alter this.Repliable
*default_date This is the date the messages must be sent out.
Format is dd/MMM/yyyy eg: 13/apr/2009
-
*default_time This is the time the messages must be sent out.
Format is HH:mm eg: 17:34
-
default_curdate This is the current date on your server. It is used to determine when your messages should go out. If not used then the server date is used.Sever Date
default_curtime This is the current time on your server. It is used to determine when your messages should go out. If not used then the server time is used.Server Time
default_data1 This is the default setting for the call but can be overridden by the individual entries.
default_data2 This is the default setting for the call but can be overridden by the individual entries.
default_flash This is the default setting for the call but can be overridden by the individual entries.False
default_type This is the default setting for the call.SMS
default_costcentre Will be used in future.""
mo_forwardemail All incoming replies will be forwarded to this email address""
default_validityperiod This is the amount of time, in hours, that an SMS should remain valid. The network will continue to try to deliver the SMS for the amount of time specified.-

🚧

All tags marked with * are mandatory

🚧

Post Paid Customers

Return Credits will always return a value of 1000000 on Post Paid accounts as no credit deduction occurs on this account type.

XML tagDescription
entries_failed If this tag exists then some of the data you pushed has errors.
If will contain: “numto”, “customerid” and “reason”. The reason will be
numto invalid
senderid invalid
time invalid
flash invalid
costcentre invalid
type invalid
data1 invalid
data2 invalid
* data1 + data2 invalid
entries_success If this tag exists then it will contain “numto” and “customerid”.
send_info This describes the overall data returned. It WILL contain “eventid” and COULD have “credits”, “msgscredits_used”, “msgs_success” and “msgs_failed”.
Credits = credits remaining in account
Msgs_credits_used = the amount of credits used
Msgssuccess = a count of the messages accepted for delivery
Msgs_failed = a count of the messages rejected

The output of the following will be defined by the input of the above parameters:

<api_result>
	<entries_failed>
		<numto/>
		<customerid/>
		<reason>numto invalid</reason>
	</entries_failed>
	<entries_success>
		<numto>2782*******</numto>
		<customerid>UnqiueValue1</customerid>
	</entries_success>
	<entries_success>
		<numto>2782*******</numto>
		<customerid>UnqiueValue1</customerid>
	</entries_success>
	<entries_success>
		<numto>27832297941</numto>
		<customerid>d47e1efd‐5e4f‐4832‐ba7f‐07f35d8c10f9</customerid>
	</entries_success>
	<send_info>
		<eventid>27105067</eventid>
		<credits>39763</credits>
		<msgs_credits_used>3</msgs_credits_used>
		<msgs_success>3</msgs_success>
		<msgs_failed>1</msgs_failed>
	</send_info>
	<call_result>
		<result>True</result>
		<error/>
	</call_result>
</api_result>

The following table determines how the result is formatted, as well as defining the defaults.

XML tagDescriptionDefault
liveIf Live = false then it will return the result but won’t send the data. It won’t appear in your sent report.True
return_msgs_credits_used If True then the amount of credits used will be returned.False
return_credits If True then the current Credits count will be returned.False
return_msgs_success_count If True then the total success data count will appear in the result.False
return_entries_failed_status If True then the total failed data count will appear in the result.False
return_entries_success_status If True then the data that is accepted will be returned in the result.False
return_entries_failed_status This is the default setting for the call but can be overridden by the individual entries. Only certain accounts can alter this.False
*default_date This is the date the messages must be sent out.
Format is dd/MMM/yyyy eg: 13/apr/2009
-
*default_time This is the time the messages must be sent out.
Format is HH:mm eg: 17:34
-
default_curdate This is the current time on your server. It is used to determine when your messages should go out. If not used then the server time is used.Server Date
default_curtime This is the current time on your server. It is used to determine when your messages should go out. If not used then the server time is used.Server Time
default_data1 This is the default setting for the call but can be overridden by the individual entries.""
default_data2 This is the default setting for the call but can be overridden by the individual entries.""
default_flash This is the default setting for the call but can be overridden by the individual entries.False
default_type This is the default setting for the call.SMS
default_costcentre ""
mo_forwardemail All incoming replies will be forwarded to this email""
default_validityperiod The amount of time in hours an SMS should remain valid. The network will continue to try to deliver the SMS over the validity period.-

RETRIEVING SENT DATA - (DATA SET AND XML)

There are 5 methods for retrieving sent items:

  • Sent_DS_DS (Accepts data set, returns data set)
  • Sent_STR_DS (Accepts XML string, returns data set)
  • Sent_STR_STR (Accepts XML string, returns XML string)
  • Sent_DS_STR (Accepts data set, returns XML string)
  • Sent_ZIP_ZIP (Accepts zipped stream, returns zipped stream)

Each function accepts 3 parameters

  • Username (string)
  • Password (string)
  • XML string or data set (depending on the function you choose)

The XML object looks like this:

<sent>
	<settings>
		<id>0</id>
		<max_recs></max_recs>
		<cols_returned></cols_returned>
		<date_format>yyyyMMddHHmmss</date_format>
	</settings>
</sent>
ParameterDescriptionDefault
*IDThe max CHANGEID from the previous call. Start with “0”-
Max_recsThe number of records returned from the call. Values 1 to 100100
Cols_ReturnedThe xml tags returned in the result. Options are: sentid, eventid, smstype, numto, data, flash, customerid, status, statusdate. Each entry must be separated by a comma.ChangeID
Date FormatThe format of any dates that are returned.dd/MMM/yyyy HH:mm:ss

🚧

All entries marked with * are mandatory

The output returned will be a data set or XML in the following format:

<api_result>
	<data>
		<changeid></changeid>
		<sentid></sentid>
		<eventid></eventid>
		<smstype></smstype>
		<numto></numto>
		<data></data>
		<flash></flash>
		<customerid></customerid>
		<status></status>
		<statusdate></statusdate>
	</data>
	<call_result>
		<result></result>
		<error/>
	</call_result>
</api_result>
XML tagDescription
changeidA unique ID identifying the change in a message status.
sentidA unique value for each message. You could receive the same SentID back if the message status changes.
eventidWhen sending, an eventid is generated and returned in the result xml. This eventid can be for 1 or “infinity” message entries.
smstypeThis is the type of message sent. (Default = SMS)
numtoThe number the message was sent to.
dataThe data sent to the user.
customeridThe customerid for the message when the data was sent.
statusThe message status. Options are “DELIVRD”, “UNDELIV”, ”UNKNOWN”, ”EXPIRED”.
statusdateThe date and time the message was sent.

RETRIEVING REPLIES - (OVERVIEW)

The design allows the following:

  • Retrieval of items you have not already pulled
  • Instant retrieval of data (due to API table design and indexing)
  • Customisable result formatting
  • Prevention of timeouts

So how is this achieved?
The API system uses a unique identity field called “replyid” which is permanently incrementing. When an inbound message is received from the corresponding network, a new record is written to the API and the replyid will increment by 1.

In the result set, the element “replyid” will be present along with the other elements you have specified.
This needs to be stored and the maximum replyid utilised by the next call. The following is occurring within the SMS gateway:

“Select top 100 * from API_Reply_Table where replyid > @ID order by replyid asc”

📘

Tips

  • Start with id (replyid) = 0.
  • Store the max replyid in your local system, permanently (database or IO system).
  • Only pull back data you require, using the “cols_returned” element (this will reduce bandwidth).

🚧

Limitations

  • Inbound messages are only retained for up to seven days, i.e. replies that were sent more than a week ago cannot be retrieved via Web Services.

  • Only replies to messages that were sent via Web Services, and from the account that was used for authentication, can be retrieved. E.g. sub accounts cannot retrieve each other’s messages, and replies to messages sent via FTP cannot be retrieved via Web Services.

RETRIEVING REPLIES - (DATA SET AND XML)

There are 5 methods for retrieving replies:

  • Reply_DS_DS (Accepts data set, returns data set)
  • Reply_STR_DS (Accepts XML string, returns data set)
  • Reply_STR_STR (Accepts (XML string, returns XML string)
  • Reply_DS_STR (Accepts data set, returns XML string)
  • Reply_ZIP_ZIP (Accepts zipped stream, returns zipped stream)

Each function accepts 3 parameters:

  • Username (string)
  • Password (string)
  • XML string or data set (depending on the function you choose)

The XML object looks like this:

<reply>
	<settings>
		<id></id>
		<max_recs></max_recs>
		<cols_returned> </cols_returned>
		<date_format> </date_format>
	</settings>
</reply>
ParameterDescriptionDefault
*IDThe max REPLYID from the previous call-
Max_recsThe number of records returned from the call. Values 1 to 100100
Cols_ReturnedThe xml tags returned in the result. Options are: replyid, eventid, numfrom, receiveddata, received, sentid, sentdata, sentdatetime, sentcustomerid, optout. Each entry must be separated by a comma.Replyid
Date FormatThe format of any dates that are returned.dd/MMM/yyyy HH:mm:ss

🚧

All entries marked with * are mandatory

The output returned will be a data set or XML in the following format:

<api_result>
	<data>
		<replyid></replyid>
		<eventid></eventid>
		<numfrom></numfrom>
		<receiveddata>123</receiveddata>
		<sentid></sentid>
		<sentdata></sentdata>
		<sentcustomerid/>
		<received></received>
		<sentdatetime></sentdatetime>
	</data>
	<call_result>
		<result></result>
		<error/>
	</call_result>
</api_result>
replyidThe max unique REPLYID for each incoming message
eventidWhen sending an eventid is generated and returned in the result xml. This eventid
can be for 1 or “infinity” message entries.
numfromThe number of the user that sent the incoming message
receiveddataThe data that the user returned
receivedThe date and time the message was received
sentidThe unique sentid for the outgoing message
sentdataThe data sent to the user
sentdatetimeThe date and time the message was sent
sentcustomeridThe customerid for the message when the data was sent
optoutContains the value 1 if the received data matched an opt-out phrase, or 0 if not.

Retrieve Incoming Short Code Entries

The SMS gateway is designed to allow easy retrieval of your inbound messages (shortcodes).
The design allows the following:

  • Retrieval of items you have not already pulled
  • Instant retrieval of data (due to API table design and indexing)
  • Customisable result formatting
  • Prevention of timeouts

So how is this achieved?

The API system uses a unique identity field called “changeid”, which is permanently incrementing.
When an inbound message is received from the corresponding network, a new record is written to the API and the changeid will increment by 1.
In the result set, the element “changeid” will be present along with the other elements you have specified. This needs to be stored and the maximum changeid utilised by the next call. The following is occurring within the SMS gateway:

“Select top 100 * from Short Code_Table where ID > @ID order by ID asc”

There are 6 methods available for retrieving replies:

  1. ShortCode_Get_DS_DS
  2. ShortCode_Get_DS_STR
  3. ShortCode_Get_DS_ZIP
  4. ShortCode_Get_STR_DS
  5. ShortCode_Get_STR_STR
  6. ShortCode_Get_STR_ZIP

Each function accepts 3 parameters:

  • Username (string)
  • Password (string)
  • XML string or data set (depending on the function you choose)

The XML object looks like this:

<options>
	<settings>
		<id>0</id>
		<date_format>Dd/MMM/yyyy HH:mm:ss</date_format>
		<shortcode>unique5digitnumber</shortcode>
		<keyword></keyword>
		<cols_returned>changeid,shortcode,keyword,phonenumber,message,received,mnc,mcc</cols_returned>
	</settings>
</options>
XML tagDescriptionDefault
*IDThe max ChangeID from the previous call.-
Date_FormatThe format of any dates that are returned.Dd/MMM/yyyy HH:mm:ss
ShortcodeThe short code (5 digit number). If nothing is specified then all short codes are returned.0
KeywordSearch on a keyword. If a keyword has been allocated to your account eg: “test” you can specify to retrieve only these entries.""
Cols_ReturnedThe following parameters are available in any combination: changeid, shortcode, keyword, phonenumber, message, received, mnc, mcc. If nothing is specified changeid, shortcode, keyword, phonenumber, message, received will be returned as a default.As mentioned.

🚧

All entries marked with * are mandatory

The output returned will be a data set or XML in the following format:

<api_result>
	<data>
		<changeid>100</changeid>
		<shortcode>unique5digitnumber</shortcode>
		<keyword></keyword>
		<phonenumber>2783*******</phonenumber>
		<message>Testing</message>
		<received>19/Jan/2024 13:40:58</received>
		<mnc>01</mnc>
		<mcc>655</mcc>
	</data>
	<call_result>
		<result>True</result>
		<error/>
	</call_result>
</api_result>
XML tagDescription
ChangeIDThe max unique ChangeID for each incoming message.
ShortcodeThe short code (5 digit number).
KeywordIf the shortcode has been separated on a keyword. it will be displayed.
Each keyword can have its own properties.
PhonenumberThe number the message was received from.
MessageThe message received.
ReceivedThe date the message was received.
mncThe Mobile Network Code
mccThe Mobile Country Code

Please see the list of available code examples below:

C# Example

Download

Vb.Net Example

Download

Delphi Example

Download

Check Balance (Web Services)

There are 2 methods for checking your credits:

  1. Credits_STR (Returns XML string)
  2. Credits_DS (Returns data set)

Each function accepts 2 parameters:

  • Username (string)
  • Password (string)

The return object looks like this:

<api_result>
	<data>
		<credits>xxxxx</credits>
	</data>
	<call_result>
		<result>True</result>
		<error />
	</call_result>
</api_result>

Your current credit value will be displayed between the “credits” tag.

🚧

Post Paid Customers

Credits will always return a value of 1000000 on Post Paid accounts as no credit deduction occurs on this account type.