Python Client
To get the IP to replace the main_url example kindly contact us.
The following methods are for python users.
main_api = "http://main_url/mspaceservice/wr/sms/"
In order to use the sms api, one MUST have an api key to be included in all requests sent. If you don't have an api key, please sign up here. Below are the steps to follow to generate the key.
Sending SMS can be done by doing either a POST or a GET Request. Both methods are shown below.
Endpoint: https://api.mspace.co.ke/smsapi/v2/sendtext
Header: apikey: <Your_api_key>
If you don't have the api key check the API Overview menu and follow the procedure to generate one.
"apikey": "your_api_key"
"Content-Type": "application/json"
"Accept": "application/json"
You can also do a POST request using xml body instead of json. Below is the how to:
"apikey": "your_api_key"
"Content-Type": "application/xml"
"Accept": "application/xml"
<sms> <username>Your_Username</username> <senderId>Your_Sender_Id</senderId> <recipient>0722XXXXXX,254733XXXXXX</recipient> <message>Your message.</message> </sms>
https://api.mspace.co.ke/smsapi/v2/sendtext/apikey=<your_api_key>/username=your_username/senderId=your_sender_id/recipient=0722XXXXXX,254733XXXXXX/message=Your message.
The below response applies to both POST and GET requests.
To any errors encountered such as status 400, 404 etc;
Checking delivery report can be done by doing either a POST or a GET Request. Both methods are shown below.
Endpoint: https://api.mspace.co.ke/smsapi/v2/deliveryreport
Header: apikey: <Your_api_key>
If you don't have the api key check the API Overview menu and follow the procedure to generate one.
"apikey": "your_api_key"
"Content-Type": "application/json"
"Accept": "application/json"
You can also do a POST request using xml body instead of json. Below is the how to:
"apikey": "your_api_key"
"Content-Type": "application/xml"
"Accept": "application/xml"
<dlr> <username></username> <messageId>49032372</messageId> </dlr>
https://api.mspace.co.ke/smsapi/v2/deliveryreport/apikey=<your_api_key>/username=/messageId=49032372
The below response applies to both POST and GET requests.
To any errors encountered such as status 400, 404 etc;
Checking SMS balance can be done by doing either a POST or a GET Request. Both methods are shown below.
Endpoint: https://api.mspace.co.ke/smsapi/v2/balance
Header: apikey: <Your_api_key>
If you don't have the api key check the API Overview menu and follow the procedure to generate one.
"apikey": "your_api_key"
"Content-Type": "application/json"
"Accept": "application/json"
You can also do a POST request using xml body instead of json. Below is the how to:
"apikey": "your_api_key"
"Content-Type": "application/xml"
"Accept": "application/xml"
<user> <username>your_username</username> </user>
https://api.mspace.co.ke/smsapi/v2/balance/apikey=<your_api_key>/username=your_username
The below response applies to both POST and GET requests.
The response is an integer value that shows the sms balance.
7628
To any errors encountered such as status 400, 404 etc;
Quering sub users can be done by doing either a POST or a GET Request. Both methods are shown below.
Endpoint: https://api.mspace.co.ke/smsapi/v2/subusers
Header: apikey: <Your_api_key>
If you don't have the api key check the API Overview menu and follow the procedure to generate one.
"apikey": "your_api_key"
"Content-Type": "application/json"
"Accept": "application/json"
You can also do a POST request using xml body instead of json. Below is the how to:
"apikey": "your_api_key"
"Content-Type": "application/xml"
"Accept": "application/xml"
<user> <username>your_username</username> </user>
https://api.mspace.co.ke/smsapi/v2/subusers/apikey=<your_api_key>/username=your_username
The below response applies to both POST and GET requests.
To any errors encountered such as status 400, 404 etc;
Quering reseller clients can be done by doing either a POST or a GET Request. Both methods are shown below.
Endpoint: https://api.mspace.co.ke/smsapi/v2/resellerclients
Header: apikey: <Your_api_key>
If you don't have the api key check the API Overview menu and follow the procedure to generate one.
"apikey": "your_api_key"
"Content-Type": "application/json"
"Accept": "application/json"
You can also do a POST request using xml body instead of json. Below is the how to:
"apikey": "your_api_key"
"Content-Type": "application/xml"
"Accept": "application/xml"
<user> <username>your_username</username> </user>
https://api.mspace.co.ke/smsapi/v2/resellerclients/apikey=<your_api_key>/username=your_username
The below response applies to both POST and GET requests.
To any errors encountered such as status 400, 404 etc;
Sub-Account top ups can be done by doing either a POST or a GET Request. Both methods are shown below.
Endpoint: https://api.mspace.co.ke/smsapi/v2/subacctopup
Header: apikey: <Your_api_key>
If you don't have the api key check the API Overview menu and follow the procedure to generate one.
"apikey": "your_api_key"
"Content-Type": "application/json"
"Accept": "application/json"
You can also do a POST request using xml body instead of json. Below is the how to:
"apikey": "your_api_key"
"Content-Type": "application/xml"
"Accept": "application/xml"
<subAccTopups> <username>Your_Username</username> <subaccname>Sub_Acc_Name</subaccname> <noOfSms>9000</noOfSms> </subAccTopups>
https://api.mspace.co.ke/smsapi/v2/subacctopup/apikey=<your_api_key>/username=Your_Username/subaccname=Sub_Acc_Name/noofsms=9000
The below response applies to both POST and GET requests.
The response is a plain string with a success message as below:
Successful Top up of 9000 SMS to <Sub_Acc_Name>
To any errors encountered such as status 400, 404 etc;
Reseller-Client top ups can be done by doing either a POST or a GET Request. Both methods are shown below.
Endpoint: https://api.mspace.co.ke/smsapi/v2/resellerclienttopup
Header: apikey: <Your_api_key>
If you don't have the api key check the API Overview menu and follow the procedure to generate one.
"apikey": "your_api_key"
"Content-Type": "application/json"
"Accept": "application/json"
You can also do a POST request using xml body instead of json. Below is the how to:
"apikey": "your_api_key"
"Content-Type": "application/xml"
"Accept": "application/xml"
<resellerClientTopups> <username>Your_Username</username> <clientname>Client_Name</clientname> <noOfSms>1000</noOfSms> </resellerClientTopups>
https://api.mspace.co.ke/smsapi/v2/resellerclienttopup/apikey=<your_api_key>/username=your_username/clientname=Client_Name/noofsms=1000
The below response applies to both POST and GET requests.
The response is a plain string with a success message as below:
Successful Top up of 9000 SMS to <Client_Name>
To any errors encountered such as status 400, 404 etc;
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.
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.
http://main_url/mspaceservice/wr/sms/balance /username=myusername/password=mypassword
You can test this by pasting in your browser and press enter.
â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 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:
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:
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(Class responseType, String username, String password);
Returns XML object of the returned value by this method, example:
subUsers_JSON(Class responseType, String username, String password);
Returns JSON object of the returned value by this method,
example: login_TEXT(this.username, this.password);
Returns PLAIN_TEXT object of the returned value by this method, example:
resellerClientTopup_XML(Class responseType, this.reselerUsername, this.resellerPassword, this.clientName, this.noOfsms);
Returns XML object of the returned value by this method,
example: 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(Class responseType, String username, String password);
Returns XML object of the returned value by this method, example:
resellerClients_JSON(Class responseType, String username, String password);
Returns JSON object of the returned value by this method,
example: 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}}
The following methods are for python users.
main_api = "http://main_url/mspaceservice/wr/sms/"
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:
The widget for the plugin is available on all your widgets areas.
To use the plugin in your PHP code, see below example:
The connection between the application and the SMPP server is SMPP version 3.4.
NAME | DESCRIPTION |
---|---|
system _ id | Provided for each client |
password | Provided for each client |
IP address | To be provided |
port | 2775 |
timeout (keep alive) | 50 sec |
You are allowed to bind as transmitter or receiver. In order to receive delivery reports, you must bind as receiver.
bind _ transmitter, bind _ reciever, unbind, submit _ sm, deliver _ sm, enquire _ link
“id:<message _ id> sub:<message _ sub> dlvrd:<message _ dlvrd> submit date:<message _ submit _ date> done date:<message _ done _ date> stat:<message _ stat> err:<message _ err>”
DELIVRD, EXPIRED, UNDELIV , ACCEPTD, UNKNOWN, REJECTED
For more information please email info@mspace.co.ke or call +254722962934
For a user to process any USSD request with MSpace Solutions, one needs to setup an account with us. Once that is done, the following follows.
A USSD mobile request must have the MSSDN,SESSION_ID,CALLBACK_URL,
USER_DATA
information appended to it. This request will be sent to the third party ia
the endpoint URL provide by the client. This data is JSON formatted
ELEMENT NAME | DESCRIPTION |
---|---|
MSISDN | This is the mobile number that sends the POST request. |
SESSION_ID | This is the session id. It’s unique to every request send. It represents a single USSD session. |
CALLBACK_URL | Provided by the client. It will be triggered any time a request is sent. |
USSD_STRING | This is the information a user enters as he interacts with the USSD menus. This data is stored in a database |
SERVICE_CODE | This is the code provided by the client that will be used in the API parameters |
USSD is session driven. Generated response represents menus that will be shown to the person dialing the USSD code. USSD uses CON keyword to initiate a connection and END keyword to end a session. In the case of an error, a malformed response will be sent and the USSD session will terminate immediately and the USSD application flow will break.
Elysee(Ntashart) Plaza, Kilimani Road, 2nd Floor Suite 4A
Kampala, Makerere Hill Road, Ham Towers, 3rd floor, Suite No HT 25
Become the premier mobile solutions provider in East Africa.
To offer innovative, cutting edge, value adding mobile solutions, offering superior products and outstanding services through the use of modern, reliable and cost effective ICT technologies.
We are committed to the three pillars that form the foundation of MSpace Solutions.