ADD CONTACTS TO LIST
Adds contacts to an existing list
See CreateContactList. This operation currently only supports adding ContactSource numbers, not contact lists, contactId lists, or CSV files.
REQUEST PARAMETERS
Parameter | Data Type | Demo Value | Description |
---|---|---|---|
AddContactsToList | object | Add attached numbers to contact list | |
ContactListId | long | 123 | Unique ID of ContactList |
Validate | boolean | false | Turn off list validation (default: true) |
ContactSource | object | List of contacts, numbers, contactIds, or csv file. | |
Contact * | object | Info about the people you want to contact. Any info needed can be stored under Contact as an extra attribute. | |
lastName | string | Doe | Last name |
externalId | string | nb-1010 | id of contact defined by external system (NATION_BUILDER, GOOGLE_GROUPS, etc...) |
mobilePhone | PhoneNumber | 18185551414 | E.164 11 digit number |
firstName | string | John | First name |
externalSystem | string | NATION_BUILDER | System where externalId was generated from (NATION_BUILDER, GOOGLE_GROUPS, etc...) |
homePhone | PhoneNumber | 18185551212 | E.164 11 digit number |
workPhone | PhoneNumber | 8185551313 | E.164 11 digit number |
zipcode | string | 98154 | 5 digit zipcode |
Id | long | 123 | Unique ID of Contact |
ContactId * | List[long] | List of existing contact ids | |
File * | base64Binary | Csv file attachment containing list of contacts or numbers | |
Numbers * | object | List of E.164 11 digit numbers space or comma seperated and optional fieldName | |
fieldName | string | field number should be assigned to homePhone, workPhone or mobilePhone (default: homePhone) |
EXAMPLE: Add a new contact to a list
using RestSharp;
namespace [your-namespace]
{
public class [your-class]
{
public string AddContactToList()
{
long contactListId = 1428507003; // Your ContactList Id here
var client = new RestClient("https://www.callfire.com/api/1.1/rest/");
client.Authenticator = new HttpBasicAuthenticator("YourLoginId", "password");
var request = new RestRequest(string.Format("contact/list/{0}/add", contactListId), Method.POST);
request.AddParameter("ContactListId", "188601001");
request.AddParameter("Contact[0][firstName]", "John");
request.AddParameter("Contact[0][lastName]", "Doe");
request.AddParameter("Contact[0][zipcode]", "12345");
request.AddParameter("Contact[0][homePhone]", "12345678909");
request.AddParameter("Contact[0][workPhone]", "12345678908");
request.AddParameter("Contact[0][mobilePhone]", "12345678907");
request.AddParameter("Contact[0][externalId]", "ABC123");
request.AddParameter("Contact[0][externalSystem]", "ExternalSystem");
var response = client.Execute(request);
string content = response.Content;
return content;
}
}
}
This will create a new contact and add it to the list identified by "188601001"
Response Parameters
Contact was successfully added
Response Code: 204
If the contact was successfully created and added to the list, you will receive response code 204. No XML will be included in the body.
The list doesn't exist
Response Code: 404
If you are trying to create a contact and add it to a nonexistent list, you will receive response code 404 and the following XML in the response:
<r:ResourceException xmlns="http://api.callfire.com/data" xmlns:r="http://api.callfire.com/resource"> <r:HttpStatus>404</r:HttpStatus> <r:Message>contact list does not exist</r:Message> </r:ResourceException>
Invalid data type sent as parameter
If you send an invalid data type, you will receive 400 as response code and the following XML in the body:
<r:ResourceException xmlns="http://api.callfire.com/data" xmlns:r="http://api.callfire.com/resource"> <r:HttpStatus>400</r:HttpStatus> <r:Message>Cannot parse number: For input string: "ABC1234"</r:Message> </r:ResourceException>
In this case we sent a string as ContactListId which is supposed to be an integer.
EXAMPLE: Add one or more existing contacts to the list
using RestSharp;
namespace [your-namespace]
{
public class [your-class]
{
public string AddContactToList()
{
long contactListId = 188601001; // Your ContactList Id here
var client = new RestClient("https://www.callfire.com/api/1.1/rest/");
client.Authenticator = new HttpBasicAuthenticator("YourLoginId", "password");
var request = new RestRequest(string.Format("contact/list/{0}/add", contactListId), Method.POST);
request.AddParameter("ContactId", "264793000003,264758485003");
var response = client.Execute(request);
string content = response.Content;
return content;
}
}
}
This will add existing contacts identified by 264793000003 and 264758485003 to the list identified by "188601001". Please note that the contactId list should be comma separated.
Response Parameters
Contact was successfully added
Response Code: 204
If the contacts were successfully added to the list, you will receive response code 204. No XML will be included in the body. You can confirm by using QueryContacts and sending the corresponding ContactListId.
Response Parameters
Trying to add a nonexistent contact
Response Code: 400
If one of the contacts doesn't exist, none will be added. You will receive response code 404 and the following XML will be sent:
<r:ResourceException xmlns="http://api.callfire.com/data" xmlns:r="http://api.callfire.com/resource">
<r:HttpStatus>400</r:HttpStatus>
<r:Message> the next contact's id not found: [12345678909]</r:Message>
</r:ResourceException>