Vaspro Documentation
Introduction
VasPro Messaging Platform offers Developer solutions to messaging that allow Application to Application communication.
The messaging APIs are agile, fast and very responsive.
Prerequisites
You need to have a VasPro account to integrate all the APIs successfully. You will get an API token from the API tab once you are logged in.
Signup LoginEach API request must include the API Key. APIs are RESTful with the allowed content type as JSON.
Base URL
Use this base URL in all your API requests.
Usage example:
- API Request:
- /v3/BulkSMS/bulk/create
- Base URL:
- https://api.vaspro.co.ke
- Request URL:
- https://api.vaspro.co.ke/v3/BulkSMS/bulk/create
Response Structure
The general response structure for all API calls is as below:
- code - The code has two values (Success and Error)
- statusDescription - It contains a brief description of the processing.
- data - The data component is available in some responses and contains the credits spent,success response, correlator(unique system Id).
Types of response codes
- 420 - Service Configuration Error (Service issues, ie. shortcode is NOT configured)
- 400 - Bad Request/Resource
- 404 - Resource is NOT available or Invalid Request
- 402 - Payment is Required (account balance is low to carry out a transaction)
- 422 - Validation Error (Missing Required Params)
- 200 - Request is Successfully Processed.
- 202 - Duplicated Request
Bulk SMS
POST Send Bulk SMS
- API:
- /v3/BulkSMS/bulk/create
Send bulk messages to your clients.
Note:
All messages are queued. Message delivery is determined by the capacity of queued messages.
Bulk messages are rate limited to 150 messages per second.
{ "apiKey":"api token here", "shortCode":"VasPro", "origin": "API_INTERFACE", "isScheduled": , "scheduleDate ": , "scheduleTime ": , "uniqueId":"12347", "enqueue": 1, "message": "", "contacts":{ "recipients":"07xxxxxxxx,07xxxxxxx" }, "callbackURL":"http://vaspro.co.ke/dlr" }
Parameter | Description | Required |
---|---|---|
apiKey string |
The user identifier Token | YES |
shortCode string |
The SenderID that will be used to broadcast the message. By default VasPro is enabled. It is normally 11 characters or below in length | YES |
isScheduled integer |
Scheduling Flag. The flags are: 1 - schedule 2 - normal delivery |
YES |
scheduleDate date |
If the scheduled flag is set to 1 then the date must be set | |
scheduleTime time |
Scheduling Time is Set in Future from current time | |
callbackURL string |
The Rest JSON Callback to receive delivery reports | |
contacts array / list |
Contacts to send out the text The Contacts should be in an array list | |
enqueue integer |
This flag has 2 values to enable the client to queue not not their messages. 1 - Queue 0 - No queueing |
YES |
message string |
The text message to be sent out to clients | YES |
uniqueID string |
The unique identifier from the client used to identify the request | YES |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/BulkSMS/bulk/create",
"method": "POST",
"headers": {
"cache-control": "no-cache",
},
"data": "{
"apiKey": "api token here",
"shortCode": "VasPro",
"origin": "API_INTERFACE",
"isScheduled": ,
"scheduleDate":
"scheduleTime": ,
"uniqueId": "12347",
"enqueue": 1,
"message": ""
"contacts":
{"recipients": "07xxxxxxxx,07xxxxxxx"},
"callbackURL": "http://vaspro.co.ke/dlr"
}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
POST Send Transactional SMS
- API:
- /v3/BulkSMS/api/create
Send transactional messages to your clients. The transactions are
{ "apiKey":"api token here", "shortCode":"VasPro", "recipient":"", "enqueue": 1, "message": "", "callbackURL":"http://vaspro.co.ke/dlr" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
shortCode | The SenderID that will be used to broadcast the message. By default VasPro is enabled. It is normally 11 characters or below in length | string | YES |
recepient | One number at a time | string | YES |
callbackURL | The Rest JSON Callback to receive delivery reports | string | |
enqueue | This flag has 2 values to enable the client to queue not not their messages. 1 - Queue 0 - No queueing |
integer | YES |
message | The text message to be sent out to clients | string | YES |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/BulkSMS/api/create",
"method": "POST",
"headers": {
"cache-control": "no-cache",
},
"data": "{
"apiKey": "api token here",
"shortCode": "VasPro",
"recipient": "",
"enqueue": 1,
"message": "",
"callbackURL": "http://vaspro.co.ke/dlr"
}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
POST Send Premium (2-way) SMS
- API:
- /v3/BulkSMS/premium/create
Send premium SMS to your clients
{ "apiKey":"api token here", "shortCode":"VasPro", "recipient":"", "enqueue": 1, "message": "", "callbackURL":"http://vaspro.co.ke/dlr", "link_id": "" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
shortCode | The SenderID that will be used to broadcast the message. By default VasPro is enabled. It is normally 11 characters or below in length | string | YES |
recepient | One number at a time | string | YES |
callbackURL | The Rest JSON Callback to receive delivery reports | string | |
enqueue | This flag has 2 values to enable the client to queue not not their messages. 1 - Queue 0 - No queueing |
integer | YES |
message | The text message to be sent out to clients | string | YES |
link_id | The unique identifier sent on receiving inbox (shortcode) notifications | string | YES |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/BulkSMS/premium/create",
"method": "POST",
"headers": {
"cache-control": "no-cache",
},
"data": {
"apiKey": "api token here",
"shortCode": "VasPro",
"recipient": "",
"enqueue": 1,
"message": "",
"callbackURL": "http://vaspro.co.ke/dlr",
"link_id": ""
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
POST Send Nested SMS
- API:
- /v3/BulkSMS/bulk/nested
Send multiple SMS with different content to different clients.
Note:
All messages are queued. Message delivery is determined by the capacity of queued messages.
Bulk messages are rate limited to 150 messages per second.
{ "apiKey":"api token here", "shortCode":"VasPro", "messageData":[ { "recepient": "07xxxxxxxx", "message": "", "uniqueId": ""}, ... ], "enqueue": 1, "message": "", "callbackURL":"http://vaspro.co.ke/dlr", "link_id": "" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
shortCode | The SenderID that will be used to broadcast the message. By default VasPro is enabled. It is normally 11 characters or below in length | string | YES |
messageData | Nested Message data containing the following fields: message - text message recipient - the mobile receiving the message uniqueId - required |
string | YES |
callbackURL | The Rest JSON Callback to receive delivery reports | string | |
enqueue | This flag has 2 values to enable the client to queue not not their messages. 1 - Queue 0 - No queueing |
integer | YES |
uniqueId | The unique identifier from the client used to identify the request | string | YES |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/BulkSMS/bulk/nested",
"method": "GET",
"headers": {
"cache-control": "no-cache",
},
"data": {
"apiKey": "api token here"
"shortCode": "VasPro",
"messageData":[
{ "recepient": "07xxxxxxxx", "message": "", "uniqueId": ""},
...
],
"enqueue": 1,
"message": "",
"callbackURL": "http://vaspro.co.ke/dlr",
"uniqueId": ""
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Contacts
GET View Contact Groups
- API:
- /v3/contact/api/groups
You can use contact API to view contact groups, add contact to contact group, edit contacts and view contact. To begin using it you need to enable all permission for contacts services on Vaspro Portal.
{ "apiKey": "api token here", "unique_id": 123, "limit": 123" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
unique_id | Unique identifier for each request you make | integer | |
phoneNumber | Contact to send out the MPESA push prompt | string | YES |
limit | Number of records to limit. By default it will limit 10 records | integer |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/contact/api/groups",
"method": "POST",
"processData": false,
"data": {
"apiKey":"KEY",
"unique_id": "",
"limit": 123
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
GET Add Contacts
- API:
- /v3/contact/api/add
Add contacts in a contact group
{ "apiKey":"api token here", "msisdn": "2547xxxxxxxx", "contact_groupId": 1234, "unique_id": 123456, "custom_field1": "", "custom_field2": "", "custom_field3": "", "custom_field4": "", "custom_field5": "", "custom_tag": "" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
msisdn | Contacts to add to the contact group | string | YES |
contact_groupId | Refers to the contact group id from Contact group API doc | integer | YES |
unique_id | The contact unique ID | integer | YES |
custom_field1 | Custom field also refer to full_name | string | |
custom_field2 | Custom field also refer to full_name | string | |
custom_field3 | Custom field also refer to full_name | string | |
custom_field4 | Custom field also refer to full_name | string | |
custom_field5 | Custom field also refer to full_name | string | |
custom_tag | Custom tags for your contact | string |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/contact/api/add",
"method": "POST",
"processData": false,
"data": {
"apiKey":"api token here",
"msisdn": "2547xxxxxxxx",
"contact_groupId": 1234,
"unique_id": 123456,
"custom_field1": "",
"custom_field2": "",
"custom_field3": "",
"custom_field4": "",
"custom_field5": "",
"custom_tag": ""
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
POST Edit Contacts
- API:
- /v3/contact/api/edit
Edit contacts in a contact group
{ "apiKey":"api token here", "msisdn": "2547xxxxxxxx", "contact_groupId": 1234, "contact_id": 1234, "unique_id": 123456, "custom_field1": "", "custom_field2": "", "custom_field3": "", "custom_field4": "", "custom_field5": "", "custom_tag": "" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
msisdn | Contacts to add to the contact group | string | YES |
contact_id | Contact Id of the contact wish to update | integer | YES |
unique_id | The contact unique ID | integer | YES |
contact_groupId | Refers to the contact group id from Contact group API doc | integer | YES |
custom_field1 | Custom field also refer to full_name | string | |
custom_field2 | Custom field also refer to full_name | string | |
custom_field3 | Custom field also refer to full_name | string | |
custom_field4 | Custom field also refer to full_name | string | |
custom_field5 | Custom field also refer to full_name | string | |
custom_tag | Custom tags for your contact | string |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/contact/api/add",
"method": "POST",
"processData": false,
"data": {
"apiKey":"api token here",
"msisdn": "2547xxxxxxxx",
"contact_groupId": 1234,
"unique_id": 123456,
"custom_field1": "",
"custom_field2": "",
"custom_field3": "",
"custom_field4": "",
"custom_field5": "",
"custom_tag": ""
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
Payments
POST Initiate MPESA SDK Push
- API:
- /v3/checkout/mpesa
Initiate the MPESA SDK Push to process payments quickly and conveniently.
To be able use SDK Push API you first need to aggregate your MPESA Paybill or Till number to VasPro portal. To Aggregate your paybill/till, login on the VasPro Portal, go to the Payments tab, then click on Aggregate Paybill button
{ "apiKey":"api token here", "amount":"100", "phoneNumber": "07xxxxxxxx", "callbackURL": "url here", "paybillNumber": "789789", "transactionDesc": "Payment for xyz" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
amount | The Amount should be in numeric form | integer | YES |
phoneNumber | Contact to send out the MPESA push prompt | string | YES |
callbackURL | The Rest JSON Callback to receive delivery reports | string | |
paybillNumber | Paybill number to initiate the MPESA SDK push | string | YES |
transactionDesc | Description of the transaction | string |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/checkout/mpesa",
"method": "POST",
"processData": false,
"headers": {
"cache-control": "no-cache",
},
"data": {
"apiKey":"KEY",
"amount":"AMOUNT",
"callBackURL":"",
"phoneNumber":"PHONE NUMBER",
"paybillNumber":"PAYBILL/TILL",
"transactionDesc":""
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
USSD
Receive USSD Requests
This API enables you to receive all USSD requests for your application to your callback URL. You only need to give us your callback
API Parameter | Description | Type |
---|---|---|
msisdn | The mobile number | string |
tokenKey | The token key can be sent on request | string |
sessionID | The MNO Session ID | string |
expiryPeriod | The time taken for the USSD to expire Usually expires in < 180 Seconds |
string |
input | The message received from user dialing | string |
accessPoint | Access Point or Ussd Code Format e.g. *664*1114# |
Requirements
- User to provide url to receive request and also respond appropriately as illustrated above.
- USSD Code for interaction is required.
- User application has to respond before the Expiry Period is over
- All menu responses should below under 1 second(s) to avoid timeouts and cater for network latency.
Expected Response From Client:
Success HTTP Status Code: 200
The Response expected should be in a string format. As below:
- Continuing with the session:
CON Select a option to proceed
Continue
Exit - Ending the USSD Sessions
To end the session the invoker has to start with the word end and accompanying text to be displayed
Example:
END Thank You for interacting with the menu
{
"tokenKey":"api token here",
"msisdn": 0712345678,
"sessionID": "xxxx",
"expiryPeriod": "20190101",
"input": "2",
"accessPoint": "*664*1114#"
}
Rewards
POST View Rewards
- API:
- /v3/rewards/view/transaction
Utilities API allows you purchase airtime, bundles, prepaid tokens, pay postpaid electricity and view all transaction. To be able to use Utilities API, you will first need to enable all permission for Rewards Management.
{ "apiKey":"api token here", "enqueue": 1, "unique_id": "" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
enqueue | It is required and should always be set to 1 | integer | YES |
unique_id | Unique Id for each request you make | string | YES |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/rewards/view/transaction",
"method": "POST",
"processData": false,
"headers": {
"cache-control": "no-cache",
},
"data": {
"apiKey":"api token here",
"enqueue": 1,
"unique_id": ""
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
POST Bulk Rewards Disbursement
- API:
- /v3/rewards/bulk
Pay utilities in bulk mode
{ "apiKey":"api token here", "enqueue": 1, "unique_id": "", "utilityID": 4, "payload": [ { "phone": 2547xxxxxxxx, "account": "meter number, account id, etc", "uniqueId": "xxx", "amount": 123 }, {...} ] , }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier Token | string | YES |
enqueue | It is required and should always be set to 1 | integer | YES |
unique_id | Unique Id for each request you make | string | YES |
utilityID | Utility ID 4 is for Airtime, 5 Mobile Data Bundles (Available on request) 6 KPLC Pre-paid Tokens |
string | YES |
payLoad | It is an array object that consist of id, phone, account, and amount | array of objects | YES |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/rewards/bulk",
"method": "POST",
"processData": false,
"data": {
"apiKey":"api token here",
"enqueue": 1,
"unique_id": "",
"utilityID": 4,
"payload": [
{
"phone": 2547xxxxxxxx,
"account": "meter number, account id, etc",
"uniqueId": "xxx",
"amount": 123
},
]
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
POST Send Airtime
- API:
- /v3/rewards/airtime
This is a dedicated API to send airtime to your clients
{ "apiKey": "xxx", "unique_id": "BAI240604", "amount": "20", "msisdn": "254704050143", "callback": "http://localhost", "dialCode": "" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier token | string | YES |
unique_id | The unique identifier for the request | string | YES |
amount | The value to disburse to the customer | integer | YES |
msisdn | The receiver of the reward | string | YES |
callback | This is where you would like to receive the delivery or response of of the query | string | |
dialCode | This is the country code eg. 254 (Kenya) | string |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/rewards/airtime",
"method": "POST",
"processData": false,
"headers": {
"cache-control": "no-cache",
},
"data": {
"apiKey": "xxx",
"unique_id": "BAI240604",
"amount": "20",
"msisdn": "254704050143",
"callback": "http://localhost",
"dialCode": ""
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
POST Send Electricity Token (KPLC Pre/Postpaid)
- API:
- /v3/rewards/electricity
This is a dedicated API to send electricity tokens or pay for KPLC meter
{ "apiKey": "xxx", "unique_id": "Vaspro_test29803314", "amount": "5", "msisdn": "2547xxxxxxx", "account_type": "1", "bill_reference": "Meter number", "callback": "client's callback url to get results after processing" }
API Parameter | Description | Type | Required |
---|---|---|---|
apiKey | The user identifier token | string | YES |
unique_id | The unique identifier for the request | string | YES |
amount | The value to disburse to the customer | integer | YES |
msisdn | The phone number of the client to receive confirmation message | string | YES |
account_type | Refers to the type of electricity account to use: 1 - Prepaid |
integer | YES |
bill_reference | The meter number of the account | string | YES |
callback | The client's callback url to get results after processing | string |
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.vaspro.co.ke/v3/rewards/electricity",
"method": "POST",
"processData": false,
"headers": {
"cache-control": "no-cache",
},
"data": {
"apiKey": "xxx",
"unique_id": "Vaspro_test29803314",
"amount": "5",
"msisdn": "2547xxxxxxx",
"account_type": "1",
"bill_reference": "Meter number",
"callback": "client's callback url to get results after processing"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});