Manage Tenplate
List Templates
To get a list of Templates for a client on the system use the url
https://api.onfonmedia.co.ke/v1/sms/Template?ApiKey={ApiKey}&ClientId={ClientId}
HTTP request parameters :
Parameter Name | Description | Type |
---|---|---|
ApiKey | Used for authentication purpose and pass this parameter in URL encoded format. | String |
ClientId | Used for authentication purpose and pass this parameter in URL encoded format. | String |
Headers
Parameter Name |
---|
Content-Type: application/json |
AccessKey: xxxxxxxxxxxxxxxx |
HTTP Response
Successful response:
{
"ErrorCode": 0,
"ErrorDescription": "Success",
"Data": [
{
"TemplateId": 138,
"CompanyId": 121,
"TemplateName": "test",
"MessageTemplate": "test ##Field##",
"IsApproved": false,
"IsActive": true,
"CreatededDate": "Mar 19, 2018",
"ApprovedDate": "Mar 19, 2018",
}
]
}
Python List Template
Here is an example of how to fetch templates from the system:
import requests
import urllib
url = "https://api.onfonmedia.co.ke/v1/sms/Template"
querystring = {"ApiKey":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx","ClientId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"}
headers = {
'AccessKey': "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
'Content-Type': "application/json",
}
response = requests.request("GET", url, headers=headers, params=urllib.urlencode(querystring))
print(response.text)
Create New Template
Add a new Template for a particular client POST DATA to the url
https://api.onfonmedia.co.ke/v1/sms/Template
HTTP json parameters :
Parameter Name | Description | Type |
---|---|---|
ApiKey | Used for authentication purpose and pass this parameter in URL encoded format. | String |
ClientId | Used for authentication purpose and pass this parameter in URL encoded format. | String |
TemplateName | Name of template. | String |
MessageTemplate | Template text. | String |
Headers
Parameter Name |
---|
Content-Type: application/json |
AccessKey: xxxxxxxx-xxxx-xxxx-xxxx |
Sample JSON request :
{
"TemplateName": "string",
"MessageTemplate": "string",
"ApiKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
Sample JSON response :
{
"ErrorCode":0,
"ErrorDescription":"Success",
"Data":"Template Added successfully."
}
Python Create Template
Here is an example of how to create a new template on the system:
import requests
import urllib
url = "https://api.onfonmedia.co.ke/v1/sms/Template"
headers = {
'AccessKey': "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
'Content-Type': "application/json",
}
data = {
"TemplateName": "Test Template",
"MessageTemplate": "Template message with no placeholder",
"ApiKey": "vxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
response = requests.request("POST", url, headers=headers,json=data)
print(response.text)
Update Template Details
Update Tempalte details given the template id
https://api.onfonmedia.co.ke/v1/sms/:6005/Template?id={Id}
HTTP json parameters :
Parameter Name | Description | Type |
---|---|---|
ApiKey | Used for authentication purpose and pass this parameter in URL encoded format. | String |
ClientId | Used for authentication purpose and pass this parameter in URL encoded format. | String |
TemplateName | Name of template. | String |
MessageTemplate | Template text. | String |
id | Template id. | integer |
Headers
Parameter Name |
---|
Content-Type: application/json |
AccessKey: xxxxxxxx-xxxx-xxxx-xxxx |
Sample JSON request :
{
"TemplateName": "string",
"MessageTemplate": "string",
"ApiKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
HTTP Response
Successful response:
{
"ErrorCode": 0,
"ErrorDescription": "Success",
"Data": "Template updated Successfully."
}
Python Update Template
Here is an example of how to update an existing template on the system:
import requests
url = "https://api.onfonmedia.co.ke/v1/sms/Template"
querystring = {"id":18}
headers = {
'AccessKey': "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
'Content-Type': "application/json",
}
data = {
"TemplateName": "Updated Template",
"MessageTemplate": "Updated Template Message",
"ApiKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
response = requests.request("PUT", url, headers=headers,json=data, params=querystring)
print(response.text)
Delete Template
Add a new Group for a particular client POST DATA to the url
https://api.onfonmedia.co.ke/v1/sms/:6005/Template?ApiKey={ApiKey}&ClientId={ClientId}&id=215
HTTP json parameters :
Parameter Name | Description | Type |
---|---|---|
ApiKey | Used for authentication purpose and pass this parameter in URL encoded format. | String |
ClientId | Used for authentication purpose and pass this parameter in URL encoded format. | String |
id | Template ID to delete | integer |
Headers
Parameter Name |
---|
Content-Type: application/json |
AccessKey: xxxxxxxxxxxxxxxx |
HTTP Response
Successful response:
{
"ErrorCode": 0,
"ErrorDescription": "Success",
"Data": "Template deleted successfully."
}
Python Delete Template
Here is an example of how to delete an existing template from the system:
import requests
import urllib
url = "https://api.onfonmedia.co.ke/v1/sms/Template"
querystring = {
"ApiKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
"id": 18
}
headers = {
'AccessKey': "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
'Content-Type': "application/json",
}
response = requests.request("DELETE", url, headers=headers, params=urllib.urlencode(querystring))
print(response.text)