Manage Group

List Groups

To get a list of Groups for a client on the system use the url

https://api.onfonmedia.co.ke/v1/sms/Group?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": [
        {
            "GroupId": 33,
            "GroupName": "JGJ",
            "ContactCount": 21
        },
        {
            "GroupId": 50,
            "GroupName": "6Y5",
            "ContactCount": 0
        }        
    ]
}

Python List Group

Here is an example of how to fetch groups from the system:

import requests
import urllib

url = "https://api.onfonmedia.co.ke/v1/sms/Group"
querystring = {"ApiKey":"xxxxxxxxxxxxxxxxx","ClientId":"xxxxxxxxxxxxxxxxxxxx"}

headers = {
    'AccessKey': "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    'Content-Type': "application/json",
    }
response = requests.request("GET", url, headers=headers, params=urllib.urlencode(querystring))
print(response.text)

Create New Group

Add a new Group for a particular client POST DATA to the url

https://api.onfonmedia.co.ke/v1/sms/Group

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
GroupName Name of the new group to be created. String

Headers

Parameter Name
Content-Type: application/json
AccessKey: xxxxxxxx-xxxx-xxxx-xxxx

Sample JSON request :

{
  "GroupName": "551",
  "ApiKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
  "ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}

Sample JSON response :

{
   "ErrorCode":0,
   "ErrorDescription":"Success",
   "Data":"success#New Group added successfully."
}

Python Create Group

Here is an example of how to create a new group on the system:

import requests
import urllib

url = "https://api.onfonmedia.co.ke/v1/sms/Group"

headers = {
    'AccessKey': "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
    'Content-Type': "application/json",
    }
data = { "GroupName": "Area 51",
  "ApiKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
  "ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}
response = requests.request("POST", url, headers=headers,json=data)
print(response.text)

Update Group Name

Add a new Group for a particular client POST DATA to the url

https://api.onfonmedia.co.ke/v1/sms/:6005/Group?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
GroupName New name for the group to be created. String

Headers

Parameter Name
Content-Type: application/json
AccessKey: xxxxxxxx-xxxx-xxxx-xxxx

HTTP Response

Successful response:

{
  "ErrorCode": 0,
  "ErrorDescription": "Success",
  "Data": "Group updated Successfully."
}

Python Update Group

Here is an example of how to update an existing group on the system:

import requests

url = "https://api.onfonmedia.co.ke/v1/sms/Group"
querystring = {"id":18}
headers = {
    'AccessKey': "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
    'Content-Type': "application/json",
    }
data = { 
  "GroupName": "Roswell",
  "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 Group

Add a new Group for a particular client POST DATA to the url

https://api.onfonmedia.co.ke/v1/sms/:6005/Group?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 Group ID to delete integer

Headers

Parameter Name
Content-Type: application/json
AccessKey: xxxxxxxxxxxxxxxx

HTTP Response

Successful response:

{
  "ErrorCode": 0,
  "ErrorDescription": "Success",
  "Data": "Group deleted successfully."
}

Python Delete Group

Here is an example of how to delete an existing group from the system:

import requests
import urllib

url = "https://api.onfonmedia.co.ke/v1/sms/Group"
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)