Skip to main content

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[]
lists
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
listData.name
string
required
List name
listData.description
string
required
List description
listData.contactCount
number
Initial contact count (defaults to 0)
list
ContactList
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[]
list
ContactList
required
Complete list object with updates
lists
ContactList[]
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[]
listId
string
required
ID of the list to delete
lists
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.

ContactList Type

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.

Add Contact to List

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);
  }
}

Remove Contact from List

const contact = db.crm.getById('c_12345');
if (contact && contact.listIds) {
  contact.listIds = contact.listIds.filter(id => id !== 'list_abc');
  db.crm.update(contact);
}

Get Contacts in List

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

Build docs developers (and LLMs) love