CallFire Solutions

Add contact to list

Follow

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

ParameterDemo ValueDescriptionData Type
AddContactsToList   Add attached numbers to contact list object
ContactListId Unique ID of ContactList long
Validate Turn off list validation (default: true) boolean
ContactSource   List of contacts, numbers, contactIds, or csv file. object
Contact *   Info about the people you want to contact. Any info needed can be stored under Contact as an extra attribute. object
lastName Last name string
externalId id of contact defined by external system (NATION_BUILDER, GOOGLE_GROUPS, etc...) string
mobilePhone E.164 11 digit number PhoneNumber
firstName First name string
externalSystem System where externalId was generated from (NATION_BUILDER, GOOGLE_GROUPS, etc...) string
homePhone E.164 11 digit number PhoneNumber
workPhone E.164 11 digit number PhoneNumber
zipcode 5 digit zipcode string
Id Unique ID of Contact long
ContactId * List of existing contact ids List[long]
File * Csv file attachment containing list of contacts or numbers base64Binary
Numbers *   List of E.164 11 digit numbers space or comma seperated and optional fieldName object
fieldName field number should be assigned to homePhone, workPhone or mobilePhone (default: homePhone) string

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: &quot;ABC1234&quot;</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>

Have more questions? Submit a request

Comments

  • Avatar
    Maria Ruiz

    How to start my contact list