MSpace Bulk SMS Service API Documentation
This page illustrates how you, a developer, a technical personnel or any form
of our esteemed
client can use our bulk SMS services with ease without necessarily logging into our web application.
After this illustration you will be able to send texts, query SMS account balance and list your sub-
account users in the system. This documentation assumes that you have subscribed for our bulk SMS
services. If not please visit our website ‘www.mspace.co.ke’ or contact our offices to be assisted and be
able to enjoy our services.
OverView of the API
Content
- Query SMS balance
- Send Text
- Query sub-account users
- Query Re-seller users
- System Login
- Re-seller client Top up
- sub-account users Top up
Overview
This is the get balance url =
“ http://main_url/mspaceservice/wr/sms/balance /username={username}/password={password}”
,
where username is the value of your username and
password the value of your password.
To get the IP to replace the main_url example kindly contact us.
Example:
http://main_url/mspaceservice/wr/sms/balance /username=myusername/password=mypassword
You can test this by pasting in your browser and press enter.
Response:
“your sms balance e.g. ‘50’” if you are a subscribed user or “Error 100:
Authentication Failure” if your credentials are wrong.
NOTE that your URL format should support URL encoding UTF- 8 . Messages that are
not properly formatted may be delivered with incorrectly encoded text or not
delivered at all.
The request methods are summarized in the table below:
main_url = http://main_url/mspaceservice/wr/sms
Method |
Query SMS Balance |
Url Structure |
main_url/balance/username={username}/password={password} |
Url example |
http://main_url/balance/username=myusername/password=mypassword |
Response on success |
Your current SMS balance e.g. “50”. |
Response on failure |
Authentication failure for wrong user credentials or non-existing user. |
Method |
Send Text |
Url Structure |
main_url/sendtext/username={username}/password={password}/senderid={senderId}/recipient={recipient}/message={message} |
Url example |
http://main_url/sendtext/username=myusername/password=mypassword/senderid=mysenderid/recipient=myrecipient/message=mymessage |
Response on success |
Send action status and the sent message id i.e.“[{"messageId": "12345", "responseTime": "2018-06-2511:12:19:793", "status": "successful"}]” |
Response on failure |
Athentication failure,Insufficient Balance, Invalid sender ID or internal service error. |
Method |
Query sub-account users |
Url Structure |
main_url/subusers/username={username}/password={password} |
Url example |
http://main_url/subusers/username=myusername/password=mypassword |
Response on success |
The username of your sub-account users and their SMS balances respectively i.e. “[{"smsBalance": "20", "subUserName": "subuser1"},{"smsBalance": "18", "subUserName": "subuser2"}]”“[]” if no subuser exists. |
Response on failure |
Authentication failure. |
Method |
Query Re-Seller users |
Url Structure |
main_url/resellerclients/username={username}/password={password} |
Url example |
http://main_url/resellerclients/username=myusername/password=mypassword |
Response on success |
The username of your clients and their SMS balances respectively i.e. “[{"smsBalance": "20", "clientname": "client1"}, {"smsBalance": "18", "clientname": "client2"}]” |
Response on failure |
Authentication failure. |
Method |
Re-Seller users Top-up |
Url Structure |
main_url/resellerclienttopup/username={username}/password={password} /clientname={clientname}/noofsms={noofsms} |
Url example |
http://main_url/resellerclienttopup/username=myusername/password=mypassword/clientname={myclientname}/noofsms={noofsms} |
Response on success |
Successful Top up of noOfSms SMS to clientname. |
Response on failure |
Athentication failure, Insufficient Balance, You are not Authorized to make this transaction, indly Contact Providers for help, Failed to top up clientname account, Top up not Successful, Failed to deduct your account, or internal service error. |
Method |
Sub-Account users Top-up |
Url Structure |
main_url/subacctopup/username={username}/password={password}/subaccname={subaccname}/noofsms={noofsms} |
Url example |
http://main_url/subacctopup/username=myusername/password=mypassword/subaccname={mysubaccname}/noofsms={noofsms} |
Response on success |
Successful Top up of noOfSms SMS to subAccName. |
Response on failure |
Athentication failure, Insufficient Balance,You are not Authorized to make this transaction,Kindly Contact Providers for help, Failed to top up subAccName account, Top up not Successful, failed to deduct your account, or internal service error. |
Method |
System Login |
Url Structure |
main_url/login/username={username}/password={password} |
Url example |
http://main_url/login/username=myusername/password=mypassword |
Response on success |
User exists. |
Response on failure |
Authentication failure. |
Java Client
Object type to be returned
Old Library
Java developers can be emailed or obtain the
java client API jar
file bundled with dependencies
here
and add into the class-path of their project. Having this
jar file,
your work will be made easier. The API contains all the request methods:
sendMessage_ JSON
subUsers_JSON(Class responseType, String username, String password, String senderid, String recipient,
String message);
Returns JSON object of the returned value by this method,
example:
sendMessage_XML
subUsers_XML(Class responseType, String username, String password, String senderid, String recipient,
String message);
Returns XML object of the returned value by this method,
example:
subUsers_XML
subUsers_XML(Class responseType, String username, String password);
Returns XML object of the returned value by this method,
example:
subUsers_JSON
subUsers_JSON(Class responseType, String username, String password);
Returns JSON object of the returned value by this method,
example:
System Login
login_TEXT(this.username, this.password);
Returns PLAIN_TEXT object of the returned value by this method,
example:
Re-Seller Top-Up
resellerClientTopup_XML(Class responseType, this.reselerUsername, this.resellerPassword, this.clientName, this.noOfsms);
Returns XML object of the returned value by this method,
example:
Sub-Account Top-Up
subAccTopup_JSON(Class responseType, this.mainAccname, this.mainAccPassword, this.subAccname, this.noOfsms);
Returns JSON object of the returned value by this method,
example:
resellerClients_XML
resellerClients_XML(Class responseType, String username, String password);
Returns XML object of the returned value by this method,
example:
resellerClients_JSON
resellerClients_JSON(Class responseType, String username, String password);
Returns JSON object of the returned value by this method,
example:
getBalance
getBalance(String username, String password);
Returns PLAIN_TEXT object of the returned value by this method,
example:
Closes the client instance.
To view your full request url, method type and request status by the API methods use Response class
as the response type. Example:
Output:
InboundJaxrsResponse{
ClientResponse{method=GET,
uri=http://main_url/mspaceservice/
wr/sms/subusers/username=
myusername/password=mypassword, status=200,
reason=OK}}
Bulk SMS Wordpress Plugin Installation
Many website are designed on top of wordpress CRM. MSpace has developed a plugin to enable customers easily
integrate their wordpress with Bulk SMS. This plugin supports below:
- Woocommerce
- Contact Form 7
- Custom PHP code
- Widget
Installation
Method 1
- Download the zipped plugin here
- Open your wordpress plugin page -> Click Add New -> Upload Plugin -> Browse. Select
the wp-sms.zip you downloaded above and then click on Install Now
- After successfull install, visit the plugins page and activate it then refresh your page. Your will
get a new menu namely SMS
Method 2
- Download the zipped plugin here
- Copy the zip into {PATH_TO_WORDPRESS}/wordpress/plugins/ folder and unzip it
- Visit the plugins poage and activate it then refresh your page. Your will get a new menu namely
SMS
Enabling Gateway
Click on on the plugin menu (SMS) in your wordpress admin -> Select Settings -> Click on Gateway
- Select mspace.co.ke on Gateway Name Drop-down
- Enter your Mspace Bulk SMS account username in API username field
- Enter your Mspace Bulk SMS account password in API password field
- Enter your Mspace Bulk SMS sender id in Sender number field
- Leave API key field empty
- Scroll Down and click on Save Changes button. Ignore any warnings
Activate Bulk SMS Api on Contact Form 7 and WooCommerce
On the plugin setting page above, select Integration.
- To activate the plugin on Contact Form 7, ensure the SMS meta box radio is ticked
This adds a SMS Newsletter in your contact form 7 setting panel.
- To activate the plugin on woocommerce, ensure radio button for New order is ticked. Create the message
body as per the instructions. This will automatically send sms to clients when the make new orders on
the e-commerce site
The widget for the plugin is available on all your widgets areas.
To use the plugin in your PHP code, see below example:
Other Features
Send SMS
You can send sms from your wordpress by selecting the plugin menu
Send SMS. Select either
subscribers -users who have filled in their details from your website forms. or your wordpress users and
also to your custom mobile numbers.
SMS Newsletter
Send Newsletter via SMS
Wordpress SMS Notification
Notify your subcribers when you have a new post etc.
Send Activation Codes
You can enable sending activation codes to your subscribers. This will ensure that all your subscribers are
genuine.
Use Actions
Below actions are available. Send emails when sending SMS
Send welcome SMS to users when they are registered.
Wordpress Hooks
Modify Numbers
Add New Numbers
Modify text messages
Export Your Subscribers
Export your subscribers to csv.
Rest API
Rest API is available so that you can integrate your wordpress SMS with other systems. Currently supports
only one endpoint as below. This is for adding new subscribers to SMS newsletters