Add Contacts to a Group using JSON/XML Data

First, you need to create a group in your account only then you can add multiple contacts to an existing valid group. APIs for adding contacts to a group using JSON/XML data have been specified below:

curl -X POST \
'<BASE_URL>&api_key=xxxxxxxxxxxxxxxx&method=groups.json&name=MyNum&action=add&json=%7B%22sms%22%3A%20%5B%7B%20%22to%22%3A%20%229xxxxxxxx......%7D%5D%20%7D'
curl -X POST \
'<BASE_URL>&api_key=xxxxxxxxxxxxxxxx&method=groups.xml&name=MyNum&action=add&xml=%7B%22sms%22%3A%20%5B%7B%20%22to%22%3A%20%229xxxxxxxx......%7D%5D%20%7D'

API Parameter Specifications

The API parameter specifications are described in the following sections:

Mandatory Parameters

The mandatory parameters in the HTTP API are tabulated below:

Parameter Description Expected Values
BASE_URL URL of your SMS Service service URL
method Predefined method groups.json or groups.xml
name group name case insensitive
xml/json You can provide either URL encoded XML/JSON data or URL of the XML/JSON file Valid XML/JSON data

Optional Parameters

The optional parameters in the HTTP API are tabulated below:

Parameter Description Expected Values
format Output format should be as specified by this variable XML/PHP/JSON/JSONP. Default response will be in JSON
action Flag to specify the action add/delete. . Add action is Default
Note: If you want to use 'Delete' functionality for deleting any contact, then simply use 'delete' value within 'action' parameter.

JSON/XML Tags

Parameter Description
number mobile number of the contact to be added
fullname full name of the contact
email email address of the contact

Sample JSON Data

  {
    "contacts": 
    [{ 
        "number": "9xxxxxxxx", 
        "fullname": "xyz", 
        "email": "xyz@email.com"  
      }, 
      {
        "number":"91xxxxxxxx",   
        "fullname":"xyz1",
        "email":"xyz1@email.com"  
      }] 
  }

Sample XML Data

<?xml version="1.0" encoding="UTF-8"?>
<xmlapi>
  <contacts>
    <contact>
      <number>95xxxxxxxx</number>
      <fullname>xyz</fullname>
      <email>x@email.com</email>
    </contact>

    <contact>
      <number>99xxxxxxxx</number>
      <fullname>xyz1</fullname>
      <email>y@email.com</email>
    </contact>
  </contacts>
</xmlapi>

Example Responses

JSON

{
    "status": "OK",
    "code": 200,
    "message": "Number updated Successfully"
}

Error Response:

 {
      "status": "ERROR",
      "code": "A424",
      "message": "Group Name does not exist!"
}

API Error Codes

Status Message
A420 Group name/id missing
A421 Group is empty/Invalid group
A422 Invalid mobile number
A423 Group name/number missing
A424 Group Name does not exist!
A425 Number does not Exist

Response Data

status It indicates the success or failure of your request.
Code Error code
message It indicates the success or failure message.