readyDocs Open the appOpen the app

Smart Lists

A smart list is a saved audience. The paths say /segments for historical reasons. A smart list made here is filter rules, like "tagged vip and in Texas", so the list updates as your contacts change. A fixed list of contacts made under Contact lists shows here too, with the same id. Pass its id as segment_id to a campaign or a drip campaign.

#The Smart list object

idinteger
The list id. Pass it as segment_id.
namestring
The list’s name.
descriptionstring
Your description, or "".
filter_rulesstring | null
The rules, as a JSON-encoded string of rule objects. null on a fixed list. When you send rules, send a real array.
Child attributes

A rule is {"field": "...", "operator": "...", "value": "..."}. A contact must match every rule. A rule with a field or operator we don’t support is refused with segment_rule_unsupported, so a typo never sends to everyone.

  • tags: contains, not_contains, is_any_of, is_none_of (comma separated), exists, not_exists.
  • pipeline_stage, status: equals, not_equals, is_any_of, is_none_of, exists, is_empty.
  • first_name, last_name, company_name, city, state, postal_code, source: equals, not_equals, contains, not_contains, is_any_of.
  • email: equals, not_equals, contains, not_contains, exists, is_empty.
  • score: greater_than, less_than, equals, gte, lte, between ("40,80").
  • created_at: after, before, days_ago_more, days_ago_less.
  • last_activity (Last edited: when the contact was last edited, its updated_at; any edit, tag or import counts, and it is not the last text or call. To filter by the last text, use last_activity on List contacts): after, before, days_ago_more, days_ago_less.
  • For after and before, send ISO 8601 or YYYY-MM-DD; a date alone is midnight UTC, so after includes that day and before leaves it out.
  • custom_field: add key (the field name) or field_id; operators equals, not_equals, contains, not_contains, is_set, is_empty.
contact_countinteger | null
How many contacts are in the list. null when your seat only sees its assigned contacts.
is_dynamicinteger
In List smart lists, 1 for a rules list and 0 for a fixed list of contacts. The other endpoints return the stored value, which is 0 for a list made with POST /segments. Don’t use it to tell the two apart outside List smart lists.
created_atstring
When the list was made, ISO 8601.

#List smart lists

Every smart list on your account, newest first, with how many contacts are in each. Needs the view_contacts permission.

Returns a list of Smart list objects in data.

Errors
HTTPCodeWhen
500segments_read_failedWe couldn’t read your lists. Retry.
500segments_count_failedWe couldn’t count the contacts in your lists. Retry.

#Get a smart list

One smart list with its rules. Needs the view_contacts permission.

Errors
HTTPCodeWhen
400invalid_fieldThe id isn’t a positive whole number.
404segment_not_foundNo smart list with this id on your account.

#List contacts in a smart list

The contacts the list matches right now, most recently updated first. Needs the view_contacts permission.

Parameters

limitinteger · queryDefault 50Max 1000
offsetinteger · queryDefault 0
afterstring · query
The next_cursor of the previous page. Reads the page that follows it, however far into a large list; use it instead of offset to walk a list of hundreds of thousands. offset is ignored when after is sent.
ids_only, ids_limitinteger · query
With ids_only=1, returns {ids, has_more} instead of contacts: up to ids_limit contact ids, newest first (max 100,000).

Returns a list of Contact objects in data.

Returns
total, total_is_estimateinteger, boolean
How many match. On very large accounts the total can be an estimate. total is null when we could not count them in time; fetch again for the count.
next_cursorstring or null
Send it as after to get the next page. null when this page was shorter than limit, which means the list is read to the end.
Errors
HTTPCodeWhen
400invalid_fieldThe id isn’t a positive whole number.
404segment_not_foundNo smart list with this id on your account.
400invalid_fieldafter isn’t a next_cursor from an earlier page. Start again without it.
500segment_rules_damagedThe list’s saved rules can’t be read. Send new filter_rules with Update a smart list.
503segment_read_failedWe couldn’t read the list just now. Retry.

#Create a smart list

Saves filter rules as a smart list. Returns 201. The same name, description and rules again within 2 minutes returns the first one with deduped: true. Needs the edit_contacts permission.

Parameters

namestringRequired
filter_rulesobject[]
An array of rules. See filter_rules for the shape. Leave it out to make an empty list, then fill it with Add contacts to a smart list.
descriptionstring

Returns a Smart list object in data, plus deduped: true when it’s a repeat.

Errors
HTTPCodeWhen
400segment_name_requiredNo name.
400invalid_fieldfilter_rules isn’t a list.
400segment_rule_unsupportedA rule names a field or operator we don’t support.
500segment_create_failedWe couldn’t confirm the list was saved. List your smart lists before you try again.
503segment_count_failedWe couldn’t count the list’s contacts, so nothing was saved. Retry.

#Update a smart list

Changes the name, description or rules. Sending filter_rules to a fixed list turns it into a rules list: its contacts are then the ones the rules match. Needs the edit_contacts and manage_campaigns permissions. If the save landed but we couldn’t read the list back, you get 200 with data: null and warning_code: "SEGMENT_REREAD_FAILED": the change is saved, so get the list.

Parameters

namestring
filter_rulesobject[]
Replaces the rules.
descriptionstring
Errors
HTTPCodeWhen
400segment_name_requiredname is empty.
400nothing_to_updateNo name, description or filter_rules sent.
400invalid_fieldfilter_rules isn’t a list.
400segment_rule_unsupportedA rule names a field or operator we don’t support.
400invalid_fieldThe id isn’t a positive whole number.
404segment_not_foundNo smart list with this id on your account.
500segment_update_failedNothing was saved. Retry.
500segment_update_unconfirmedWe couldn’t confirm the save. Get the list before you try again.

#Add contacts to a smart list

The same as Add contacts to a list, with segment_ error codes; new code should use /lists. Puts specific contacts in a list, up to 50,000 at a time. On a rules list we tag them so the list includes them. Adding someone twice is safe. Needs the edit_contacts permission.

Parameters

contact_idsinteger[]
Required unless you send all.
allboolean
true adds every contact you can see instead of a list of ids. Campaigns that send to this list then reach all of them, and so does any drip you later fill from it. There is no count beforehand and no undo token. On a rules list, take them back out by removing the smartlist-<id> tag with Tag or untag many contacts, which returns an undo_token.
Returns
addedinteger
Contacts added. With all: true on a rules list the answer is 202 with queued: true, job_id and tag instead, and the contacts are tagged in the background.
contact_countinteger | null
How many are in the list now. null on a rules list when the count couldn’t be read, or when your seat only sees its assigned contacts; the add still worked.
tagstring
Rules lists only: the tag the contacts got, smartlist-<id>.
Errors
HTTPCodeWhen
400no_contacts_selectedNo contacts.
400too_many_contactsMore than 50,000.
400invalid_fieldThe id isn’t a positive whole number.
404segment_not_foundNo smart list with this id on your account.
500segment_rules_damagedThe contacts got the tag but the list’s rules can’t be read, so they aren’t in it. Send new filter_rules with Update a smart list, then add them again.
500segment_add_failedThe add didn’t finish. Adding the same contacts again is safe.

#Delete a smart list

The same as Delete a list, with segment_ error codes; new code should use /lists. Deletes the list. Your contacts stay; the ones you added by hand lose its smartlist-<id> tag. Needs the edit_contacts and manage_campaigns permissions.

Parameters

forceinteger · query
1 deletes the list even when campaigns that haven’t sent yet use it. Those campaigns then fail.

Returns { "success": true }.

Errors
HTTPCodeWhen
400invalid_fieldThe id isn’t a positive whole number.
404segment_not_foundNo smart list with this id on your account.
409segment_in_useDraft, scheduled or paused campaigns send to this list. campaigns lists them (id, name, status). Send ?force=1 to delete anyway. Delete a list answers the same case as list_in_use.
409list_in_useAnother smart list’s rules use this list. Change those rules first; force doesn’t override this.
500segment_delete_failedNothing was deleted. Retry.