---
title: ContactsGroup
description: Group of contacts.
---

Group of contacts.

A contacts container may have several groups of contacts. A contact can only belong to a single contacts container but may belong to zero or more contacts groups. For example, an iCloud account has only one container but may have many groups.

## Properties

### identifier

Identifier of the contacts group.

```typescript
identifier: string
```

Read-only.

### name

Name of the contacts group.

```typescript
name: string
```

## Methods

<span id="-new-contactsgroup" class="api-anchor"></span>

### new ContactsGroup()

Constructs a contacts group.

```typescript
new ContactsGroup()
```

In order to add the group to your address book, you must queue it for insertion using `ContactsGroup.add()`. When you're done making changes to the address book you should call `Contact.persistChanges()` to persist the changes.

<span id="add" class="api-anchor"></span>

### add(group, containerIdentifier)

Queues a contacts group to be added.

```typescript
static add(group: ContactsGroup, containerIdentifier: string)
```

After you have created a group, you must queue the group to be added to the address book and invoke `Contact.persistChanges()` to persist the changes to the address book.

For performance reasons, it is best to batch changes to the address book. Therefore you should queue all updates, insertions and removals of contacts and contacts groups to as large batches as possible and then call `Contact.persistChanges()` when you want to persist the changes to the address book.

#### Parameters

**`group` `ContactsGroup`**

Contacts group to queue to be added.

**`containerIdentifier` `string`**

Optional. Identifier of container to add the contacts group to. If null is specified, the group will be added to the default container.

<span id="-addmember" class="api-anchor"></span>

### addMember(contact)

Adds a contact to the group.

```typescript
addMember(contact: Contact)
```

In order to persist the change, you should call `Contact.persistChanges()`. It is important that the contact is added to the address book. To add the contact to the address book, you should queue it for insertion using `Contact.add()` before persisting the changes.

#### Parameters

**`contact` `Contact`**

Contact to add to the group.

<span id="all" class="api-anchor"></span>

### all(containers)

Fetches contacts groups.

```typescript
static all(containers: [ContactsContainer]): Promise<[ContactsGroup]>
```

Fetches the contacts groups in the specified containers. A group can be in only one container.

#### Parameters

**`containers` `[ContactsContainer]`**

Container to fetch contacts groups from.

#### Return value

**`Promise<[ContactsGroup]>`**

Promise that provides the contacts groups when fulfilled.

<span id="delete" class="api-anchor"></span>

### delete(group)

Queues a contacts group to be deleted.

```typescript
static delete(group: ContactsGroup)
```

To delete a contacts group, you must queue the group for deletion and invoke `Contact.persistChanges()` to persist the changes to the address book.

For performance reasons, it is best to batch changes to the address book. Therefore you should queue all updates, insertions and removals of contacts and contacts groups to as large batches as possible and then call `Contact.persistChanges()` when you want to persist the changes to the address book.

#### Parameters

**`group` `ContactsGroup`**

Contacts group to queue to be deleted.

<span id="-removemember" class="api-anchor"></span>

### removeMember(contact)

Removes a contact from the group.

```typescript
removeMember(contact: Contact)
```

In order to persist the change, you should call `Contact.persistChanges()`.
It is important that the contact is added to the address book. To add the contact to the address book, you should queue it for insertion using `Contact.add()` before persisting the changes.

#### Parameters

**`contact` `Contact`**

Contact to add to the group.

<span id="update" class="api-anchor"></span>

### update(group)

Queues an update to a contacts group.

```typescript
static update(group: ContactsGroup)
```

After you have updated one or more properties on a contacts group, you must queue the group to be updated and invoke `Contact.persistChanges()` to persist the changes to the address book.

For performance reasons, it is best to batch changes to the address book. Therefore you should queue all updates, insertions and removals of contacts and contacts groups to as large batches as possible and then call `Contact.persistChanges()` when you want to persist the changes to the address book.

#### Parameters

**`group` `ContactsGroup`**

Contacts group to queue to be updated.