Overview
Contact Lists allow you to segment your CRM contacts into targeted groups for campaigns, automations, and analytics.
Methods
getLists
Retrieve all contact lists.
db.crm.getLists(): ContactList[]
Array of all contact lists
Example:
const lists = db.crm.getLists();
console.log(`Total lists: ${lists.length}`);
addList
Create a new contact list.
db.crm.addList(listData: Omit<ContactList, 'id' | 'createdAt'>): ContactList
Initial contact count (defaults to 0)
The newly created list with generated ID and timestamp
Example:
const newList = db.crm.addList({
name: 'Newsletter Subscribers',
description: 'All active newsletter subscribers',
contactCount: 0
});
updateList
Update an existing list.
db.crm.updateList(list: ContactList): ContactList[]
Complete list object with updates
Updated array of all lists
Example:
const list = db.crm.getLists()[0];
list.description = 'Updated description';
list.contactCount = 150;
db.crm.updateList(list);
deleteList
Delete a list and remove it from all contacts.
db.crm.deleteList(listId: string): ContactList[]
Updated array of remaining lists
Example:
db.crm.deleteList('list_12345');
Deleting a list will automatically remove the listId reference from all contacts’ listIds arrays.
interface ContactList {
id: string;
name: string;
description: string;
createdAt: string;
contactCount?: number;
}
Working with List Membership
Contacts can belong to multiple lists via the listIds field.
const contact = db.crm.getById('c_12345');
if (contact) {
const listIds = contact.listIds || [];
if (!listIds.includes('list_abc')) {
contact.listIds = [...listIds, 'list_abc'];
db.crm.update(contact);
}
}
const contact = db.crm.getById('c_12345');
if (contact && contact.listIds) {
contact.listIds = contact.listIds.filter(id => id !== 'list_abc');
db.crm.update(contact);
}
const listId = 'list_12345';
const contactsInList = db.crm.getAll()
.filter(c => c.listIds?.includes(listId));
console.log(`Contacts in list: ${contactsInList.length}`);
Use Cases
Segmentation
Create lists for different member types, interests, or engagement levels
Campaigns
Target specific lists with email campaigns
Automations
Trigger automations when contacts join lists
Analytics
Track growth and engagement per list