Contact lists
A contact list is a group of contacts you pick by hand. Lists and smart lists are the same thing underneath: one set of lists with one set of ids. GET /lists shows both kinds, and a list you make here works anywhere a segment_id is asked for, such as a campaign audience. A list made here holds only the contacts you add. A smart list made with POST /segments holds the contacts its rules match plus any you add by hand.
These paths start with /lists. The older /dialer/lists paths answer the same. Every route here needs the view_contacts permission, which every role holds by default.
Taking a contact out of a list only happens through Remove contacts from a list. Deleting a list never deletes its contacts.
#The Contact list object
idinteger- The list id. It also works as a
segment_id. namestring- The list’s name.
descriptionstring- Your description, or
"". contact_countinteger | null- How many contacts are in the list. A hand-picked list is counted live. A smart list shows its last saved count, or
nullwhen your seat only sees its assigned contacts. is_dynamicinteger1for a smart list or a list we refill on a schedule,0for a fixed list of contacts.created_atstring- When the list was made.
#List contact lists
Every list on your account, hand-picked lists and smart lists alike, newest first, with how many contacts are in each. Shows up to 500 lists.
Returns
listsobject[]- A list of Contact list objects.
truncatedbooleantruewhen you have more than 500 lists and only the first 500 are shown.
Errors
| HTTP | Code | When |
|---|---|---|
| 500 | lists_read_failed | We couldn’t load your lists. Retry. |
#List contacts in a list
One page of a list’s contacts. A hand-picked list shows the most recently added first. A smart list shows the contacts its rules match now plus the ones added by hand, newest contact first. To get the next page, pass the last page’s next_cursor as after.
Parameters
limitinteger · queryDefault100Max500afterinteger · query- The
next_cursorfrom the page before. searchstring · query- Only contacts whose first name, last name or phone contains this text. Up to 100 characters are used.
Returns
listobject- The list’s
id,nameanddescription. contactsobject[]- Each has
id,first_name,last_name,phone,email,status,last_disposition(the last call result, if you use the dialer),added_at(when it joined the list;nullon a smart list) andcursor. totalinteger- How many contacts match, across all pages.
total_is_estimateboolean- Smart lists only.
truewhen the total couldn’t be counted in time and is the last known count. next_cursorinteger- Pass it as
afterfor the next page.nullwhen this page wasn’t full.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | list_not_found | The id isn’t a whole number. |
| 404 | list_not_found | No list with this id on your account. |
| 500 | rules_damaged | This smart list’s saved rules are damaged. Save its rules again with Update a smart list. |
| 500 | load_failed | We couldn’t load the contacts. Retry. |
#Create a list
Makes an empty hand-picked list. Returns 201. Sending the same name again within 2 minutes returns the first list with deduped: true. Needs the edit_contacts permission.
Parameters
namestringRequired- Up to 200 characters; longer names are cut.
descriptionstring- Up to 1,000 characters; longer text is cut.
Returns the new list’s id in data, plus deduped: true when it’s a repeat.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | name_required | No name. |
| 400 | invalid_field | name or description is a list or object. |
| 500 | create_failed | We couldn’t create the list. Retry. |
#Rename a list
Changes a list’s name and description. Works on smart lists too, and leaves their rules alone. Send name every time, even when you only change the description. Needs the manage_campaigns permission.
Parameters
namestringRequired- Up to 200 characters; longer names are cut.
descriptionstring- Up to 1,000 characters. Leave it out to keep the current one.
Returns { "success": true }.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | name_required | No name. |
| 400 | invalid_field | name or description is a list or object. |
| 400 | list_not_found | The id isn’t a whole number. |
| 404 | list_not_found | No list with this id on your account. |
| 500 | update_failed | We couldn’t save the list. Retry. |
#Delete a list
Deletes a list of either kind. Its contacts stay in your account; only their place in the list goes. Campaigns that used the list lose it as their audience. On a smart list we also take its smartlist-<id> tag off your contacts. Needs the manage_campaigns permission.
Parameters
forcestring · query- Send
1to delete a list that unsent campaigns still send to. Those campaigns then won’t send.
Returns { "success": true }.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | list_not_found | The id isn’t a whole number. |
| 404 | list_not_found | No list with this id on your account. |
| 409 | list_in_use | Another smart list’s rules use this list. Change those rules first; force doesn’t skip this. |
| 409 | list_in_use | A draft, scheduled or paused campaign sends to this list, and you didn’t send force=1. The body has a campaigns list with each one’s id, name and status. |
| 500 | delete_failed | Nothing was deleted. Retry. |
#Add contacts to a list
Adds your contacts to a list by id, up to 50,000 at a time. Works on both kinds of list. Ids that aren’t contacts on your account are skipped, and adding someone twice is safe. Needs the edit_contacts permission.
Parameters
contact_idsinteger[]Required- The contacts to add. You can send one id as
contact_idinstead.
Returns
addedinteger- Contacts newly added. Ones already in the list aren’t counted.
totalinteger | null- How many contacts are in the list now.
nullon a smart list when your seat only sees its assigned contacts.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_contacts | No ids, more than 50,000, or none of them is a valid id. |
| 400 | invalid_field | contact_ids isn’t a list, or contact_id is a list. |
| 400 | list_not_found | The list id isn’t a whole number. |
| 404 | list_not_found | No list with this id on your account. |
| 500 | list_total_unconfirmed | The contacts were added, but we couldn’t count the list after. |
| 500 | add_failed | We couldn’t add the contacts. Retrying is safe. |
#Add one contact or phone number to a list
Adds one contact by id, or by phone number. With a phone number and no contact_id, we use your contact with that number, or make a new contact for it, then add it. Needs the edit_contacts permission.
Parameters
contact_idinteger- The contact to add.
phonestring- A phone number, used when there is no
contact_id.
Returns added and total, as Add contacts to a list does.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_contacts | No usable contact_id and no phone. |
| 400 | invalid_phone | The phone number isn’t one we can read. |
| 400 | invalid_field | contact_id or phone is a list or object. |
| 400 | list_not_found | The list id isn’t a whole number. |
| 404 | list_not_found | No list with this id on your account. |
| 500 | list_total_unconfirmed | The contact was added, but we couldn’t count the list after. |
| 500 | add_failed | We couldn’t add the contact. Retrying is safe. |
#Remove contacts from a list
Takes contacts out of a list, up to 50,000 at a time. This is the only route that does. The contacts stay in your account. Needs the edit_contacts permission.
On a smart list, this removes contacts added by either add route (Add contacts to a list or Add contacts to a smart list). A contact the list’s rules still match stays in the list, and still_matching tells you how many did.
Parameters
contact_idsinteger[]Required- The contacts to remove.
Returns
totalinteger- How many contacts are in the list now.
still_matchinginteger- How many of the contacts you sent are still in a smart list because its rules match them. Always
0on a hand-picked list.nullwhen we couldn’t work it out.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_contacts | No ids, more than 50,000, or none of them is a valid id. |
| 400 | invalid_field | contact_ids isn’t a list. |
| 400 | list_not_found | The list id isn’t a whole number. |
| 404 | list_not_found | No list with this id on your account. |
| 500 | list_total_unconfirmed | The contacts were removed, but we couldn’t count the list after. |
| 500 | remove_failed | We couldn’t remove the contacts. Retrying is safe. |
#Preview a smart list
Counts how many of your contacts a set of rules matches, without saving anything. Use it to check rules before you create a smart list. Needs the edit_contacts permission.
Parameters
filter_rulesobject[]- An array of rules. See
filter_rulesfor the shape. No rules, or a value that isn’t a list, matches nobody:countis0, and a top-levelnotesays no rules were read. include_sampleboolean- Also return up to 5 matching contacts, newest first.
Returns
countinteger- How many contacts match.
sampleobject[]- Only with
include_sample. Each hasid,first_name,last_nameandphone.
Errors
| HTTP | Code | When |
|---|---|---|
| 400 | segment_rule_unsupported | A rule names a field or operator we don’t support. |
| 400 | invalid_field | include_sample is a list or object. |
| 503 | segment_preview_failed | We couldn’t count the matching contacts. Retry. |