Contacts Guide
Overview
The CallFire platform provides the ability to manage Contacts, Contact Lists, and Do Not Contact records via the Developers' UI and the API.
Each contact has a default set of fields attached to it:
- firstName
- lastName
- homePhone
- mobilePhone
- workPhone
- zipcode
To create a contact, you must specify at least one of supported phone types, other fields are optional. CallFire supports user-defined fields as well, so you may also attach custom data to a contact.
Note that all user-defined fields are shared between all contacts in the account. Imagine that all your contacts are stored in a big table where rows represent a contact record and columns represent all possible contact fields, starting from the defaults and followed by custom fields. In this case, if you add a new contact with a custom field which didn't exist before, the value of that field will be added to all contacts with a NULL value. See the example below:
firstName,lastName,homePhone,workPhone,A,B,C, ..., AZ
Alice,Moore,12345678901,12345678900,30,,team1
Bob,Schmidt,12345678999,12345678888,40,Manager,team1
Jason,Po,12225678999,12345671100,25,,
Eric,Satie,12345678999,12345678888,20,Sales,team2
Do Not Contact (DNC) - an object that represents a recipient (phone number) that opted out of receiving calls or text messages.
Refer to the various API operations for manipulating Contacts, Contact Lists, and DNCs:
- Create / Find / Update / Get / Delete a Contact
- Create / Find / Update / Get / Delete a Contact List
- Add / Get / Remove Contact List Items
- Find / Update a Do Not Contact object
The Developers' UI supports importing contacts from several external systems:
- SalesForce
- NationBuilder
- Zoho
- NETSUITE
- MailChimp
Important note Standalone contacts will be validated when added to a broadcast campaign. If you create a new contact list or add contacts to an existing list, it should go through the validation process.
List Validation Settings allows you to choose what to do with invalid or duplicate phone numbers. Go to Settings -> List validation page to change validation settings.
After adding new contacts into the CallFire system, the contact lists gpass through seven system safeguards that check the accuracy and consistency of the data. For example, our system checks if a number is formatted correctly, is invalid, is duplicated in another contact list, or is on a specific DNC list. The default resolution of these safeguards will be to remove contacts that violate these rules. If contacts are not being added to a list, this means the data needs to be properly formatted and correct before calling this API.
You can find detailed JSON models or try the API directly from a browser at API v2 Swagger page
How to Create new Contacts
You can create standalone contacts by passing a list of contact objects as a request body to the Create Contacts API method. You can provide a set of user-defined fields and attach them to a contact.
[[code-container]] [+curl] request:
#!/usr/bin/env bash
curl -u username:password -H "Content-Type:application/json" -X POST -d '
[
{
"firstName":"Alice",
"lastName":"Moore",
"homePhone":"12135551124",
"mobilePhone":"12136666123",
"workPhone":"14553327789",
"zipcode":"40460",
"properties":
{
"custom_ext_system_id":100200301
}
},
{
"firstName":"Bob",
"lastName":"Smith",
"homePhone":"12135551127",
"properties":
{
"custom_age":30,
"custom_position":"Manager"
}
}
]' "https://api.callfire.com/v2/contacts"
response:
{
"items": [
{
"id": 4103
},
{
"id": 4104
}
]
}
[-curl]
[+java]
import com.callfire.api.client.CallfireClient;
import com.callfire.api.client.api.common.model.ResourceId;
import com.callfire.api.client.api.contacts.model.Contact;
import java.util.Arrays;
import java.util.List;
class ApiClientSample {
public static void main(String[] args) {
CallfireClient client = new CallfireClient("api login", "api password");
Contact contact1 = new Contact();
contact1.setFirstName("Alice");
contact1.setLastName("Moore");
contact1.setHomePhone("12135551126");
contact1.setMobilePhone("12136666123");
contact1.setWorkPhone("14553327789");
contact1.setZipcode("40460");
contact1.getProperties().put("custom_ext_system_id", "100200301");
Contact contact2 = new Contact();
contact2.setFirstName("Bob");
contact2.setLastName("Smith");
contact2.setHomePhone("12135551127");
contact2.getProperties().put("age", "30");
contact2.getProperties().put("custom_position", "Manager");
List<Contact> inputContacts = Arrays.asList(contact1, contact2);
List<ResourceId> resultResourceIds = client.contactsApi().create(inputContacts);
}
}
[-java]
[+csharp]
using System.Collections.Generic;
using CallfireApiClient;
using CallfireApiClient.Api.Common.Model;
using CallfireApiClient.Api.Contacts.Model;
public class ApiClientSample
{
public static void Main(string[] args)
{
var client = new CallfireClient("api_login", "api_password");
var contact1 = new Contact
{
FirstName = "Alice",
LastName = "Moore",
HomePhone = "12135551126",
MobilePhone = "12136666123",
WorkPhone = "14553327789",
Zipcode = "40460",
Properties = new Dictionary<string, string>
{
{"custom_ext_system_id", "100200301"}
}
};
var contact2 = new Contact
{
FirstName = "Bob",
LastName = "Smith",
HomePhone = "12135551127",
Properties = new Dictionary<string, string>
{
{"age", "30"},
{"custom_position", "Manager"}
}
};
IList<ResourceId> contacts = client.ContactsApi.Create(new List<Contact> { contact1, contact2 });
}
}
[-csharp]
[+js]
'strict'
const CallfireClient = require('callfire-api-client-js');
const client = new CallfireClient('api-login', 'api-password');
client.ready(() => {
client.contacts.createContacts({
body: [
{
firstName: 'Alice',
lastName: 'Moore',
homePhone: '12135551126',
mobilePhone: '12136666123',
workPhone: '14553327789',
zipcode: '40460',
properties: {
custom_ext_system_id: 100200301
}
},
{
firstName: 'Bob',
lastName: 'Smith',
homePhone: '12135551127',
properties: {
custom_age: 30,
custom_position: 'Manager'
}
}
]
})
.then((response) => {
console.log(response.obj);
})
.catch((err) => {
console.log('request error ' + err.data);
});
},
(clientError) => {
console.log('client error ' + clientError);
}
);
[-js]
[+python]
from callfire.client import CallfireClient
client = CallfireClient('api-login', 'api-password')
response = client.contacts.createContacts(
body=[
{
'firstName': 'Alice',
'lastName': 'Moore',
'homePhone': '12135551126',
'mobilePhone': '12136666123',
'workPhone': '14553327789',
'zipcode': '40460',
'properties': {
'custom_ext_system_id': 100200301
}
},
{
'firstName': 'Bob',
'lastName': 'Smith',
'homePhone': '12135551127',
'properties': {
'custom_age': 30,
'custom_position': 'Manager'
}
}
]
).result()
# see sample JSON response for this API
# on 'curl' samples tab
print(response)
[-python]
[+php]
<?php
class ApiClientSample {
public static function main() {
$client = \CallFire\Api\DocumentedClient::createClient("login", "password");
$request = $client->createContacts();
$body = '[
{
"firstName":"Alice",
"lastName":"Moore",
"homePhone":"12135551124",
"mobilePhone":"12136666123",
"workPhone":"14553327789",
"zipcode":"40460",
"properties":
{
"custom_ext_system_id":100200301
}
},
{
"firstName":"Bob",
"lastName":"Smith",
"homePhone":"12135551127",
"properties":
{
"custom_age":30,
"custom_position":"Manager"
}
}
]';
$request->getOperationConfig()->setBodyParameter($body);
$result = $client->request($request);
$json = json_decode($result->getBody());
}
}
[-php]
[[/code-container]]
To find newly-created contacts, use the corresponding API method:
[[code-container]] [+curl] request:
#!/usr/bin/env bash
curl -u username:password -H "Content-Type:application/json" -X GET "https://api.callfire.com/v2/contacts?id=11646003&id=12646003&id=13776003&number=12135551126&number=12136666123&contactListId=14400809003&propertyName=14400809003&propertyValue=14400809003&offset=0&limit=10&fields=items(id,name,size)"
response:
{
"items": [
{
"id":88970899000
"firstName":"Alice",
"lastName":"Moore",
"homePhone":"12135551124",
"mobilePhone":"12136666123",
"workPhone":"14553327789",
"zipcode":"40460",
"properties":
{
"custom_age":30,
"custom_position":"Manager"
}
},
{
"id":88971899000
"firstName":"Bob",
"lastName":"Smith",
"homePhone":"17885551111",
"mobilePhone":"17886666122",
"workPhone":"17883327700",
"zipcode":"25600",
"properties":
{
"custom_ext_system_id":100200301
}
}
],
"limit": 10,
"offset": 0,
"totalCount": 2
}
[-curl]
[+java]
import com.callfire.api.client.CallfireClient;
import com.callfire.api.client.api.common.model.Page;
import com.callfire.api.client.api.contacts.model.Contact;
import com.callfire.api.client.api.contacts.model.request.FindContactsRequest;
import java.util.Arrays;
class ApiClientSample {
public static void main(String[] args) {
CallfireClient client = new CallfireClient("api login", "api password");
FindContactsRequest request = FindContactsRequest.create()
.id(Arrays.asList(11646003L, 12646003L, 13776003L))
.number(Arrays.asList("12135551126", "12136666123"))
.contactListId(14400809003L)
.propertyName("14400809003")
.propertyValue("14400809003")
.offset(0L)
.limit(10L)
.build();
Page<Contact> contacts = client.contactsApi().find(request);
}
}
[-java]
[+csharp]
using System.Collections.Generic;
using CallfireApiClient;
using CallfireApiClient.Api.Common.Model;
using CallfireApiClient.Api.Contacts.Model;
using CallfireApiClient.Api.Contacts.Model.Request;
public class ApiClientSample
{
public static void Main(string[] args)
{
var client = new CallfireClient("api_login", "api_password");
var request = new FindContactsRequest
{
Id = new List<long> { 11646003, 12646003, 13776003 },
Number = new List<string> { "12135551126", "12136666123" },
ContactListId = 14400809003,
PropertyName = "14400809003",
PropertyValue = "14400809003",
Offset = 0,
Limit = 10,
Fields = "items(id,name,size)"
};
Page<Contact> contacts = client.ContactsApi.Find(request);
}
}
[-csharp]
[+js]
'strict'
const CallfireClient = require('callfire-api-client-js');
const client = new CallfireClient('api-login', 'api-password');
client.ready(() => {
client.contacts.findContacts({
// find contacts with particular ids
id: [11646003, 12646003, 13776003],
// find contacts by specified phone numbers
number: ['12135551126', '12136666123'],
// find contacts by contact list
contactListId: 14400809003,
// find contacts by custom property name
propertyName: 14400809003,
// find contacts by custom property value
propertyValue: 14400809003,
// search offset
offset: 0,
// return 10 items per request
limit: 10,
// return only specific fields
fields: 'items(id,name,size)'
})
.then((response) => {
console.log(response.obj);
})
.catch((err) => {
console.log('request error ' + err.data);
});
},
(clientError) => {
console.log('client error ' + clientError);
}
);
[-js]
[+python]
from callfire.client import CallfireClient
client = CallfireClient('api-login', 'api-password')
response = client.contacts.findContacts(
# find contacts with particular ids
id=[11646003, 12646003, 13776003],
# find contacts by specified phone numbers
number=['12135551126', '12136666123'],
# find contacts by contact list
contactListId=14400809003,
# find contacts by custom property name
propertyName=14400809003,
# find contacts by custom property value
propertyValue=14400809003,
# search offset
offset=0,
# return 10 items per request
limit=10,
# return only specific fields
fields='items(id,name,size)'
).result()
# see sample JSON response for this API
# on 'curl' samples tab
print(response)
[-python]
[+php]
<?php
class ApiClientSample {
public static function main() {
$client = \CallFire\Api\DocumentedClient::createClient("login", "password");
$request = $client->findContacts();
$request->getOperationConfig()->setQueryParameters(array("id" => 11646003,
"id" => 12646003,
"id" => 13776003,
"number" => "12135551126",
"number" => "12136666123",
"contactListId" => 14400809003,
"propertyName" => "14400809003",
"propertyValue" => "14400809003",
"offset" => 0,
"limit" => 10,
"fields" => "items(id,name,size)"));
$result = $client->request($request);
$json = json_decode($result->getBody());
}
}
ApiClientSample::main();
[-php]
[[/code-container]]
How to Create a new Contact List
You can create a contact list for use with campaigns using one of three different methods:
- a list of contact objects (the same input method as used in the Create Contacts API);
- a list of number strings in E.164 format or, in case of international numbers, in E.123 format. You also have the ability to specify what type of phone (homePhone, workPhone, mobilePhone) should be chosen.
- a list of CallFire contact ids can be used as the data source for the created contact list.
- upload a CSV file with contacts.
The following API examples illustrate how to create a new contact list from the given sources:
[[code-container]] [+curl] request:
#!/usr/bin/env bash
curl -u username:password -H "Content-Type:application/json" -X POST -d '
{
"name":"My Contact List",
"contacts":
[
{
"firstName": "Alice",
"lastName": "Moore",
"homePhone": "12135551126"
},
{
"firstName": "Bob",
"lastName": "Smith",
"homePhone": "12135551127",
"properties": {
"age": 30
}
}
]
}' "https://api.callfire.com/v2/contacts/lists"
curl -u username:password -H "Content-Type:application/json" -X POST -d '
{
"name":"My Contact List",
"contactIds": [
800634185003,
800734186003,
800834187003,
800984185003
]
}' "https://api.callfire.com/v2/contacts/lists"
curl -u username:password -H "Content-Type:application/json" -X POST -d '
{
"name":"My Contact List",
"contactNumbers": [
"12132212384",
"12136612355",
"12133312300"
],
contactNumbersField: "workPhone"
}' "https://api.callfire.com/v2/contacts/lists"
response:
{
"id": 3
}
[-curl]
[+java]
import com.callfire.api.client.CallfireClient;
import com.callfire.api.client.api.common.model.ResourceId;
import com.callfire.api.client.api.contacts.model.Contact;
import com.callfire.api.client.api.contacts.model.request.CreateContactListRequest;
import java.util.Arrays;
class ApiClientSample {
public static void main(String[] args) {
CallfireClient client = new CallfireClient("api login", "api password");
CreateContactListRequest request1 = CreateContactListRequest.<String>create()
.name("My Contact List")
.contacts(Arrays.asList("12132212384", "12136612355", "12133312300"))
.contactNumbersField("workPhone")
.build();
ResourceId resourceId1 = client.contactListsApi().create(request1);
// second example shows how to create contact list from existing contacts, what we need is just their ids:
CreateContactListRequest request2 = CreateContactListRequest.<Long>create()
.name("My Contact List")
.contacts(Arrays.asList(800634185003L, 800734186003L, 800834187003L, 800984185003L))
.build();
ResourceId resourceId2 = client.contactListsApi().create(request2);
// next code sample uses Contact object in CreateContactListRequest request:
Contact contact1 = new Contact();
contact1.setFirstName("Alice");
contact1.setLastName("Moore");
contact1.setHomePhone("12135551126");
Contact contact2 = new Contact();
contact1.setFirstName("Bob");
contact1.setLastName("Smith");
contact1.setHomePhone("12135551127");
contact1.getProperties().put("age", "30");
CreateContactListRequest request3 = CreateContactListRequest.<Contact>create()
.name("My Contact List")
.contacts(Arrays.asList(contact1, contact2))
.build();
ResourceId resourceId3 = client.contactListsApi().create(request3);
}
}
[-java]
[+csharp]
using System.Collections.Generic;
using CallfireApiClient;
using CallfireApiClient.Api.Common.Model;
using CallfireApiClient.Api.Contacts.Model;
using CallfireApiClient.Api.Contacts.Model.Request;
public class ApiClientSample
{
public static void Main(string[] args)
{
var client = new CallfireClient("api_login", "api_password");
var request1 = new CreateContactListRequest<Contact>
{
Contacts = new List<Contact>
{
new Contact
{
FirstName = "Alice",
LastName = "Moore",
HomePhone = "12135551126"
},
new Contact
{
FirstName = "Bob",
LastName = "Smith",
HomePhone = "12135551127",
Properties = new Dictionary<string, string>
{
{"age", "30"}
}
}
},
Name = "My Contact List"
};
ResourceId resourceId1 = client.ContactListsApi.Create(request1);
var request2 = new CreateContactListRequest<string>
{
Contacts = new List<string> {"12132212384", "12136612355", "12133312300"},
ContactNumbersField = "workPhone",
Name = "My Contact List"
};
ResourceId resourceId2 = client.ContactListsApi.Create(request2);
var request3 = new CreateContactListRequest<long>
{
Contacts = new List<long> {800634185003, 800734186003, 800834187003, 800984185003},
Name = "My Contact List"
};
ResourceId resourceId3 = client.ContactListsApi.Create(request3);
}
}
[-csharp]
[+js]
'strict'
const CallfireClient = require('callfire-api-client-js');
const client = new CallfireClient('api-login', 'api-password');
client.ready(() => {
client.contacts.createContactList({
body: {
name: 'My Contact List',
// choose one of available source of contacts: array of contact objects,
// existing contacts (ids) or array of numbers
contacts: [
{
firstName: 'Alice',
lastName: 'Moore',
homePhone: '12135551126'
},
{
firstName: 'Bob',
lastName: 'Smith',
homePhone: '12135551127',
properties: {
age: 30
}
}
],
// add existing contacts to list
// contactIds: [
// 800634185003,
// 800734186003,
// 800834187003,
// 800984185003
// ],
// add phone numbers to list
// contactNumbers: [
// '12132212384',
// '12136612355',
// '12133312300'
// ],
// contactNumbersField: 'workPhone'
}
})
.then((response) => {
console.log(response.obj);
})
.catch((err) => {
console.log('request error ' + err.data);
});
},
(clientError) => {
console.log('client error ' + clientError);
}
);
[-js]
[+python]
from callfire.client import CallfireClient
client = CallfireClient('api-login', 'api-password')
response = client.contacts.createContactList(
body={
'name': 'My Contact List',
# choose one of available source of contacts: array of contact objects,
# existing contacts (ids) or array of numbers
'contacts': [
{
'firstName': 'Alice',
'lastName': 'Moore',
'homePhone': '12135551126'
},
{
'firstName': 'Bob',
'lastName': 'Smith',
'homePhone': '12135551127',
'properties': {
'age': 30
}
}
],
# add existing contacts to list
# contactIds: [
# 800634185003,
# 800734186003,
# 800834187003,
# 800984185003
# ],
# add phone numbers to list
# contactNumbers: [
# '12132212384',
# '12136612355',
# '12133312300'
# ],
# contactNumbersField: 'workPhone'
}
).result()
# see sample JSON response for this API
# on 'curl' samples tab
print(response)
[-python]
[+php]
<?php
class ApiClientSample {
public static function main() {
$client = \CallFire\Api\DocumentedClient::createClient("login", "password");
$request1 = $client->createContactList();
$body = '{
"name":"My Contact List",
"contacts":
[
{
"firstName": "Alice",
"lastName": "Moore",
"homePhone": "12135551126"
},
{
"firstName": "Bob",
"lastName": "Smith",
"homePhone": "12135551127",
"properties": {
"age": 30
}
}
]
}';
$request1->getOperationConfig()->setBodyParameter($body);
$result1 = $client->request($request1);
$json = json_decode($result1->getBody());
$request2 = $client->createContactList();
$body = '{
"name":"My Contact List",
"contactIds": [
800634185003,
800734186003,
800834187003,
800984185003
]
}';
$request2->getOperationConfig()->setBodyParameter($body);
$result2 = $client->request($request2);
$request3 = $client->createContactList();
$body = '{
"name":"My Contact List",
"contactNumbers": [
"12132212384",
"12136612355",
"12133312300"
],
contactNumbersField: "workPhone"
}';
$request3->getOperationConfig()->setBodyParameter($body);
$result3 = $client->request($request3);
}
}
ApiClientSample::main();
[-php]
[[/code-container]]
Create a new list from a CSV file
You can create a new contact list by uploading a CSV file.
Note: each contact should contain at least one phone number.
Limitations:
- file size must not exceed 10 MB.
An example of CSV file format:
firstName,lastName,homePhone,workPhone,custom_age,custom_role,custom_label
Alice,Moore,12345678901,12345678900,30,,team1
Bob,Schmidt,12345678999,12345678888,40,Manager,team1
Jason,Po,12225678999,12345671100,25,,
Eric,Satie,12345678999,12345678888,20,Sales,team2
and how to upload it:
[[code-container]] [+curl] request:
#!/usr/bin/env bash
curl -u username:password -X POST -F "name=My Contact List" -F "file=@contacts.csv" -F "useCustomFields=true" "https://api.callfire.com/v2/contacts/lists/upload"
response:
{
"id": 4
}
[-curl]
[+java]
import com.callfire.api.client.CallfireClient;
import com.callfire.api.client.api.common.model.ResourceId;
import java.io.File;
class ApiClientSample {
public static void main(String[] args) {
CallfireClient client = new CallfireClient("api login", "api password");
File file = new File("/contacts.csv");
ResourceId resourceId = client.contactListsApi().createFromCsv("My Contact List", file);
}
}
[-java]
[+csharp]
using System.IO;
using CallfireApiClient;
using CallfireApiClient.Api.Common.Model;
public class ApiClientSample
{
public static void Main(string[] args)
{
var client = new CallfireClient("api_login", "api_password");
var path = "/contacts.csv";
ResourceId listId = client.ContactListsApi.CreateFromCsv("My Contact List", Path.GetFullPath(path));
}
}
[-csharp]
[+js]
'strict'
const CallfireClient = require('callfire-api-client-js');
const client = new CallfireClient('api-login', 'api-password');
client.ready(() => {
client.contacts.createContactListFromFile({
name: 'My Contact List',
file: new Blob([''], {type: 'text/plain'})
})
.then((response) => {
console.log(response.obj);
})
.catch((err) => {
console.log('request error ' + err.data);
});
},
(clientError) => {
console.log('client error ' + clientError);
}
);
[-js]
[+python]
from callfire.client import CallfireClient
client = CallfireClient('api-login', 'api-password')
response = client.contacts.createContactListFromFile(
name='My Contact List',
file=open('contacts.csv', 'r')
).result()
# see sample JSON response for this API
# on 'curl' samples tab
print(response)
[-python]
[+php]
<?php
class ApiClientSample {
public static function main() {
$client = \CallFire\Api\DocumentedClient::createClient("login", "password");
$request = $client->createContactListFromFile();
$request->getOperationConfig()->setFileUpload(__dir__.'\contacts.csv', 'My Contact List');
$result = $client->request($request);
$json = json_decode($result->getBody());
}
}
ApiClientSample::main();
[-php]
[[/code-container]]
If you already have a contact list in your account, you can add new contacts to it. This API supports the same input sources as thr Create Contact List API. The following code samples show how to add new contacts from various sources.
[[code-container]] [+curl] request:
#!/usr/bin/env bash
curl -u username:password -H "Content-Type:application/json" -X POST -d '
{
"contacts":
[
{
"firstName":"Alice",
"lastName":"Moore",
"homePhone":"12135551126"
},
{
"firstName":"Bob",
"lastName":"Smith",
"homePhone":"12135551127",
"properties":
{
"age":30
}
}
]
}' "https://api.callfire.com/v2/contacts/lists/45006708003/items"
curl -u username:password -H "Content-Type:application/json" -X POST -d '
{
"contactIds":
[
800634185003,
800734186003,
800834187003,
800984185003
]
}' "https://api.callfire.com/v2/contacts/lists/45006708003/items"
curl -u username:password -H "Content-Type:application/json" -X POST -d '
{
"contactNumbers":
[
"12132212384",
"12136612355",
"12133312300"
],
"contactNumbersField":"workPhone"
}' "https://api.callfire.com/v2/contacts/lists/45006708003/items"
response:
200 OK - No Response
[-curl]
[+java]
import com.callfire.api.client.CallfireClient;
import com.callfire.api.client.api.contacts.model.Contact;
import com.callfire.api.client.api.contacts.model.request.AddContactListItemsRequest;
import java.util.Arrays;
class ApiClientSample {
public static void main(String[] args) {
CallfireClient client = new CallfireClient("api login", "api password");
Contact contact1 = new Contact();
contact1.setFirstName("Alice");
contact1.setLastName("Moore");
contact1.setHomePhone("12135551126");
Contact contact2 = new Contact();
contact1.setFirstName("Bob");
contact1.setLastName("Smith");
contact1.setHomePhone("12135551127");
contact1.getProperties().put("age", "30");
AddContactListItemsRequest request1 = AddContactListItemsRequest.<Contact>create()
.contactListId(45006708003L)
.contacts(Arrays.asList(contact1, contact2))
.build();
client.contactListsApi().addListItems(request1);
AddContactListItemsRequest request2 = AddContactListItemsRequest.<String>create()
.contactListId(45006708003L)
.contactNumbersField("workPhone")
.contacts(Arrays.asList("12132212384", "12136612355", "12133312300"))
.build();
client.contactListsApi().addListItems(request2);
AddContactListItemsRequest request3 = AddContactListItemsRequest.<Long>create()
.contactListId(45006708003L)
.contacts(Arrays.asList(800634185003L, 800734186003L, 800834187003L, 800984185003L))
.build();
client.contactListsApi().addListItems(request3);
}
}
[-java]
[+csharp]
using System.Collections.Generic;
using CallfireApiClient;
using CallfireApiClient.Api.Contacts.Model;
using CallfireApiClient.Api.Contacts.Model.Request;
public class ApiClientSample
{
public static void Main(string[] args)
{
var client = new CallfireClient("api_login", "api_password");
var request1 = new AddContactListContactsRequest<Contact>
{
Contacts = new List<Contact>
{
new Contact
{
FirstName = "Alice",
LastName = "Moore",
HomePhone = "12135551126"
},
new Contact
{
FirstName = "Bob",
LastName = "Smith",
HomePhone = "12135551127",
Properties = new Dictionary<string, string>
{
{"age", "30"}
}
}
},
ContactListId = 45006708003
};
client.ContactListsApi.AddListItems(request1);
var request2 = new AddContactListContactsRequest<string>
{
Contacts = new List<string> {"12132212384", "12136612355", "12133312300"},
ContactNumbersField = "workPhone",
ContactListId = 45006708003
};
client.ContactListsApi.AddListItems(request2);
var request3 = new AddContactListContactsRequest<long>
{
Contacts = new List<long> {800634185003, 800734186003, 800834187003, 800984185003},
ContactListId = 45006708003
};
client.ContactListsApi.AddListItems(request3);
}
}
[-csharp]
[+js]
'strict'
const CallfireClient = require('callfire-api-client-js');
const client = new CallfireClient('api-login', 'api-password');
client.ready(() => {
client.contacts.addContactListItems({
id: 45006708003,
body: {
// choose one of source of contacts: array of contact objects / existing contacts (ids) / array of numbers
contacts: [
{
firstName: 'Alice',
lastName: 'Moore',
homePhone: '12135551126'
},
{
firstName: 'Bob',
lastName: 'Smith',
homePhone: '12135551127',
properties: {
age: 30
}
}
],
// add existing contacts to list
// contactIds: [
// 800634185003,
// 800734186003,
// 800834187003,
// 800984185003
// ],
// add phone numbers to list
// contactNumbers: [
// '12132212384',
// '12136612355',
// '12133312300'
// ],
// contactNumbersField: 'workPhone'
}
})
.then((response) => {
console.log(response.obj);
})
.catch((err) => {
console.log('request error ' + err.data);
});
},
(clientError) => {
console.log('client error ' + clientError);
}
);
[-js]
[+python]
from callfire.client import CallfireClient
client = CallfireClient('api-login', 'api-password')
response = client.contacts.addContactListItems(
id=45006708003,
body={
# choose one of source of contacts: array of contact objects / existing contacts (ids) / array of numbers
'contacts': [
{
'firstName': 'Alice',
'lastName': 'Moore',
'homePhone': '12135551126'
},
{
'firstName': 'Bob',
'lastName': 'Smith',
'homePhone': '12135551127',
'properties': {
'age': 30
}
}
],
# add existing contacts to list
# contactIds: [
# 800634185003,
# 800734186003,
# 800834187003,
# 800984185003
# ],
# add phone numbers to list
# contactNumbers: [
# '12132212384',
# '12136612355',
# '12133312300'
# ],
# contactNumbersField: 'workPhone'
}
).result()
# see sample JSON response for this API
# on 'curl' samples tab
print(response)
[-python]
[+php]
<?php
class ApiClientSample {
public static function main() {
$client = \CallFire\Api\DocumentedClient::createClient("login", "password");
$request1 = $client->addContactListItems();
$request1->getOperationConfig()->setPathParameters(array("id" => 45006708003));
$body = '{
"contacts":
[
{
"firstName":"Alice",
"lastName":"Moore",
"homePhone":"12135551126"
},
{
"firstName":"Bob",
"lastName":"Smith",
"homePhone":"12135551127",
"properties":
{
"age":30
}
}
]
}';
$request1->getOperationConfig()->setBodyParameter($body);
$result1 = $client->request($request1);
$json = json_decode($result1->getBody());
$request2 = $client->addContactListItems();
$request2->getOperationConfig()->setPathParameters(array("id" => 45006708003));
$body = '{
"contactIds":
[
800634185003,
800734186003,
800834187003,
800984185003
]
}';
$request2->getOperationConfig()->setBodyParameter($body);
$result2 = $client->request($request2);
$json = json_decode($result2->getBody());
$request3 = $client->addContactListItems();
$request3->getOperationConfig()->setPathParameters(array("id" => 45006708003));
$body = '{
"contactNumbers":
[
"12132212384",
"12136612355",
"12133312300"
],
"contactNumbersField":"workPhone"
}';
$request3->getOperationConfig()->setBodyParameter($body);
$result3 = $client->request($request3);
$json = json_decode($result3->getBody());
}
}
ApiClientSample::main();
[-php]
[[/code-container]]