InsertSubscriber
Insertion of a subscriber.
URL | https://api.enginemailer.com/restapi/subscriber/emsubscriber/insertSubscriber |
Method | HTTP POST |
Note: The user can only insert with the maximum number of 50/day with the free account and 10,000/day with the paid account.
Table: Parameter
Parameter name | Description | Column Type |
---|---|---|
SubscriberData | A list of subscriber data. | JSON String |
Table: Data Definition for JSON
Parameter name | Description | Column Type | Maximum Length | Required? |
---|---|---|---|---|
Subscriber Email | String |
128 | Yes | |
SubCategories | List of sub categories id of the subscriber. It is pre-defined in the portal and it can be retrieved by invoking getSubCategory method. | JArray (Int) |
No | |
CustomFields | The custom field value of the subscriber. All the custom field value must be in correct format based on their field type. | Jarray (JObject) |
No | |
SourceType | User defined label to indicate the source of subscriber (e.g Website Sign Up). | String |
256 | No |
Table: Custom Fields Data Type
Data Type | Expected Value Format | Maximum Length |
---|---|---|
Date (Not Date Range) |
dd MMM yyyy eg. 01 Jan 2017 |
|
Date (Date Range) |
dd MMM yyyy – dd MMM yyyy eg. 01 Jan 2017 – 02 Jan 2017 |
|
Phone |
Contact Number come with the plus sign with the country code. eg. +60146666666 |
|
Numeric |
Integer value. |
|
Longtext |
<String> |
512 |
Address |
<String> |
512 |
Dropdown |
<String> |
64 |
Checkbox |
Checkbox can have multiple value, the value is separated by | eg. <String>|<String>|<String> |
64 |
Request Example
Header
<APIKEY> - Value
Body
{
"email":"example@enginemailer.com",
"subcategories":[
1,
2
],
"customfields":[
{
"customfield_key":"branch",
"customfield_value":"KL"
},
{
"customfield_key":"mobile",
"customfield_value":"+60123456789"
},
{
"customfield_key":"hobbies",
"customfield_value":"Eating|Sleeping"
}
],
"sourcetype": "Signup from website"
}
Response
Success Response
{
"Result":{
"Status":"OK",
"StatusCode":"200"
}
}
Failed Response
{
"Result":{
"StatusCode":"500",
"Status":"InternalServerError",
"ErrorMessage":"Authentication Failed!"
}
}
Code Example (.NET)
JArray subcategory = new JArray();
subcategory.Add(1);
subcategory.Add(2);
JObject jObject = new JObject();
JArray customfield = new JArray();
JObject customfield1 = new JObject();
JObject customfield2 = new JObject();
customfield1.Add("customfield_key", "branch");
customfield1.Add("customfield_value", "Sydney");
customfield.Add(customfield1);
customfield2.Add("customfield_key", "mobile");
customfield2.Add("customfield_value", "+60123456789");
customfield.Add(customfield2);
customfield3.Add("customfield_key", "hobbies");
customfield3.Add("customfield_value", "Eating|Sleeping");
customfield.Add(customfield3);
jObject.Add("email", "example@weblite.com.my");
jObject.Add("subcategories", subcategory);
jObject.Add("customfields", customfield);
jObject.Add("sourcetype", "Signup from website");
var client = new RestClient("http://api.enginemailer.com/RESTAPI/subscriber/emsubscriber/insertSubscriber");
var request = new RestRequest(Method.POST);
request.AddHeader("APIKey", "<>");
request.AddParameter("email", jObject.ToString(), ParameterType.RequestBody);
var response = client.Execute(request).Content;
var response2 = JObject.Parse(response);